@@ -23,6 +23,7 @@ struct hwloc_synthetic_attr_s {
23
23
unsigned depth ; /* For caches/groups */
24
24
hwloc_obj_cache_type_t cachetype ; /* For caches */
25
25
hwloc_uint64_t memorysize ; /* For caches/memory */
26
+ hwloc_uint64_t memorysidecachesize ; /* Single level of memory-side-cache in-front of a NUMA node */
26
27
};
27
28
28
29
struct hwloc_synthetic_indexes_s {
@@ -380,6 +381,9 @@ hwloc_synthetic_parse_attrs(const char *attrs, const char **next_posp,
380
381
} else if (!iscache && !strncmp ("memory=" , attrs , 7 )) {
381
382
memorysize = hwloc_synthetic_parse_memory_attr (attrs + 7 , & attrs );
382
383
384
+ } else if (!strncmp ("memorysidecachesize=" , attrs , 20 )) {
385
+ sattr -> memorysidecachesize = hwloc_synthetic_parse_memory_attr (attrs + 20 , & attrs );
386
+
383
387
} else if (!strncmp ("indexes=" , attrs , 8 )) {
384
388
index_string = attrs + 8 ;
385
389
attrs += 8 ;
@@ -490,6 +494,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
490
494
data -> level [0 ].indexes .string = NULL ;
491
495
data -> level [0 ].indexes .array = NULL ;
492
496
data -> level [0 ].attr .memorysize = 0 ;
497
+ data -> level [0 ].attr .memorysidecachesize = 0 ;
493
498
data -> level [0 ].attached = NULL ;
494
499
type_count [HWLOC_OBJ_MACHINE ] = 1 ;
495
500
if (* description == '(' ) {
@@ -539,6 +544,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
539
544
if (attached ) {
540
545
attached -> attr .type = type ;
541
546
attached -> attr .memorysize = 0 ;
547
+ attached -> attr .memorysidecachesize = 0 ;
542
548
/* attached->attr.depth and .cachetype unused */
543
549
attached -> next = NULL ;
544
550
pprev = & data -> level [count - 1 ].attached ;
@@ -636,6 +642,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
636
642
data -> level [count ].indexes .string = NULL ;
637
643
data -> level [count ].indexes .array = NULL ;
638
644
data -> level [count ].attr .memorysize = 0 ;
645
+ data -> level [count ].attr .memorysidecachesize = 0 ;
639
646
if (* next_pos == '(' ) {
640
647
err = hwloc_synthetic_parse_attrs (next_pos + 1 , & next_pos , & data -> level [count ].attr , & data -> level [count ].indexes , verbose );
641
648
if (err < 0 )
@@ -821,6 +828,7 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
821
828
data -> level [1 ].indexes .string = NULL ;
822
829
data -> level [1 ].indexes .array = NULL ;
823
830
data -> level [1 ].attr .memorysize = 0 ;
831
+ data -> level [1 ].attr .memorysidecachesize = 0 ;
824
832
data -> level [1 ].totalwidth = data -> level [0 ].totalwidth ;
825
833
/* update arity to insert a single NUMA node per parent */
826
834
data -> level [1 ].arity = data -> level [0 ].arity ;
@@ -868,6 +876,12 @@ hwloc_synthetic_set_attr(struct hwloc_synthetic_attr_s *sattr,
868
876
obj -> attr -> numanode .page_types [0 ].size = 4096 ;
869
877
obj -> attr -> numanode .page_types [0 ].count = sattr -> memorysize / 4096 ;
870
878
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 ;
871
885
case HWLOC_OBJ_PACKAGE :
872
886
case HWLOC_OBJ_DIE :
873
887
break ;
@@ -935,6 +949,14 @@ hwloc_synthetic_insert_attached(struct hwloc_topology *topology,
935
949
936
950
hwloc__insert_object_by_cpuset (topology , NULL , child , "synthetic:attached" );
937
951
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
+
938
960
hwloc_synthetic_insert_attached (topology , data , attached -> next , set );
939
961
}
940
962
@@ -986,6 +1008,14 @@ hwloc__look_synthetic(struct hwloc_topology *topology,
986
1008
hwloc_synthetic_set_attr (& curlevel -> attr , obj );
987
1009
988
1010
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
+ }
989
1019
}
990
1020
991
1021
hwloc_synthetic_insert_attached (topology , data , curlevel -> attached , set );
0 commit comments