Skip to content

Commit e98c642

Browse files
committed
Add missing checks and comments for umf_numa_mode_t
To be consistent with linux mbind behavior. On windows, UMF_NUMA_MODE_BIND and UMF_NUMA_MODE_INTERLEAVE will not be supported for now (the only mode we can support is UMF_NUMA_MODE_PREFERRED).
1 parent 5a9b468 commit e98c642

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

include/umf/providers/provider_os_memory.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ typedef enum umf_numa_mode_t {
4242
/// On linux this corresponds to MPOL_DEFAULT. If this mode is specified,
4343
/// nodemask must be NULL and maxnode must be 0.
4444
UMF_NUMA_MODE_BIND, ///< Restricts memory allocation to nodes specified in nodemask. Allocations
45-
/// might come from any of the allowed nodes.
45+
/// might come from any of the allowed nodes. Nodemask must specify at least one node.
4646
UMF_NUMA_MODE_INTERLEAVE, ///< Interleaves memory allocations across the set of nodes specified in nodemask.
47+
/// Nodemask must specify at least one node.
4748
UMF_NUMA_MODE_PREFERRED, ///< Specifies preferred node for allocation. If allocation cannot be fulfilled,
4849
/// memory will be allocated from other nodes.
4950
UMF_NUMA_MODE_LOCAL, ///< The memory is allocated on the node of the CPU that triggered the allocation.

src/provider/provider_os_memory.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,16 @@ static hwloc_membind_policy_t translate_numa_mode(umf_numa_mode_t mode,
146146
}
147147
return HWLOC_MEMBIND_DEFAULT;
148148
case UMF_NUMA_MODE_BIND:
149+
if (nodemaskEmpty) {
150+
// nodeset must not be empty
151+
return -1;
152+
}
149153
return HWLOC_MEMBIND_BIND;
150154
case UMF_NUMA_MODE_INTERLEAVE:
155+
if (nodemaskEmpty) {
156+
// nodeset must not be empty
157+
return -1;
158+
}
151159
return HWLOC_MEMBIND_INTERLEAVE;
152160
case UMF_NUMA_MODE_PREFERRED:
153161
return HWLOC_MEMBIND_BIND;

0 commit comments

Comments
 (0)