Thank you very much, Brice!


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 :
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)
core2 = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, 5);
if (!core2)
cpuset = hwloc_bitmap_alloc();
if (!cpuset);
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)
hwloc_bitmap_or(cpuset, cpuset, core2->cpuset);


hwloc-users mailing list

Reply via email to