Skip to content

Commit 5a2f14b

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 #716 Note that intersect imply smaller and larger too. Signed-off-by: Brice Goglin <[email protected]> (cherry picked from commit c8b380d)
1 parent 06a5419 commit 5a2f14b

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
@@ -1158,6 +1158,8 @@ match_local_obj_cpuset(hwloc_obj_t node, hwloc_cpuset_t cpuset, unsigned long fl
11581158
{
11591159
if (flags & HWLOC_LOCAL_NUMANODE_FLAG_ALL)
11601160
return 1;
1161+
if (flags & HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY)
1162+
return hwloc_bitmap_intersects(node->cpuset, cpuset);
11611163
if ((flags & HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY)
11621164
&& hwloc_bitmap_isincluded(cpuset, node->cpuset))
11631165
return 1;
@@ -1180,6 +1182,7 @@ hwloc_get_local_numanode_objs(hwloc_topology_t topology,
11801182

11811183
if (flags & ~(HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY
11821184
|HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY
1185+
|HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY
11831186
| HWLOC_LOCAL_NUMANODE_FLAG_ALL)) {
11841187
errno = EINVAL;
11851188
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
@@ -409,6 +409,7 @@ extern "C" {
409409
#define hwloc_local_numanode_flag_e HWLOC_NAME(local_numanode_flag_e)
410410
#define HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_LARGER_LOCALITY)
411411
#define HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY)
412+
#define HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY)
412413
#define HWLOC_LOCAL_NUMANODE_FLAG_ALL HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_ALL)
413414
#define hwloc_get_local_numanode_objs HWLOC_NAME(get_local_numanode_objs)
414415
#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
@@ -1202,6 +1202,7 @@ hwloc_utils_parse_local_numanode_flags(char *str) {
12021202
struct hwloc_utils_parsing_flag possible_flags[] = {
12031203
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY),
12041204
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY),
1205+
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY),
12051206
HWLOC_UTILS_PARSING_FLAG(HWLOC_LOCAL_NUMANODE_FLAG_ALL)
12061207
};
12071208

0 commit comments

Comments
 (0)