Skip to content

Commit 75234cb

Browse files
committed
utils/calc: fix searching NUMA nodes inside CPU objects when NUMA are attached higher
This is the symmetric of the previous commit, but reversing NUMAs and PUs. When a NUMA node is attached at a level, and we search for that NUMA node inside children of that level (hierarchical spec), the cpuset of the NUMA node contains more than just one children, hence we wouldn't find it with isincluded(). We now use zero()||intersects() instead. Example (different from the one added in test-hwloc-calc): AMD machine with 4 L3 (4 cores each) and 1 NUMA per package (16 cores total). "hwloc-calc l3:0.numa:0" should return the first NUMA (cpuset 0xffff nodeset 0x1) but it didn't because it's not included in the L3 (cpuset 0x000f nodeset 0x1). This should not happen when the user knows the ordering of levels in the machine, but may happen when using generic scripts that don't know where NUMA is attached (L3 above NUMA on some Intel/SNC but below on AMD currently). Signed-off-by: Brice Goglin <[email protected]>
1 parent f0eeb3a commit 75234cb

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

utils/hwloc/hwloc-calc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ hwloc_calc_get_nbobjs_inside_sets_by_depth(struct hwloc_calc_location_context_s
8686
hwloc_obj_t obj = NULL;
8787
unsigned n = 0;
8888
while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
89-
if (!hwloc_bitmap_isincluded(obj->cpuset, cpuset))
89+
if (!hwloc_bitmap_iszero(obj->cpuset) && !hwloc_bitmap_intersects(obj->cpuset, cpuset))
9090
continue;
9191
if (!hwloc_bitmap_iszero(obj->nodeset) && !hwloc_bitmap_intersects(obj->nodeset, nodeset))
9292
continue;
@@ -115,7 +115,7 @@ hwloc_calc_get_obj_inside_sets_by_depth(struct hwloc_calc_location_context_s *lc
115115
hwloc_obj_t obj = NULL;
116116
unsigned i = 0;
117117
while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
118-
if (!hwloc_bitmap_isincluded(obj->cpuset, cpuset))
118+
if (!hwloc_bitmap_iszero(obj->cpuset) && !hwloc_bitmap_intersects(obj->cpuset, cpuset))
119119
continue;
120120
if (!hwloc_bitmap_iszero(obj->nodeset) && !hwloc_bitmap_intersects(obj->nodeset, nodeset))
121121
continue;

utils/hwloc/test-hwloc-calc.output

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ PU:22_PU:23_Core:6_Core:7_Group0:2
133133
# Search cores within single NUMA when they have multiple local NUMA nodes
134134
0x00000060
135135

136+
# Search NUMA node within single Group when they have multiple local Groups
137+
0x00000002
138+
136139
# Physical output of NUMA Nodes when out-of-order in the topology
137140
2,1
138141

utils/hwloc/test-hwloc-calc.sh.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ set -e
184184
echo "# Search cores within single NUMA when they have multiple local NUMA nodes"
185185
$calc --if synthetic --input "pack:2 [numa] [numa] core:4 pu:1" sock:1.numa:1.core:1-2
186186
echo
187+
echo "# Search NUMA node within single Group when they have multiple local Groups"
188+
$calc --if synthetic --input "pack:2 [numa] group:2 core:4 1" --nodeset-output pack:1.group:1.numa:0
189+
echo
187190

188191
echo "# Physical output of NUMA Nodes when out-of-order in the topology"
189192
$calc --if synthetic --input "node:4(indexes=3,2,1,0) pu:2" node:1-2 --po -I node

0 commit comments

Comments
 (0)