Skip to content

Commit 15634d0

Browse files
committed
Fix maxnode calculation in numa memory target
It should be set to the highest possible id of a node (highest bit set in the map) + 1, and not to number of nodes.
1 parent 1b3c593 commit 15634d0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/memory_targets/memory_target_numa.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ numa_targets_create_nodemask(struct numa_memory_target_t **targets,
7777
}
7878
}
7979

80+
int lastBit = hwloc_bitmap_last(bitmap);
81+
if (lastBit == -1) {
82+
// no node is set
83+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
84+
}
85+
86+
*maxnode = lastBit + 1;
87+
8088
int nrUlongs = hwloc_bitmap_nr_ulongs(bitmap);
8189
if (nrUlongs == -1) {
8290
hwloc_bitmap_free(bitmap);
@@ -93,7 +101,6 @@ numa_targets_create_nodemask(struct numa_memory_target_t **targets,
93101
}
94102

95103
*mask = nodemask;
96-
*maxnode = nrUlongs * sizeof(unsigned long) * 8;
97104

98105
return UMF_RESULT_SUCCESS;
99106
}

0 commit comments

Comments
 (0)