Skip to content

Commit c3061d1

Browse files
committed
memattrs: only build memory tiers and set subtypes when not loading from XML
XML already has its own subtype and tiers. If importing from <2.8 (no subtypes) or <2.10 (no tiers), one may set HWLOC_MEMTIERS_REFRESH=1 to force refresh them. May also be used if the backend set wrong subtypes for some reason. Signed-off-by: Brice Goglin <[email protected]>
1 parent a942a56 commit c3061d1

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

doc/hwloc.doxy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,12 @@ following environment variables.
11361136
If an empty value or <tt>none</tt> is given, tiers are entirely disabled.
11371137
</dd>
11381138

1139+
<dt>HWLOC_MEMTIERS_REFRESH=1</dt>
1140+
<dd>Force the rebuilding of memory tiers.
1141+
This is mostly useful when importing a XML topology from an old hwloc
1142+
version which was not able to guess memory subtypes and tiers.
1143+
</dd>
1144+
11391145
<dt>HWLOC_GROUPING=1</dt>
11401146
<dd>enables or disables objects grouping based on distances.
11411147
By default, hwloc uses distance matrices between objects (either read

hwloc/memattrs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ hwloc__group_memory_tiers(hwloc_topology_t topology,
14251425
/* Sort nodes.
14261426
* We could also sort by the existing subtype.
14271427
* KNL is the only case where subtypes are set in backends, but we set memattrs as well there.
1428+
* Also HWLOC_MEMTIERS_REFRESH would be a special value to ignore existing subtypes.
14281429
*/
14291430
hwloc_debug("Sorting memory node infos...\n");
14301431
qsort(nodeinfos, n, sizeof(*nodeinfos), compare_node_infos_by_type_and_bw);
@@ -1809,12 +1810,11 @@ hwloc__apply_memory_tiers_subtypes(hwloc_topology_t topology,
18091810
}
18101811

18111812
int
1812-
hwloc_internal_memattrs_guess_memory_tiers(hwloc_topology_t topology)
1813+
hwloc_internal_memattrs_guess_memory_tiers(hwloc_topology_t topology, int force_subtype)
18131814
{
18141815
struct hwloc_memory_tier_s *tiers;
18151816
unsigned nr_tiers;
18161817
unsigned i;
1817-
int force_subtype = 0;
18181818
const char *env;
18191819

18201820
env = getenv("HWLOC_MEMTIERS");

hwloc/topology.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4299,10 +4299,13 @@ hwloc_topology_load (struct hwloc_topology *topology)
42994299
}
43004300

43014301
if (!(topology->flags & HWLOC_TOPOLOGY_FLAG_NO_MEMATTRS)) {
4302+
int force_memtiers = (getenv("HWLOC_MEMTIERS_REFRESH") != NULL);
43024303
/* Same for memattrs */
43034304
hwloc_internal_memattrs_need_refresh(topology);
43044305
hwloc_internal_memattrs_refresh(topology);
4305-
hwloc_internal_memattrs_guess_memory_tiers(topology);
4306+
/* update memtiers unless XML */
4307+
if (force_memtiers || strcmp(topology->backends->component->name, "xml"))
4308+
hwloc_internal_memattrs_guess_memory_tiers(topology, force_memtiers);
43064309
}
43074310

43084311
topology->state &= ~HWLOC_TOPOLOGY_STATE_IS_LOADING;

include/private/private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ extern void hwloc_internal_memattrs_need_refresh(hwloc_topology_t topology);
431431
extern void hwloc_internal_memattrs_refresh(hwloc_topology_t topology);
432432
extern int hwloc_internal_memattrs_dup(hwloc_topology_t new, hwloc_topology_t old);
433433
extern int hwloc_internal_memattr_set_value(hwloc_topology_t topology, hwloc_memattr_id_t id, hwloc_obj_type_t target_type, hwloc_uint64_t target_gp_index, unsigned target_os_index, struct hwloc_internal_location_s *initiator, hwloc_uint64_t value);
434-
extern int hwloc_internal_memattrs_guess_memory_tiers(hwloc_topology_t topology);
434+
extern int hwloc_internal_memattrs_guess_memory_tiers(hwloc_topology_t topology, int force_subtype);
435435

436436
extern void hwloc_internal_cpukinds_init(hwloc_topology_t topology);
437437
extern int hwloc_internal_cpukinds_rank(hwloc_topology_t topology);

tests/hwloc/memtiers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ main(void)
137137

138138
hwloc_topology_export_xmlbuffer(topology, &xmlbuffer, &buflen, 0);
139139

140+
putenv((char*)"HWLOC_MEMTIERS_REFRESH=1");
141+
140142
printf("checking NVM and SPM subtypes are set on XML reload\n");
141143
printf("UNKNOWN should be before SPM and NVM in tiers since we have no BW\n");
142144
err = hwloc_topology_init(&new);

0 commit comments

Comments
 (0)