Skip to content

Commit 1b089e9

Browse files
committed
utils: filter based on memory tiers using numa[tier=1]
Signed-off-by: Brice Goglin <[email protected]>
1 parent f15fea1 commit 1b089e9

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

utils/hwloc/hwloc-calc.1in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ To find the number of NUMA nodes with subtype "HBM":
404404
$ hwloc-calc -N "numa[hbm]" all
405405
4
406406

407+
To find the number of NUMA nodes in memory tier 1
408+
(DRAM nodes on a server with HBM and DRAM):
409+
410+
$ hwloc-calc -N "numa[tier=1]" all
411+
4
412+
407413
To find the NUMA node of subtype MCDRAM (on KNL) near a PU:
408414

409415
$ hwloc-calc -I "numa[mcdram]" pu:157

utils/hwloc/hwloc-calc.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct hwloc_calc_level {
3838
hwloc_obj_type_t type;
3939
union hwloc_obj_attr_u attr;
4040
char subtype[32];
41+
int memory_tier;
4142
int pci_vendor, pci_device;
4243
int only_hbm; /* -1 for everything, 0 for only non-HBM, 1 for only HBM numa nodes */
4344
};
@@ -99,6 +100,12 @@ hwloc_calc_check_object_filtered(hwloc_obj_t obj, struct hwloc_calc_level *level
99100
}
100101

101102
if (level->type == HWLOC_OBJ_NUMANODE) {
103+
if (level->memory_tier >= 0) {
104+
const char *tier = hwloc_obj_get_info_by_name(obj, "MemoryTier");
105+
if (!tier || atoi(tier) != level->memory_tier)
106+
return 1;
107+
}
108+
102109
if (level->only_hbm >= 0) {
103110
/* filter on hbm */
104111
int obj_is_hbm = obj->subtype && !strcmp(obj->subtype, "MCDRAM");
@@ -206,6 +213,11 @@ hwloc_calc_parse_level_filter(hwloc_topology_t topology __hwloc_attribute_unused
206213
const char *end;
207214
unsigned subtypelen;
208215

216+
if (!strncmp(current, "tier=", 5)) {
217+
level->memory_tier = atoi(current+5);
218+
return 0;
219+
}
220+
209221
if (!strncmp(current, "subtype=", 8)) {
210222
current += 8;
211223
goto subtype;
@@ -254,6 +266,7 @@ hwloc_calc_parse_level(struct hwloc_calc_location_context_s *lcontext,
254266
int err;
255267

256268
level->subtype[0] = '\0';
269+
level->memory_tier = -1;
257270
level->pci_device = level->pci_vendor = -1;
258271
level->only_hbm = -1;
259272
if (lcontext)

utils/hwloc/hwloc-info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ hwloc_calc_process_location_info_cb(struct hwloc_calc_location_context_s *lconte
536536
level.depth = show_descendants_depth;
537537
level.only_hbm = -1;
538538
level.subtype[0] = '\0';
539+
level.memory_tier = -1;
539540
level.pci_vendor = level.pci_device = -1;
540541
n = hwloc_calc_get_nbobjs_inside_sets_by_depth(lcontext, obj->cpuset, obj->nodeset, &level);
541542
for(i=0; i<n; i++) {

utils/hwloc/hwloc.7in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ objects are wanted.
9595
type and also its subtype string attribute.
9696
For instance \fINUMA[HBM]\fR selects NUMA nodes of subtype "HBM".
9797
The prefix \fIsubtype=\fR may be avoided if there is no ambiguity.
98+
\fINUMA[tier=X]\fR select NUMA nodes of tier <X> ("MemoryTier" info attribute).
9899
\fIOS[Net]\fR also selects OS devices whose OS-device-specific type is Network.
99100
.br
100101

utils/hwloc/test-hwloc-info.output

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ NUMANode:11
508508
NUMANode:3
509509
NUMANode:5
510510

511+
# Memory Tier 1 filter
512+
NUMANode:6
513+
511514
# NVML subtype OSdev type filter
512515
OSDev[Co-Processor,GPU]:2
513516
OSDev[Co-Processor,GPU]:5

utils/hwloc/test-hwloc-info.sh.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ set -e
124124
echo "# MCDRAM subtype NUMA filter"
125125
$info --if xml --input $xmldir/64intel64-fakeKNL-SNC4-hybrid.xml -s 'numa[mcdram]:1-2'
126126
echo
127+
echo "# Memory Tier 1 filter"
128+
$info --if xml --input $xmldir/64intel64-fakeKNL-SNC4-hybrid.xml -s 'numa[tier=1]:3'
129+
echo
127130
echo "# NVML subtype OSdev type filter"
128131
$info --if xml --input $xmldir/power8gpudistances.xml -s 'os[nvml]:all'
129132
echo

0 commit comments

Comments
 (0)