Skip to content

Commit a60ef29

Browse files
bgoglinndenoyelle
authored andcommitted
components: add envvar to annotate global components
If the envvar HWLOC_ANNOTATE_GLOBAL_COMPONENTS=1, global components don't exclude the ANNOTATE phase anymore. Hence, the pci component may add PCI vendor/device strings to objects if the XML generation was performed without pciaccess. Note that it doesn't check whether those names are already available, so they may be duplicated if enabled blindly. Signed-off-by: Brice Goglin <[email protected]>
1 parent 945c832 commit a60ef29

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

doc/hwloc.doxy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,14 @@ following environment variables.
10911091
Setting this environment variable to 1 will expose it as a proper Memory-side cache.
10921092
</dd>
10931093

1094+
<dt>HWLOC_ANNOTATE_GLOBAL_COMPONENTS=0</dt>
1095+
<dd>Allow components to annotate the topology even if they are
1096+
usually excluded by global components by default.
1097+
Setting this variable to 1 and also setting <tt>HWLOC_COMPONENTS=xml,pci,stop</tt>
1098+
enables the addition of PCI vendor and model info attributes to a XML topology
1099+
that was generated without those names (if pciaccess was missing).
1100+
</dd>
1101+
10941102
<dt>HWLOC_FSROOT=/path/to/linux/filesystem-root/</dt>
10951103
<dd>switches to reading the topology from the specified
10961104
Linux filesystem root instead of the main file-system root.

hwloc/components.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,19 @@ hwloc_disc_component_force_enable(struct hwloc_topology *topology,
574574
backend = comp->instantiate(topology, comp, 0U /* force-enabled don't get any phase blacklisting */,
575575
data1, data2, data3);
576576
if (backend) {
577+
int err;
577578
backend->envvar_forced = envvar_forced;
578579
if (topology->backends)
579580
hwloc_backends_disable_all(topology);
580-
return hwloc_backend_enable(backend);
581+
err = hwloc_backend_enable(backend);
582+
583+
if (comp->phases == HWLOC_DISC_PHASE_GLOBAL) {
584+
char *env = getenv("HWLOC_ANNOTATE_GLOBAL_COMPONENTS");
585+
if (env && atoi(env))
586+
topology->backend_excluded_phases &= ~HWLOC_DISC_PHASE_ANNOTATE;
587+
}
588+
589+
return err;
581590
} else
582591
return -1;
583592
}

hwloc/topology.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,10 +3215,12 @@ hwloc_discover(struct hwloc_topology *topology,
32153215
* automatically propagated to the whole tree after detection.
32163216
*/
32173217

3218-
if (topology->backend_phases == HWLOC_DISC_PHASE_GLOBAL) {
3218+
if (topology->backend_phases & HWLOC_DISC_PHASE_GLOBAL) {
3219+
/* usually, GLOBAL is alone.
3220+
* but HWLOC_ANNOTATE_GLOBAL_COMPONENTS=1 allows optional ANNOTATE steps.
3221+
*/
32193222
struct hwloc_backend *global_backend = topology->backends;
32203223
assert(global_backend);
3221-
assert(!global_backend->next);
32223224
assert(global_backend->phases == HWLOC_DISC_PHASE_GLOBAL);
32233225

32243226
/*
@@ -3237,7 +3239,6 @@ hwloc_discover(struct hwloc_topology *topology,
32373239
*/
32383240

32393241
if (topology->backend_phases & HWLOC_DISC_PHASE_CPU) {
3240-
assert(!(topology->backend_phases & HWLOC_DISC_PHASE_GLOBAL));
32413242
/*
32423243
* Discover CPUs first
32433244
*/

0 commit comments

Comments
 (0)