Skip to content

Commit

Permalink
synthetic/import: allow memory-side caches
Browse files Browse the repository at this point in the history
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 <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Apr 26, 2023
1 parent 880a25a commit 24e2c76
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions hwloc/topology-synthetic.c
Expand Up @@ -23,6 +23,7 @@ struct hwloc_synthetic_attr_s {
unsigned depth; /* For caches/groups */
hwloc_obj_cache_type_t cachetype; /* For caches */
hwloc_uint64_t memorysize; /* For caches/memory */
hwloc_uint64_t memorysidecachesize; /* Single level of memory-side-cache in-front of a NUMA node */
};

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

} else if (!strncmp("memorysidecachesize=", attrs, 20)) {
sattr->memorysidecachesize = hwloc_synthetic_parse_memory_attr(attrs+20, &attrs);

} else if (!strncmp("indexes=", attrs, 8)) {
index_string = attrs+8;
attrs += 8;
Expand Down Expand Up @@ -490,6 +494,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
data->level[0].indexes.string = NULL;
data->level[0].indexes.array = NULL;
data->level[0].attr.memorysize = 0;
data->level[0].attr.memorysidecachesize = 0;
data->level[0].attached = NULL;
type_count[HWLOC_OBJ_MACHINE] = 1;
if (*description == '(') {
Expand Down Expand Up @@ -539,6 +544,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
if (attached) {
attached->attr.type = type;
attached->attr.memorysize = 0;
attached->attr.memorysidecachesize = 0;
/* attached->attr.depth and .cachetype unused */
attached->next = NULL;
pprev = &data->level[count-1].attached;
Expand Down Expand Up @@ -636,6 +642,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
data->level[count].indexes.string = NULL;
data->level[count].indexes.array = NULL;
data->level[count].attr.memorysize = 0;
data->level[count].attr.memorysidecachesize = 0;
if (*next_pos == '(') {
err = hwloc_synthetic_parse_attrs(next_pos+1, &next_pos, &data->level[count].attr, &data->level[count].indexes, verbose);
if (err < 0)
Expand Down Expand Up @@ -821,6 +828,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
data->level[1].indexes.string = NULL;
data->level[1].indexes.array = NULL;
data->level[1].attr.memorysize = 0;
data->level[1].attr.memorysidecachesize = 0;
data->level[1].totalwidth = data->level[0].totalwidth;
/* update arity to insert a single NUMA node per parent */
data->level[1].arity = data->level[0].arity;
Expand Down Expand Up @@ -868,6 +876,12 @@ hwloc_synthetic_set_attr(struct hwloc_synthetic_attr_s *sattr,
obj->attr->numanode.page_types[0].size = 4096;
obj->attr->numanode.page_types[0].count = sattr->memorysize / 4096;
break;
case HWLOC_OBJ_MEMCACHE:
obj->attr->cache.depth = 1;
obj->attr->cache.linesize = 64;
obj->attr->cache.type = HWLOC_OBJ_CACHE_UNIFIED;
obj->attr->cache.size = sattr->memorysidecachesize;
break;
case HWLOC_OBJ_PACKAGE:
case HWLOC_OBJ_DIE:
break;
Expand Down Expand Up @@ -935,6 +949,14 @@ hwloc_synthetic_insert_attached(struct hwloc_topology *topology,

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

if (attached->attr.memorysidecachesize) {
hwloc_obj_t mscachechild = hwloc_alloc_setup_object(topology, HWLOC_OBJ_MEMCACHE, HWLOC_UNKNOWN_INDEX);
mscachechild->cpuset = hwloc_bitmap_dup(set);
mscachechild->nodeset = hwloc_bitmap_dup(child->nodeset);
hwloc_synthetic_set_attr(&attached->attr, mscachechild);
hwloc__insert_object_by_cpuset(topology, NULL, mscachechild, "synthetic:attached:mscache");
}

hwloc_synthetic_insert_attached(topology, data, attached->next, set);
}

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

hwloc__insert_object_by_cpuset(topology, NULL, obj, "synthetic");

if (type == HWLOC_OBJ_NUMANODE && curlevel->attr.memorysidecachesize) {
hwloc_obj_t mscachechild = hwloc_alloc_setup_object(topology, HWLOC_OBJ_MEMCACHE, HWLOC_UNKNOWN_INDEX);
mscachechild->cpuset = hwloc_bitmap_dup(set);
mscachechild->nodeset = hwloc_bitmap_dup(obj->nodeset);
hwloc_synthetic_set_attr(&curlevel->attr, mscachechild);
hwloc__insert_object_by_cpuset(topology, NULL, mscachechild, "synthetic:mscache");
}
}

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

0 comments on commit 24e2c76

Please sign in to comment.