Skip to content

Commit d535c65

Browse files
committed
memattrs: add "node0_is_dram" option to HWLOC_MEMTIERS_GUESS envvar
NUMA node P#0 is usually DRAM (except of HBM-only CPUs). Signed-off-by: Brice Goglin <[email protected]>
1 parent bc89428 commit d535c65

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

doc/hwloc.doxy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,9 @@ following environment variables.
11231123
By default, hwloc only uses heuristics that are likely correct
11241124
and disables those that are unlikely.
11251125
</dd>
1126-
<!-- not stable yet, hence not documented
1127-
HWLOC_MEMTIERS_GUESS=spm_is_hbm
1128-
assume all SPM nodes are HBM
1126+
<!-- since 2.10, not stable yet, hence not documented
1127+
HWLOC_MEMTIERS_GUESS=spm_is_hbm,node0_is_dram
1128+
assume all SPM nodes are HBM, assume node0 is in the DRAM tier
11291129
-->
11301130

11311131
<dt>HWLOC_GROUPING=1</dt>

hwloc/memattrs.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,13 +1465,14 @@ hwloc__group_memory_tiers(hwloc_topology_t topology,
14651465
}
14661466

14671467
enum hwloc_guess_memtiers_flag {
1468-
HWLOC_GUESS_MEMTIERS_FLAG_SPM_IS_HBM = 1<<0
1468+
HWLOC_GUESS_MEMTIERS_FLAG_NODE0_IS_DRAM = 1<<0,
1469+
HWLOC_GUESS_MEMTIERS_FLAG_SPM_IS_HBM = 1<<1
14691470
};
14701471

14711472
static int
14721473
hwloc__guess_dram_hbm_tiers(struct hwloc_memory_tier_s *tier1,
14731474
struct hwloc_memory_tier_s *tier2,
1474-
unsigned long flags __hwloc_attribute_unused)
1475+
unsigned long flags)
14751476
{
14761477
struct hwloc_memory_tier_s *tmp;
14771478

@@ -1498,6 +1499,13 @@ hwloc__guess_dram_hbm_tiers(struct hwloc_memory_tier_s *tier1,
14981499
}
14991500
/* tier2 BW is >2x tier1 */
15001501

1502+
if ((flags & HWLOC_GUESS_MEMTIERS_FLAG_NODE0_IS_DRAM)
1503+
&& hwloc_bitmap_isset(tier2->nodeset, 0)) {
1504+
/* node0 is not DRAM, and we assume that's not possible */
1505+
hwloc_debug(" node0 shouldn't have HBM BW\n");
1506+
return -1;
1507+
}
1508+
15011509
/* assume tier1 == DRAM and tier2 == HBM */
15021510
tier1->type = HWLOC_MEMORY_TIER_DRAM;
15031511
tier2->type = HWLOC_MEMORY_TIER_HBM;
@@ -1529,6 +1537,10 @@ hwloc__guess_memory_tiers_types(hwloc_topology_t topology __hwloc_attribute_unus
15291537
hwloc_debug("Assuming SPM-tier is HBM, ignore bandwidth\n");
15301538
flags |= HWLOC_GUESS_MEMTIERS_FLAG_SPM_IS_HBM;
15311539
}
1540+
if (strstr(env, "node0_is_dram")) {
1541+
hwloc_debug("Assuming node0 is DRAM\n");
1542+
flags |= HWLOC_GUESS_MEMTIERS_FLAG_NODE0_IS_DRAM;
1543+
}
15321544
}
15331545

15341546
if (nr_tiers == 1)
@@ -1586,6 +1598,17 @@ hwloc__guess_memory_tiers_types(hwloc_topology_t topology __hwloc_attribute_unus
15861598
}
15871599
}
15881600

1601+
if (flags & HWLOC_GUESS_MEMTIERS_FLAG_NODE0_IS_DRAM) {
1602+
/* force mark node0's tier as DRAM if we couldn't guess it */
1603+
for(i=0; i<nr_tiers; i++)
1604+
if (hwloc_bitmap_isset(tiers[i].nodeset, 0)
1605+
&& tiers[i].type == HWLOC_MEMORY_TIER_UNKNOWN) {
1606+
hwloc_debug("Forcing node0 tier to DRAM");
1607+
tiers[i].type = HWLOC_MEMORY_TIER_DRAM;
1608+
break;
1609+
}
1610+
}
1611+
15891612
return 0;
15901613
}
15911614

tests/hwloc/memtiers.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ main(void)
129129
check_subtypes(new, "NVM", NULL, "HBM", NULL, "HBM");
130130
hwloc_topology_destroy(new);
131131

132+
printf("checking HBM subtypes are set on XML reload if HWLOC_MEMTIERS_GUESS=node0_is_dram,spm_is_hbm\n");
133+
putenv((char*)"HWLOC_MEMTIERS_GUESS=node0_is_dram,spm_is_hbm");
134+
err = hwloc_topology_init(&new);
135+
assert(!err);
136+
err = hwloc_topology_set_xmlbuffer(new, xmlbuffer, buflen);
137+
assert(!err);
138+
err = hwloc_topology_load(new);
139+
assert(!err);
140+
check_subtypes(new, "NVM", "DRAM", "HBM", "DRAM", "HBM");
141+
hwloc_topology_destroy(new);
142+
132143
free(xmlbuffer);
133144

134145
printf("adding correct BW values\n");

0 commit comments

Comments
 (0)