Skip to content

Commit 0466319

Browse files
igchorldorau
authored andcommitted
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 8064716 commit 0466319

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
@@ -61,6 +61,14 @@ numa_targets_create_nodemask(struct numa_memory_target_t **targets,
6161
}
6262
}
6363

64+
int lastBit = hwloc_bitmap_last(bitmap);
65+
if (lastBit == -1) {
66+
// no node is set
67+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
68+
}
69+
70+
*maxnode = lastBit + 1;
71+
6472
int nrUlongs = hwloc_bitmap_nr_ulongs(bitmap);
6573
if (nrUlongs == -1) {
6674
hwloc_bitmap_free(bitmap);
@@ -77,7 +85,6 @@ numa_targets_create_nodemask(struct numa_memory_target_t **targets,
7785
}
7886

7987
*mask = nodemask;
80-
*maxnode = nrUlongs * sizeof(unsigned long) * 8;
8188

8289
return UMF_RESULT_SUCCESS;
8390
}

0 commit comments

Comments
 (0)