Open MPI logo

Hardware Locality Users' Mailing List Archives

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

Subject: Re: [hwloc-users] bind process to built cpuset
From: Brice Goglin (Brice.Goglin_at_[hidden])
Date: 2012-02-21 07:01:32


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-users_at_[hidden]
>>> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users
>> _______________________________________________
>> hwloc-users mailing list
>> hwloc-users_at_[hidden]
>> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users
> _______________________________________________
> hwloc-users mailing list
> hwloc-users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users