Re: [hwloc-users] bind process to built cpuset

2012-02-21 Thread Brice Goglin
void hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1,
hwloc_const_bitmap_t bitmap2);

The first argument is the destination, it's not const. Only the source
arguments (second and third) are const.

Brice




Le 21/02/2012 12:18, Albert Solernou a écrit :
> Hi, I just tried it and it works nicely!
>
> I didn't tried it myself because the documentation of the library
> states that two of the arguments in hwloc_bitmap_or are
> hwloc_const_bitmap_t. However, in your approach only one of  them is
> constant. Anyway, it is working now.
>
> Best,
> Albert
>
> On Tue 21 Feb 2012 09:46:46 GMT, Albert Solernou wrote:
>> Thank you very much, Brice!
>>
>> Best,
>> Albert
>>
>> On Mon 20 Feb 2012 18:09:55 GMT, Brice Goglin wrote:
>>> Le 20/02/2012 19:06, Brice Goglin a écrit :
 Le 20/02/2012 17:41, Albert Solernou a écrit :
> Hi,
> I'd like to bind a process to a cpuset, so that when it spawns on
> several threads, those are trapped on that cpuset.
>
> In order to do so, I want to define my own cpuset. Let's say I
> want it
> to include HWLOC_OBJ_CORE 2 and 5. How can I create this cpuset? The
> bitmap api sounds like the solution to me, but I couldn't relate the
> indexes in there into HWLOC_OBJects of any type...
 If you want to bind to cores #2 and #5, do:

 hwloc_bitmap_t cpuset;
 hwloc_obj_t core1, core2;

 core1 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 2);
 if (!core1)
  error...
 core2 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 5);
 if (!core2)
  error...
 cpuset = hwloc_bitmap_alloc();
 if (!cpuset);
  error...
 hwloc_bitmap_or(cpuset, cpuset, core1->cpuset);
 hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);
>>>
>>> By the way, alloc()+or() can be optimized as dup():
>>>
>>> cpuset = hwloc_bitmap_dup(core1->cpuset);
>>> if (!cpuset)
>>>  error...
>>> hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);
>>>
>>> Brice
>>>
>>> ___
>>> hwloc-users mailing list
>>> hwloc-us...@open-mpi.org
>>> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users
>> ___
>> hwloc-users mailing list
>> hwloc-us...@open-mpi.org
>> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users
> ___
> hwloc-users mailing list
> hwloc-us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users



Re: [hwloc-users] bind process to built cpuset

2012-02-21 Thread Albert Solernou
Hi, 
I just tried it and it works nicely!


I didn't tried it myself because the documentation of the library 
states that two of the arguments in hwloc_bitmap_or are 
hwloc_const_bitmap_t. However, in your approach only one of  them is 
constant. Anyway, it is working now.


Best,
Albert

On Tue 21 Feb 2012 09:46:46 GMT, Albert Solernou wrote:

Thank you very much, Brice!

Best,
Albert

On Mon 20 Feb 2012 18:09:55 GMT, Brice Goglin wrote:

Le 20/02/2012 19:06, Brice Goglin a écrit :

Le 20/02/2012 17:41, Albert Solernou a écrit :

Hi,
I'd like to bind a process to a cpuset, so that when it spawns on
several threads, those are trapped on that cpuset.

In order to do so, I want to define my own cpuset. Let's say I want it
to include HWLOC_OBJ_CORE 2 and 5. How can I create this cpuset? The
bitmap api sounds like the solution to me, but I couldn't relate the
indexes in there into HWLOC_OBJects of any type...

If you want to bind to cores #2 and #5, do:

hwloc_bitmap_t cpuset;
hwloc_obj_t core1, core2;

core1 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 2);
if (!core1)
 error...
core2 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 5);
if (!core2)
 error...
cpuset = hwloc_bitmap_alloc();
if (!cpuset);
 error...
hwloc_bitmap_or(cpuset, cpuset, core1->cpuset);
hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);


By the way, alloc()+or() can be optimized as dup():

cpuset = hwloc_bitmap_dup(core1->cpuset);
if (!cpuset)
 error...
hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);

Brice

___
hwloc-users mailing list
hwloc-us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users

___
hwloc-users mailing list
hwloc-us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users


Re: [hwloc-users] bind process to built cpuset

2012-02-21 Thread Albert Solernou

Thank you very much, Brice!

Best,
Albert

On Mon 20 Feb 2012 18:09:55 GMT, Brice Goglin wrote:

Le 20/02/2012 19:06, Brice Goglin a écrit :

Le 20/02/2012 17:41, Albert Solernou a écrit :

Hi,
I'd like to bind a process to a cpuset, so that when it spawns on
several threads, those are trapped on that cpuset.

In order to do so, I want to define my own cpuset. Let's say I want it
to include HWLOC_OBJ_CORE 2 and 5. How can I create this cpuset? The
bitmap api sounds like the solution to me, but I couldn't relate the
indexes in there into HWLOC_OBJects of any type...

If you want to bind to cores #2 and #5, do:

hwloc_bitmap_t cpuset;
hwloc_obj_t core1, core2;

core1 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 2);
if (!core1)
error...
core2 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 5);
if (!core2)
error...
cpuset = hwloc_bitmap_alloc();
if (!cpuset);
error...
hwloc_bitmap_or(cpuset, cpuset, core1->cpuset);
hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);


By the way, alloc()+or() can be optimized as dup():

cpuset = hwloc_bitmap_dup(core1->cpuset);
if (!cpuset)
error...
hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);

Brice

___
hwloc-users mailing list
hwloc-us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users


Re: [hwloc-users] bind process to built cpuset

2012-02-20 Thread Brice Goglin
Le 20/02/2012 19:06, Brice Goglin a écrit :
> Le 20/02/2012 17:41, Albert Solernou a écrit :
>> Hi,
>> I'd like to bind a process to a cpuset, so that when it spawns on
>> several threads, those are trapped on that cpuset.
>>
>> In order to do so, I want to define my own cpuset. Let's say I want it
>> to include HWLOC_OBJ_CORE 2 and 5. How can I create this cpuset? The
>> bitmap api sounds like the solution to me, but I couldn't relate the
>> indexes in there into HWLOC_OBJects of any type...
> If you want to bind to cores #2 and #5, do:
>
> hwloc_bitmap_t cpuset;
> hwloc_obj_t core1, core2;
>
> core1 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 2);
> if (!core1)
>error...
> core2 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 5);
> if (!core2)
>error...
> cpuset = hwloc_bitmap_alloc();
> if (!cpuset);
>error...
> hwloc_bitmap_or(cpuset, cpuset, core1->cpuset);
> hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);

By the way, alloc()+or() can be optimized as dup():

cpuset = hwloc_bitmap_dup(core1->cpuset);
if (!cpuset)
   error...
hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);

Brice



Re: [hwloc-users] bind process to built cpuset

2012-02-20 Thread Brice Goglin
Le 20/02/2012 17:41, Albert Solernou a écrit :
> Hi,
> I'd like to bind a process to a cpuset, so that when it spawns on
> several threads, those are trapped on that cpuset.
>
> In order to do so, I want to define my own cpuset. Let's say I want it
> to include HWLOC_OBJ_CORE 2 and 5. How can I create this cpuset? The
> bitmap api sounds like the solution to me, but I couldn't relate the
> indexes in there into HWLOC_OBJects of any type...

If you want to bind to cores #2 and #5, do:

hwloc_bitmap_t cpuset;
hwloc_obj_t core1, core2;

core1 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 2);
if (!core1)
   error...
core2 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 5);
if (!core2)
   error...
cpuset = hwloc_bitmap_alloc();
if (!cpuset);
   error...
hwloc_bitmap_or(cpuset, cpuset, core1->cpuset);
hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);

...
hwloc_set_cpubind(... cpuset, HWLOC_CPUBIND_PROCESS)
...

hwloc_bitmap_free(cpuset);


This uses core logical indexes. If you want physical indexes, let me
know (but those makes sense for PUs, not really for Cores).

> On the other hand, I'd like to know if binding a process in there
> would lock its spawned threads.

Each thread inside the process basically gets the same binding as the
entire process.

Brice