@@ -416,6 +416,32 @@ hwloc_synthetic_parse_attrs(const char *attrs, const char **next_posp,
416
416
return 0 ;
417
417
}
418
418
419
+ static void
420
+ hwloc_synthetic_set_default_attrs (struct hwloc_synthetic_attr_s * sattr ,
421
+ int * type_count )
422
+ {
423
+ hwloc_obj_type_t type = sattr -> type ;
424
+
425
+ if (type == HWLOC_OBJ_GROUP ) {
426
+ if (sattr -> depth == (unsigned )-1 )
427
+ sattr -> depth = type_count [HWLOC_OBJ_GROUP ]-- ;
428
+
429
+ } else if (hwloc__obj_type_is_cache (type )) {
430
+ if (!sattr -> memorysize ) {
431
+ if (1 == sattr -> depth )
432
+ /* 32KiB in L1 */
433
+ sattr -> memorysize = 32 * 1024 ;
434
+ else
435
+ /* *4 at each level, starting from 1MiB for L2, unified */
436
+ sattr -> memorysize = 256ULL * 1024 << (2 * sattr -> depth );
437
+ }
438
+
439
+ } else if (type == HWLOC_OBJ_NUMANODE && !sattr -> memorysize ) {
440
+ /* 1GiB in memory nodes. */
441
+ sattr -> memorysize = 1024 * 1024 * 1024 ;
442
+ }
443
+ }
444
+
419
445
/* frees level until arity = 0 */
420
446
static void
421
447
hwloc_synthetic_free_levels (struct hwloc_synthetic_backend_data_s * data )
@@ -803,30 +829,14 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
803
829
count ++ ;
804
830
}
805
831
832
+ /* set default attributes that depend on the depth/hierarchy of levels */
806
833
for (i = 0 ; i < count ; i ++ ) {
834
+ struct hwloc_synthetic_attached_s * attached ;
807
835
struct hwloc_synthetic_level_data_s * curlevel = & data -> level [i ];
808
- hwloc_obj_type_t type = curlevel -> attr .type ;
809
-
810
- if (type == HWLOC_OBJ_GROUP ) {
811
- if (curlevel -> attr .depth == (unsigned )-1 )
812
- curlevel -> attr .depth = type_count [HWLOC_OBJ_GROUP ]-- ;
813
-
814
- } else if (hwloc__obj_type_is_cache (type )) {
815
- if (!curlevel -> attr .memorysize ) {
816
- if (1 == curlevel -> attr .depth )
817
- /* 32KiB in L1 */
818
- curlevel -> attr .memorysize = 32 * 1024 ;
819
- else
820
- /* *4 at each level, starting from 1MiB for L2, unified */
821
- curlevel -> attr .memorysize = 256ULL * 1024 << (2 * curlevel -> attr .depth );
822
- }
823
-
824
- } else if (type == HWLOC_OBJ_NUMANODE && !curlevel -> attr .memorysize ) {
825
- /* 1GiB in memory nodes. */
826
- curlevel -> attr .memorysize = 1024 * 1024 * 1024 ;
827
- }
828
-
829
- hwloc_synthetic_process_indexes (data , & data -> level [i ].indexes , data -> level [i ].totalwidth , verbose );
836
+ hwloc_synthetic_set_default_attrs (& curlevel -> attr , type_count );
837
+ for (attached = curlevel -> attached ; attached != NULL ; attached = attached -> next )
838
+ hwloc_synthetic_set_default_attrs (& attached -> attr , type_count );
839
+ hwloc_synthetic_process_indexes (data , & curlevel -> indexes , curlevel -> totalwidth , verbose );
830
840
}
831
841
832
842
hwloc_synthetic_process_indexes (data , & data -> numa_attached_indexes , data -> numa_attached_nr , verbose );
0 commit comments