Skip to content

Commit 8db8fd3

Browse files
committed
synthetic/export: export memory-side caches
Accumulate all levels in a single MS$ attribute of the NUMA node. Ignore memory side caches when exporting to v1 since the object doesn't exist there. Signed-off-by: Brice Goglin <[email protected]>
1 parent 24e2c76 commit 8db8fd3

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

hwloc/topology-synthetic.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,13 +1256,15 @@ hwloc__export_synthetic_indexes(hwloc_obj_t *level, unsigned total,
12561256

12571257
static int
12581258
hwloc__export_synthetic_obj_attr(struct hwloc_topology * topology,
1259+
unsigned long flags,
12591260
hwloc_obj_t obj,
12601261
char *buffer, size_t buflen)
12611262
{
12621263
const char * separator = " ";
12631264
const char * prefix = "(";
12641265
char cachesize[64] = "";
12651266
char memsize[64] = "";
1267+
char memorysidecachesize[64] = "";
12661268
int needindexes = 0;
12671269

12681270
if (hwloc__obj_type_is_cache(obj->type) && obj->attr->cache.size) {
@@ -1275,6 +1277,19 @@ hwloc__export_synthetic_obj_attr(struct hwloc_topology * topology,
12751277
prefix, (unsigned long long) obj->attr->numanode.local_memory);
12761278
prefix = separator;
12771279
}
1280+
if (obj->type == HWLOC_OBJ_NUMANODE && !(flags & HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_V1)) {
1281+
hwloc_obj_t memorysidecache = obj->parent;
1282+
hwloc_uint64_t size = 0;
1283+
while (memorysidecache && memorysidecache->type == HWLOC_OBJ_MEMCACHE) {
1284+
size += memorysidecache->attr->cache.size;
1285+
memorysidecache = memorysidecache->parent;
1286+
}
1287+
if (size) {
1288+
snprintf(memorysidecachesize, sizeof(memorysidecachesize), "%smemorysidecachesize=%llu",
1289+
prefix, (unsigned long long) size);
1290+
prefix = separator;
1291+
}
1292+
}
12781293
if (!obj->logical_index /* only display indexes once per level (not for non-first NUMA children, etc.) */
12791294
&& (obj->type == HWLOC_OBJ_PU || obj->type == HWLOC_OBJ_NUMANODE)) {
12801295
hwloc_obj_t cur = obj;
@@ -1286,12 +1301,12 @@ hwloc__export_synthetic_obj_attr(struct hwloc_topology * topology,
12861301
cur = cur->next_cousin;
12871302
}
12881303
}
1289-
if (*cachesize || *memsize || needindexes) {
1304+
if (*cachesize || *memsize || *memorysidecachesize || needindexes) {
12901305
ssize_t tmplen = buflen;
12911306
char *tmp = buffer;
12921307
int res, ret = 0;
12931308

1294-
res = hwloc_snprintf(tmp, tmplen, "%s%s%s", cachesize, memsize, needindexes ? "" : ")");
1309+
res = hwloc_snprintf(tmp, tmplen, "%s%s%s%s", cachesize, memsize, memorysidecachesize, needindexes ? "" : ")");
12951310
if (hwloc__export_synthetic_update_status(&ret, &tmp, &tmplen, res) < 0)
12961311
return -1;
12971312

@@ -1365,7 +1380,7 @@ hwloc__export_synthetic_obj(struct hwloc_topology * topology, unsigned long flag
13651380

13661381
if (!(flags & HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_ATTRS)) {
13671382
/* obj attributes */
1368-
res = hwloc__export_synthetic_obj_attr(topology, obj, tmp, tmplen);
1383+
res = hwloc__export_synthetic_obj_attr(topology, flags, obj, tmp, tmplen);
13691384
if (hwloc__export_synthetic_update_status(&ret, &tmp, &tmplen, res) < 0)
13701385
return -1;
13711386
}
@@ -1411,21 +1426,19 @@ hwloc__export_synthetic_memory_children(struct hwloc_topology * topology, unsign
14111426
}
14121427

14131428
while (mchild) {
1414-
/* FIXME: really recurse to export memcaches and numanode,
1429+
/* The core doesn't support shared memcache for now (because ACPI and Linux don't).
1430+
* So, for each mchild here, recurse only in the first children at each level.
1431+
*
1432+
* FIXME: whenever supported by the core, really recurse to export memcaches and numanode,
14151433
* but it requires clever parsing of [ memcache [numa] [numa] ] during import,
14161434
* better attaching of things to describe the hierarchy.
14171435
*/
14181436
hwloc_obj_t numanode = mchild;
1419-
/* only export the first NUMA node leaf of each memory child.
1420-
* memcache are ignored. non-first child of memcaches are also ignored.
1437+
/* Only export the first NUMA node leaf of each memory child.
1438+
* Memcaches are ignored here, they will be summed and exported as a single attribute
1439+
* of the NUMA node in hwloc__export_synthetic_obj().
14211440
*/
14221441
while (numanode && numanode->type != HWLOC_OBJ_NUMANODE) {
1423-
if (verbose) {
1424-
static int warned = 0;
1425-
if (!warned)
1426-
fprintf(stderr, "Ignoring memory objects that are not NUMA nodes.\n");
1427-
warned = 1;
1428-
}
14291442
if (verbose && numanode->memory_arity > 1) {
14301443
static int warned = 0;
14311444
if (!warned)
@@ -1591,7 +1604,7 @@ hwloc_topology_export_synthetic(struct hwloc_topology * topology,
15911604

15921605
if (!(flags & HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_ATTRS)) {
15931606
/* obj attributes */
1594-
res = hwloc__export_synthetic_obj_attr(topology, obj, tmp, tmplen);
1607+
res = hwloc__export_synthetic_obj_attr(topology, flags, obj, tmp, tmplen);
15951608
if (res > 0)
15961609
needprefix = 1;
15971610
if (hwloc__export_synthetic_update_status(&ret, &tmp, &tmplen, res) < 0)

0 commit comments

Comments
 (0)