Open MPI logo

Hardware Locality Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Development mailing list

Subject: Re: [hwloc-devel] The de-C99 of hwloc
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2011-02-18 10:55:25


On Feb 18, 2011, at 4:10 AM, Samuel Thibault wrote:

>>>> + /* Setup ordering arrays */
>>>> + if (!orders_initialized) {
>>>> + obj_type_order[HWLOC_OBJ_SYSTEM] = 0;
>>>> + obj_type_order[HWLOC_OBJ_MACHINE] = 1;
>>>> + obj_type_order[HWLOC_OBJ_GROUP] = 2;
>>>> + obj_type_order[HWLOC_OBJ_NODE] = 3;
>>>> + obj_type_order[HWLOC_OBJ_SOCKET] = 4;
>>>> + obj_type_order[HWLOC_OBJ_CACHE] = 5;
>>>> + obj_type_order[HWLOC_OBJ_CORE] = 6;
>>>> + obj_type_order[HWLOC_OBJ_PU] = 7;
>>>> + obj_type_order[HWLOC_OBJ_MISC] = 8;
>>>> +
>>>> + orders_initialized = 1;
>>>> + }
>>>>
>>> This is not actually thread safe. This needs a CPU write memory barrier
>>> between the last obj_type_order[] array write and the orders_initialized
>>> write, and a read barrier after orders_initialized is read as being
>>> 1, to make sure that a cpu seeing orders_initialized as 1 will always
>>> also see the values in obj_type_order. A simpler way is to use
>>> pthread_once().

Let's do pthread_once() -- we don't have any of the infrastructure mojo for memory barriers.

What will we need on Windows? Are there other OS's without pthread_once()?

>> Is there no portable way to define a library _init function?
>
> Not even in C99.

Where should this functionality be, if we can't put it in an _init function, and it doesn't belong in the topology init function?

-- 
Jeff Squyres
jsquyres_at_[hidden]
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/