Skip to content

Commit c8b380d

Browse files
committed
memattrs: add INTERSECT flag for getting local NUMA nodes
If the input locality is a single core of multiple packages, no NUMA is smaller or larger, but they intersect. Refs open-mpi#716 Note that intersect imply smaller and larger too. Signed-off-by: Brice Goglin <[email protected]>
1 parent c1d80cc commit c8b380d

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

hwloc/memattrs.c

+3
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,8 @@ match_local_obj_cpuset(hwloc_obj_t node, hwloc_cpuset_t cpuset, unsigned long fl
11591159
{
11601160
if (flags & HWLOC_LOCAL_NUMANODE_FLAG_ALL)
11611161
return 1;
1162+
if (flags & HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY)
1163+
return hwloc_bitmap_intersects(node->cpuset, cpuset);
11621164
if ((flags & HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY)
11631165
&& hwloc_bitmap_isincluded(cpuset, node->cpuset))
11641166
return 1;
@@ -1181,6 +1183,7 @@ hwloc_get_local_numanode_objs(hwloc_topology_t topology,
11811183

11821184
if (flags & ~(HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY
11831185
|HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY
1186+
|HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY
11841187
| HWLOC_LOCAL_NUMANODE_FLAG_ALL)) {
11851188
errno = EINVAL;
11861189
return -1;

include/hwloc/memattrs.h

+10
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ enum hwloc_local_numanode_flag_e {
250250
*/
251251
HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY = (1UL<<1),
252252

253+
/** \breif Select NUMA nodes whose locality intersects the given cpuset.
254+
* This includes larger and smaller localities as well as localities
255+
* that are partially included.
256+
* For instance, if the locality is one core of both packages, a NUMA node
257+
* local to one package is neither larger nor smaller than this locality,
258+
* but it intersects it.
259+
* \hideinitializer
260+
*/
261+
HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY = (1UL<<3),
262+
253263
/** \brief Select all NUMA nodes in the topology.
254264
* The initiator \p initiator is ignored.
255265
* \hideinitializer

include/hwloc/rename.h

+1
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ extern "C" {
425425
#define hwloc_local_numanode_flag_e HWLOC_NAME(local_numanode_flag_e)
426426
#define HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_LARGER_LOCALITY)
427427
#define HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY)
428+
#define HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY)
428429
#define HWLOC_LOCAL_NUMANODE_FLAG_ALL HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_ALL)
429430
#define hwloc_get_local_numanode_objs HWLOC_NAME(get_local_numanode_objs)
430431
#define hwloc_topology_get_default_nodeset HWLOC_NAME(topology_get_default_nodeset)

utils/hwloc/misc.h

+1
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,7 @@ hwloc_utils_parse_local_numanode_flags(char *str) {
11691169
struct hwloc_utils_parsing_flag possible_flags[] = {
11701170
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY),
11711171
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY),
1172+
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY),
11721173
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_ALL)
11731174
};
11741175

0 commit comments

Comments
 (0)