Skip to content

Commit 3b76c84

Browse files
igchorldorau
authored andcommitted
Workaround a bug in hwloc_bitmap_nr_ulongs in older hwloc versions
1 parent 011f86e commit 3b76c84

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/memory_targets/memory_target_numa.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ numa_targets_create_nodemask(struct numa_memory_target_t **targets,
6969

7070
*maxnode = lastBit + 1;
7171

72-
int nrUlongs = hwloc_bitmap_nr_ulongs(bitmap);
73-
if (nrUlongs == -1) {
74-
hwloc_bitmap_free(bitmap);
75-
return UMF_RESULT_ERROR_UNKNOWN;
76-
}
72+
// Do not use hwloc_bitmap_nr_ulongs due to:
73+
// https://github.com/open-mpi/hwloc/issues/429
74+
unsigned bits_per_long = sizeof(unsigned long) * 8;
75+
int nrUlongs = (lastBit + bits_per_long) / bits_per_long;
7776

7877
unsigned long *nodemask = malloc(sizeof(unsigned long) * nrUlongs);
7978
int ret = hwloc_bitmap_to_ulongs(bitmap, nrUlongs, nodemask);

0 commit comments

Comments
 (0)