|
1 | 1 | /*
|
2 | 2 | * Copyright © 2009 CNRS
|
3 |
| - * Copyright © 2009-2016 Inria. All rights reserved. |
| 3 | + * Copyright © 2009-2017 Inria. All rights reserved. |
4 | 4 | * Copyright © 2009-2012 Université Bordeaux
|
5 | 5 | * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
|
6 | 6 | * See COPYING in top-level directory.
|
@@ -69,20 +69,47 @@ hwloc_calc_append_set(hwloc_bitmap_t set, hwloc_const_bitmap_t newset,
|
69 | 69 | return 0;
|
70 | 70 | }
|
71 | 71 |
|
72 |
| -static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure |
73 |
| -hwloc_calc_get_obj_inside_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_bitmap_t rootset, |
74 |
| - unsigned depth, unsigned i, int logical) |
| 72 | +static __hwloc_inline unsigned |
| 73 | +hwloc_calc_get_nbobjs_inside_sets_by_depth(hwloc_topology_t topology, |
| 74 | + hwloc_const_bitmap_t cpuset, hwloc_const_bitmap_t nodeset, |
| 75 | + unsigned depth) |
75 | 76 | {
|
76 |
| - if (logical) { |
77 |
| - return hwloc_get_obj_inside_cpuset_by_depth(topology, rootset, depth, i); |
78 |
| - } else { |
79 |
| - hwloc_obj_t obj = NULL; |
80 |
| - while ((obj = hwloc_get_next_obj_inside_cpuset_by_depth(topology, rootset, depth, obj)) != NULL) { |
| 77 | + hwloc_obj_t obj = NULL; |
| 78 | + unsigned n = 0; |
| 79 | + while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) { |
| 80 | + if (!hwloc_bitmap_isincluded(obj->cpuset, cpuset)) |
| 81 | + continue; |
| 82 | + if (!hwloc_bitmap_isincluded(obj->nodeset, nodeset)) |
| 83 | + continue; |
| 84 | + assert(!hwloc_bitmap_iszero(obj->cpuset) || !hwloc_bitmap_iszero(obj->nodeset)); |
| 85 | + n++; |
| 86 | + } |
| 87 | + return n; |
| 88 | +} |
| 89 | + |
| 90 | +static __hwloc_inline hwloc_obj_t |
| 91 | +hwloc_calc_get_obj_inside_sets_by_depth(hwloc_topology_t topology, |
| 92 | + hwloc_const_bitmap_t cpuset, hwloc_const_bitmap_t nodeset, |
| 93 | + unsigned depth, unsigned ind, int logical) |
| 94 | +{ |
| 95 | + hwloc_obj_t obj = NULL; |
| 96 | + unsigned i = 0; |
| 97 | + while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) { |
| 98 | + if (!hwloc_bitmap_isincluded(obj->cpuset, cpuset)) |
| 99 | + continue; |
| 100 | + if (!hwloc_bitmap_isincluded(obj->nodeset, nodeset)) |
| 101 | + continue; |
| 102 | + assert(!hwloc_bitmap_iszero(obj->cpuset) || !hwloc_bitmap_iszero(obj->nodeset)); |
| 103 | + if (logical) { |
| 104 | + if (i == ind) |
| 105 | + return obj; |
| 106 | + i++; |
| 107 | + } else { |
81 | 108 | if (obj->os_index == i)
|
82 |
| - return obj; |
| 109 | + return obj; |
83 | 110 | }
|
84 |
| - return NULL; |
85 | 111 | }
|
| 112 | + return NULL; |
86 | 113 | }
|
87 | 114 |
|
88 | 115 | static __hwloc_inline int
|
@@ -221,7 +248,7 @@ hwloc_calc_parse_range(const char *_string,
|
221 | 248 |
|
222 | 249 | static __hwloc_inline int
|
223 | 250 | hwloc_calc_append_object_range(hwloc_topology_t topology, unsigned topodepth,
|
224 |
| - hwloc_const_bitmap_t rootset, int depth, |
| 251 | + hwloc_const_bitmap_t rootcpuset, hwloc_const_bitmap_t rootnodeset, int depth, |
225 | 252 | const char *string, /* starts with indexes following the colon */
|
226 | 253 | int logical,
|
227 | 254 | void (*cbfunc)(void *, hwloc_obj_t, int), void *cbdata,
|
@@ -265,29 +292,31 @@ hwloc_calc_append_object_range(hwloc_topology_t topology, unsigned topodepth,
|
265 | 292 | }
|
266 | 293 | }
|
267 | 294 |
|
268 |
| - width = hwloc_get_nbobjs_inside_cpuset_by_depth(topology, rootset, depth); |
| 295 | + width = hwloc_calc_get_nbobjs_inside_sets_by_depth(topology, rootcpuset, rootnodeset, depth); |
269 | 296 | if (amount == -1)
|
270 | 297 | amount = (width-first+step-1)/step;
|
271 | 298 |
|
272 | 299 | for(i=first, j=0; j<(unsigned)amount; i+=step, j++) {
|
273 | 300 | if (wrap && i>=width)
|
274 | 301 | i = 0;
|
275 | 302 |
|
276 |
| - obj = hwloc_calc_get_obj_inside_cpuset_by_depth(topology, rootset, depth, i, logical); |
| 303 | + obj = hwloc_calc_get_obj_inside_sets_by_depth(topology, rootcpuset, rootnodeset, depth, i, logical); |
277 | 304 | if (verbose > 0 || (!obj && verbose >= 0)) {
|
278 |
| - char *s; |
279 |
| - hwloc_bitmap_asprintf(&s, rootset); |
| 305 | + char *sc, *sn; |
| 306 | + hwloc_bitmap_asprintf(&sc, rootcpuset); |
| 307 | + hwloc_bitmap_asprintf(&sn, rootnodeset); |
280 | 308 | if (obj)
|
281 |
| - printf("using object #%u depth %u below cpuset %s\n", |
282 |
| - i, depth, s); |
| 309 | + printf("using object #%u depth %u below cpuset %s nodeset %s\n", |
| 310 | + i, depth, sc, sn); |
283 | 311 | else
|
284 |
| - fprintf(stderr, "object #%u depth %u below cpuset %s does not exist\n", |
285 |
| - i, depth, s); |
286 |
| - free(s); |
| 312 | + fprintf(stderr, "object #%u depth %u below cpuset %s nodeset %s does not exist\n", |
| 313 | + i, depth, sc, sn); |
| 314 | + free(sc); |
| 315 | + free(sn); |
287 | 316 | }
|
288 | 317 | if (obj) {
|
289 | 318 | if (dot) {
|
290 |
| - hwloc_calc_append_object_range(topology, topodepth, obj->cpuset, nextdepth, nextsep+1, logical, cbfunc, cbdata, verbose); |
| 319 | + hwloc_calc_append_object_range(topology, topodepth, obj->cpuset, obj->nodeset, nextdepth, nextsep+1, logical, cbfunc, cbdata, verbose); |
291 | 320 | } else {
|
292 | 321 | /* add to the temporary cpuset
|
293 | 322 | * and let the caller add/clear/and/xor for the actual final cpuset depending on cmdline options
|
@@ -483,7 +512,10 @@ hwloc_calc_process_type_arg(hwloc_topology_t topology, unsigned topodepth,
|
483 | 512 | }
|
484 | 513 |
|
485 | 514 | /* look at indexes following this type/depth */
|
486 |
| - return hwloc_calc_append_object_range(topology, topodepth, hwloc_topology_get_complete_cpuset(topology), depth, sep+1, logical, cbfunc, cbdata, verbose); |
| 515 | + return hwloc_calc_append_object_range(topology, topodepth, |
| 516 | + hwloc_topology_get_complete_cpuset(topology), |
| 517 | + hwloc_topology_get_complete_nodeset(topology), |
| 518 | + depth, sep+1, logical, cbfunc, cbdata, verbose); |
487 | 519 | }
|
488 | 520 |
|
489 | 521 | struct hwloc_calc_process_arg_cpuset_cbdata_s {
|
|
0 commit comments