26 static hwloc_topology_t plasma_topology = NULL;
27 static volatile int plasma_nbr = 0;
32 if (!topo_initialized) {
35 hwloc_topology_init(&plasma_topology);
38 hwloc_topology_load(plasma_topology);
41 sys_corenbr = hwloc_get_nbobjs_by_type(plasma_topology, HWLOC_OBJ_CORE);
55 if ((topo_initialized ==1) && (plasma_nbr == 0)) {
57 hwloc_topology_destroy(plasma_topology);
75 hwloc_cpuset_t cpuset;
77 if (!topo_initialized) {
78 plasma_error(
"plasma_setaffinity",
"Topology not initialized");
83 obj = hwloc_get_obj_by_type(plasma_topology, HWLOC_OBJ_CORE, rank);
89 #if !defined(HWLOC_BITMAP_H)
90 cpuset = hwloc_cpuset_dup(obj->cpuset);
91 hwloc_cpuset_singlify(cpuset);
93 cpuset = hwloc_bitmap_dup(obj->cpuset);
94 hwloc_bitmap_singlify(cpuset);
98 if (hwloc_set_cpubind(plasma_topology, cpuset, HWLOC_CPUBIND_THREAD)) {
100 #if !defined(HWLOC_BITMAP_H)
101 hwloc_cpuset_asprintf(&str, obj->cpuset);
103 hwloc_bitmap_asprintf(&str, obj->cpuset);
105 printf(
"Couldn't bind to cpuset %s\n", str);
111 rank = obj->children[0]->os_index;
114 #if !defined(HWLOC_BITMAP_H)
115 hwloc_cpuset_free(cpuset);
117 hwloc_bitmap_free(cpuset);
128 hwloc_cpuset_t cpuset;
130 if (!topo_initialized) {
131 plasma_error(
"plasma_unsetaffinity",
"Topology not initialized");
136 obj = hwloc_get_obj_by_type(plasma_topology, HWLOC_OBJ_MACHINE, 0);
144 #if !defined(HWLOC_BITMAP_H)
145 cpuset = hwloc_cpuset_dup(obj->cpuset);
147 cpuset = hwloc_bitmap_dup(obj->cpuset);
151 if (hwloc_set_cpubind(plasma_topology, cpuset, HWLOC_CPUBIND_THREAD)) {
153 #if !defined(HWLOC_BITMAP_H)
154 hwloc_cpuset_asprintf(&str, obj->cpuset);
156 hwloc_bitmap_asprintf(&str, obj->cpuset);
158 plasma_warning(
"plasma_unsetaffinity",
"Could not bind to the whole machine");
159 printf(
"Couldn't bind to cpuset %s\n", str);
165 #if !defined(HWLOC_BITMAP_H)
166 hwloc_cpuset_free(cpuset);
168 hwloc_bitmap_free(cpuset);
173 int plasma_getnuma_size() {
174 hwloc_cpuset_t cpuset;
178 obj = hwloc_get_obj_by_type(plasma_topology, HWLOC_OBJ_NODE, 0);
182 #if !defined(HWLOC_BITMAP_H)
183 cpuset = hwloc_cpuset_dup(obj->cpuset);
185 cpuset = hwloc_bitmap_dup(obj->cpuset);
187 thrdnbr = hwloc_get_nbobjs_inside_cpuset_by_type(plasma_topology, cpuset, HWLOC_OBJ_CORE);
190 #if !defined(HWLOC_BITMAP_H)
191 hwloc_cpuset_free(cpuset);
193 hwloc_bitmap_free(cpuset);