Skip to content

Commit

Permalink
memattrs: add MemoryTiersNr=2 info attr to topology
Browse files Browse the repository at this point in the history
Closes #661

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Apr 30, 2024
1 parent 9900705 commit 0839821
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 7 deletions.
10 changes: 10 additions & 0 deletions doc/hwloc.doxy
Expand Up @@ -2034,6 +2034,10 @@ placed.
These info attributes are attached to the topology itself.

<dl>
<dt>MemoryTiersNr</dt>
<dd>The number of different memory tiers in the topology, if any.
See \ref heteromem.
</dd>
<dt>Backend</dt>
<dd>The name of a hwloc backend/component that added objects in the topology.
If several components were combined, multiple Backend pairs may exist,
Expand Down Expand Up @@ -2574,6 +2578,12 @@ $ hwloc-calc -I 'numa[tier=0]' -p all
2,3
\endverbatim

The number of tiers may be retrieved at looking in topology attributes:
\verbatim
$ hwloc-info --get-attr "info MemoryTiersNr" topology
2
\endverbatim

hwloc-calc and hwloc-bind also have options such as
<tt>\--local-memory</tt> and <tt>\--best-memattr</tt>
to select the best NUMA node among the local ones.
Expand Down
8 changes: 7 additions & 1 deletion hwloc/memattrs.c
@@ -1,5 +1,5 @@
/*
* Copyright © 2020-2023 Inria. All rights reserved.
* Copyright © 2020-2024 Inria. All rights reserved.
* See COPYING in top-level directory.
*/

Expand Down Expand Up @@ -1807,6 +1807,11 @@ hwloc__apply_memory_tiers_subtypes(hwloc_topology_t topology,
}
}
}
if (nr_tiers > 1) {
char tmp[20];
snprintf(tmp, sizeof(tmp), "%u", nr_tiers);
hwloc__replace_infos(&topology->infos, "MemoryTiersNr", tmp);
}
}

int
Expand All @@ -1822,6 +1827,7 @@ hwloc_internal_memattrs_guess_memory_tiers(hwloc_topology_t topology, int force_
while ((node = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, node)) != NULL) {
hwloc__remove_infos(&node->infos, "MemoryTier", NULL);
}
hwloc__remove_infos(&topology->infos, "MemoryTiersNr", NULL);

env = getenv("HWLOC_MEMTIERS");
if (env) {
Expand Down
3 changes: 2 additions & 1 deletion hwloc/topology-xml.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
* Copyright © 2009-2023 Inria. All rights reserved.
* Copyright © 2009-2024 Inria. All rights reserved.
* Copyright © 2009-2011, 2020 Université Bordeaux
* Copyright © 2009-2018 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
Expand Down Expand Up @@ -458,6 +458,7 @@ hwloc__xml_import_obj_info(hwloc_topology_t topology,
if (!strcmp(infoname, "Backend")
|| !strcmp(infoname, "SyntheticDescription")
|| !strcmp(infoname, "LinuxCgroup")
|| !strcmp(infoname, "MemoryTiersNr")
|| !strcmp(infoname, "WindowsBuildEnvironment")
|| !strcmp(infoname, "OSName")
|| !strcmp(infoname, "OSRelease")
Expand Down
Expand Up @@ -155,5 +155,5 @@ Memory attribute #2 name `Bandwidth' flags 5
NUMANode L#5 = 90000 from cpuset 0x0f000f00,0x0f000f00 (Group0 L#2)
NUMANode L#6 = 22500 from cpuset 0xf000f000,0xf000f000 (Group0 L#3)
NUMANode L#7 = 90000 from cpuset 0xf000f000,0xf000f000 (Group0 L#3)
Topology infos: Backend=Linux OSName=Linux OSRelease=3.10.0-327.el7.x86_64 OSVersion="#1 SMP Thu Oct 29 17:29:29 EDT 2015" HostName=localhost.localdomain Architecture=x86_64
Topology infos: Backend=Linux OSName=Linux OSRelease=3.10.0-327.el7.x86_64 OSVersion="#1 SMP Thu Oct 29 17:29:29 EDT 2015" HostName=localhost.localdomain Architecture=x86_64 MemoryTiersNr=2
Topology not from this system
2 changes: 1 addition & 1 deletion tests/hwloc/linux/64intel64-fakeKNL-SNC4-hybrid.console
Expand Up @@ -150,5 +150,5 @@ Memory attribute #2 name `Bandwidth' flags 5
NUMANode L#5 = 90000 from cpuset 0x0f000f00,0x0f000f00 (L3 L#2)
NUMANode L#6 = 22500 from cpuset 0xf000f000,0xf000f000 (L3 L#3)
NUMANode L#7 = 90000 from cpuset 0xf000f000,0xf000f000 (L3 L#3)
Topology infos: Backend=Linux OSName=Linux OSRelease=3.10.0-327.el7.x86_64 OSVersion="#1 SMP Thu Oct 29 17:29:29 EDT 2015" HostName=localhost.localdomain Architecture=x86_64
Topology infos: Backend=Linux OSName=Linux OSRelease=3.10.0-327.el7.x86_64 OSVersion="#1 SMP Thu Oct 29 17:29:29 EDT 2015" HostName=localhost.localdomain Architecture=x86_64 MemoryTiersNr=2
Topology not from this system
2 changes: 1 addition & 1 deletion tests/hwloc/linux/fakeheteromemtiers.console
Expand Up @@ -88,5 +88,5 @@ Memory attribute #5 name `WriteBandwidth' flags 5
NUMANode L#4 = 100 from cpuset 0x0000000c (Group0 L#1)
NUMANode L#1 = 100 from cpuset 0x00000003 (Group0 L#0)
NUMANode L#6 = 100 from cpuset 0x00000030 (Group0 L#2)
Topology infos: LinuxCgroup=/ Backend=Linux OSName=Linux OSRelease=5.18.0-rc4 OSVersion="#1 SMP PREEMPT_DYNAMIC Tue Apr 26 11:49:51 CEST 2022" HostName=efi Architecture=x86_64
Topology infos: LinuxCgroup=/ Backend=Linux OSName=Linux OSRelease=5.18.0-rc4 OSVersion="#1 SMP PREEMPT_DYNAMIC Tue Apr 26 11:49:51 CEST 2022" HostName=efi Architecture=x86_64 MemoryTiersNr=3
Topology not from this system
2 changes: 1 addition & 1 deletion tests/hwloc/linux/fakememinitiators-1np2c+1npp+gi.console
Expand Up @@ -83,5 +83,5 @@ Memory attribute #7 name `WriteLatency' flags 6
NUMANode L#3 = 26 from cpuset 0x0000000c (Group0 L#2)
NUMANode L#4 = 26 from cpuset 0x000000c0 (Group0 L#3)
NUMANode L#5 = 77 from cpuset 0x000000cc (Package L#1)
Topology infos: LinuxCgroup=/ Backend=Linux
Topology infos: LinuxCgroup=/ Backend=Linux MemoryTiersNr=2
Topology not from this system
2 changes: 1 addition & 1 deletion tests/hwloc/linux/nvidiagpunumanodes-kept.console
Expand Up @@ -106,5 +106,5 @@ Relative latency matrix (name NUMALatency kind 5) between 8 NUMANodes (depth -3)
1 80 80 80 80 80 10 80 80
2 80 80 80 80 80 80 10 80
3 80 80 80 80 80 80 80 10
Topology infos: LinuxCgroup=/jjh Backend=Linux OSName=Linux OSRelease=4.14.0-49.el7a.bz1553205.page_fault_hang.ppc64le OSVersion="#1 SMP Fri Mar 30 12:06:11 CDT 2018" HostName=c685f8n02 Architecture=ppc64le
Topology infos: LinuxCgroup=/jjh Backend=Linux OSName=Linux OSRelease=4.14.0-49.el7a.bz1553205.page_fault_hang.ppc64le OSVersion="#1 SMP Fri Mar 30 12:06:11 CDT 2018" HostName=c685f8n02 Architecture=ppc64le MemoryTiersNr=2
Topology not from this system

0 comments on commit 0839821

Please sign in to comment.