Skip to content

Commit 24e2c76

Browse files
committed
synthetic/import: allow memory-side caches
It's just a single level, specified as an attribute to NUMAnodes pack:2 [numa(size=16GiB memorysidecache=1GiB)] pu:2 Signed-off-by: Brice Goglin <[email protected]>
1 parent 880a25a commit 24e2c76

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

hwloc/topology-synthetic.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct hwloc_synthetic_attr_s {
2323
unsigned depth; /* For caches/groups */
2424
hwloc_obj_cache_type_t cachetype; /* For caches */
2525
hwloc_uint64_t memorysize; /* For caches/memory */
26+
hwloc_uint64_t memorysidecachesize; /* Single level of memory-side-cache in-front of a NUMA node */
2627
};
2728

2829
struct hwloc_synthetic_indexes_s {
@@ -380,6 +381,9 @@ hwloc_synthetic_parse_attrs(const char *attrs, const char **next_posp,
380381
} else if (!iscache && !strncmp("memory=", attrs, 7)) {
381382
memorysize = hwloc_synthetic_parse_memory_attr(attrs+7, &attrs);
382383

384+
} else if (!strncmp("memorysidecachesize=", attrs, 20)) {
385+
sattr->memorysidecachesize = hwloc_synthetic_parse_memory_attr(attrs+20, &attrs);
386+
383387
} else if (!strncmp("indexes=", attrs, 8)) {
384388
index_string = attrs+8;
385389
attrs += 8;
@@ -490,6 +494,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
490494
data->level[0].indexes.string = NULL;
491495
data->level[0].indexes.array = NULL;
492496
data->level[0].attr.memorysize = 0;
497+
data->level[0].attr.memorysidecachesize = 0;
493498
data->level[0].attached = NULL;
494499
type_count[HWLOC_OBJ_MACHINE] = 1;
495500
if (*description == '(') {
@@ -539,6 +544,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
539544
if (attached) {
540545
attached->attr.type = type;
541546
attached->attr.memorysize = 0;
547+
attached->attr.memorysidecachesize = 0;
542548
/* attached->attr.depth and .cachetype unused */
543549
attached->next = NULL;
544550
pprev = &data->level[count-1].attached;
@@ -636,6 +642,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
636642
data->level[count].indexes.string = NULL;
637643
data->level[count].indexes.array = NULL;
638644
data->level[count].attr.memorysize = 0;
645+
data->level[count].attr.memorysidecachesize = 0;
639646
if (*next_pos == '(') {
640647
err = hwloc_synthetic_parse_attrs(next_pos+1, &next_pos, &data->level[count].attr, &data->level[count].indexes, verbose);
641648
if (err < 0)
@@ -821,6 +828,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
821828
data->level[1].indexes.string = NULL;
822829
data->level[1].indexes.array = NULL;
823830
data->level[1].attr.memorysize = 0;
831+
data->level[1].attr.memorysidecachesize = 0;
824832
data->level[1].totalwidth = data->level[0].totalwidth;
825833
/* update arity to insert a single NUMA node per parent */
826834
data->level[1].arity = data->level[0].arity;
@@ -868,6 +876,12 @@ hwloc_synthetic_set_attr(struct hwloc_synthetic_attr_s *sattr,
868876
obj->attr->numanode.page_types[0].size = 4096;
869877
obj->attr->numanode.page_types[0].count = sattr->memorysize / 4096;
870878
break;
879+
case HWLOC_OBJ_MEMCACHE:
880+
obj->attr->cache.depth = 1;
881+
obj->attr->cache.linesize = 64;
882+
obj->attr->cache.type = HWLOC_OBJ_CACHE_UNIFIED;
883+
obj->attr->cache.size = sattr->memorysidecachesize;
884+
break;
871885
case HWLOC_OBJ_PACKAGE:
872886
case HWLOC_OBJ_DIE:
873887
break;
@@ -935,6 +949,14 @@ hwloc_synthetic_insert_attached(struct hwloc_topology *topology,
935949

936950
hwloc__insert_object_by_cpuset(topology, NULL, child, "synthetic:attached");
937951

952+
if (attached->attr.memorysidecachesize) {
953+
hwloc_obj_t mscachechild = hwloc_alloc_setup_object(topology, HWLOC_OBJ_MEMCACHE, HWLOC_UNKNOWN_INDEX);
954+
mscachechild->cpuset = hwloc_bitmap_dup(set);
955+
mscachechild->nodeset = hwloc_bitmap_dup(child->nodeset);
956+
hwloc_synthetic_set_attr(&attached->attr, mscachechild);
957+
hwloc__insert_object_by_cpuset(topology, NULL, mscachechild, "synthetic:attached:mscache");
958+
}
959+
938960
hwloc_synthetic_insert_attached(topology, data, attached->next, set);
939961
}
940962

@@ -986,6 +1008,14 @@ hwloc__look_synthetic(struct hwloc_topology *topology,
9861008
hwloc_synthetic_set_attr(&curlevel->attr, obj);
9871009

9881010
hwloc__insert_object_by_cpuset(topology, NULL, obj, "synthetic");
1011+
1012+
if (type == HWLOC_OBJ_NUMANODE && curlevel->attr.memorysidecachesize) {
1013+
hwloc_obj_t mscachechild = hwloc_alloc_setup_object(topology, HWLOC_OBJ_MEMCACHE, HWLOC_UNKNOWN_INDEX);
1014+
mscachechild->cpuset = hwloc_bitmap_dup(set);
1015+
mscachechild->nodeset = hwloc_bitmap_dup(obj->nodeset);
1016+
hwloc_synthetic_set_attr(&curlevel->attr, mscachechild);
1017+
hwloc__insert_object_by_cpuset(topology, NULL, mscachechild, "synthetic:mscache");
1018+
}
9891019
}
9901020

9911021
hwloc_synthetic_insert_attached(topology, data, curlevel->attached, set);

0 commit comments

Comments
 (0)