@@ -1239,6 +1239,73 @@ hwloc__xml_import_object(hwloc_topology_t topology,
1239
1239
return -1 ;
1240
1240
}
1241
1241
1242
+ static int
1243
+ hwloc__xml_v2import_support (hwloc_topology_t topology ,
1244
+ hwloc__xml_import_state_t state )
1245
+ {
1246
+ char * name = NULL ;
1247
+ int value = 1 ; /* value is optional */
1248
+ while (1 ) {
1249
+ char * attrname , * attrvalue ;
1250
+ if (state -> global -> next_attr (state , & attrname , & attrvalue ) < 0 )
1251
+ break ;
1252
+ if (!strcmp (attrname , "name" ))
1253
+ name = attrvalue ;
1254
+ else if (!strcmp (attrname , "value" ))
1255
+ value = atoi (attrvalue );
1256
+ else {
1257
+ if (hwloc__xml_verbose ())
1258
+ fprintf (stderr , "%s: ignoring unknown support attribute %s\n" ,
1259
+ state -> global -> msgprefix , attrname );
1260
+ }
1261
+ }
1262
+
1263
+ if (name && topology -> flags & HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT ) {
1264
+ #ifdef HWLOC_DEBUG
1265
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_support ) == 3 * sizeof (void * ));
1266
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_discovery_support ) == 5 );
1267
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_cpubind_support ) == 11 );
1268
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_membind_support ) == 15 );
1269
+ #endif
1270
+
1271
+ #define DO (_cat ,_name ) if (!strcmp(#_cat "." #_name, name)) topology->support._cat->_name = value
1272
+ DO (discovery ,pu );
1273
+ else DO (discovery ,numa );
1274
+ else DO (discovery ,numa_memory );
1275
+ else DO (discovery ,disallowed_pu );
1276
+ else DO (discovery ,disallowed_numa );
1277
+ else DO (cpubind ,set_thisproc_cpubind );
1278
+ else DO (cpubind ,get_thisproc_cpubind );
1279
+ else DO (cpubind ,set_proc_cpubind );
1280
+ else DO (cpubind ,get_proc_cpubind );
1281
+ else DO (cpubind ,set_thisthread_cpubind );
1282
+ else DO (cpubind ,get_thisthread_cpubind );
1283
+ else DO (cpubind ,set_thread_cpubind );
1284
+ else DO (cpubind ,get_thread_cpubind );
1285
+ else DO (cpubind ,get_thisproc_last_cpu_location );
1286
+ else DO (cpubind ,get_proc_last_cpu_location );
1287
+ else DO (cpubind ,get_thisthread_last_cpu_location );
1288
+ else DO (membind ,set_thisproc_membind );
1289
+ else DO (membind ,get_thisproc_membind );
1290
+ else DO (membind ,set_proc_membind );
1291
+ else DO (membind ,get_proc_membind );
1292
+ else DO (membind ,set_thisthread_membind );
1293
+ else DO (membind ,get_thisthread_membind );
1294
+ else DO (membind ,set_area_membind );
1295
+ else DO (membind ,get_area_membind );
1296
+ else DO (membind ,alloc_membind );
1297
+ else DO (membind ,firsttouch_membind );
1298
+ else DO (membind ,bind_membind );
1299
+ else DO (membind ,interleave_membind );
1300
+ else DO (membind ,nexttouch_membind );
1301
+ else DO (membind ,migrate_membind );
1302
+ else DO (membind ,get_area_memlocation );
1303
+ #undef DO
1304
+ }
1305
+
1306
+ return 0 ;
1307
+ }
1308
+
1242
1309
static int
1243
1310
hwloc__xml_v2import_distances (hwloc_topology_t topology ,
1244
1311
hwloc__xml_import_state_t state ,
@@ -1761,6 +1828,10 @@ hwloc_look_xml(struct hwloc_backend *backend, struct hwloc_disc_status *dstatus)
1761
1828
ret = hwloc__xml_v2import_distances (topology , & childstate , 1 );
1762
1829
if (ret < 0 )
1763
1830
goto failed ;
1831
+ } else if (!strcmp (tag , "support" )) {
1832
+ ret = hwloc__xml_v2import_support (topology , & childstate );
1833
+ if (ret < 0 )
1834
+ goto failed ;
1764
1835
} else {
1765
1836
if (hwloc__xml_verbose ())
1766
1837
fprintf (stderr , "%s: ignoring unknown tag `%s' after root object.\n" ,
@@ -1866,12 +1937,14 @@ hwloc_look_xml(struct hwloc_backend *backend, struct hwloc_disc_status *dstatus)
1866
1937
/* keep the "Backend" information intact */
1867
1938
/* we could add "BackendSource=XML" to notify that XML was used between the actual backend and here */
1868
1939
1869
- topology -> support .discovery -> pu = 1 ;
1870
- topology -> support .discovery -> disallowed_pu = 1 ;
1871
- if (data -> nbnumanodes ) {
1872
- topology -> support .discovery -> numa = 1 ;
1873
- topology -> support .discovery -> numa_memory = 1 ; // FIXME
1874
- topology -> support .discovery -> disallowed_numa = 1 ;
1940
+ if (!(topology -> flags & HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT )) {
1941
+ topology -> support .discovery -> pu = 1 ;
1942
+ topology -> support .discovery -> disallowed_pu = 1 ;
1943
+ if (data -> nbnumanodes ) {
1944
+ topology -> support .discovery -> numa = 1 ;
1945
+ topology -> support .discovery -> numa_memory = 1 ; // FIXME
1946
+ topology -> support .discovery -> disallowed_numa = 1 ;
1947
+ }
1875
1948
}
1876
1949
1877
1950
if (data -> look_done )
@@ -2622,9 +2695,70 @@ hwloc__xml_v2export_distances(hwloc__xml_export_state_t parentstate, hwloc_topol
2622
2695
hwloc___xml_v2export_distances (parentstate , dist );
2623
2696
}
2624
2697
2698
+ static void
2699
+ hwloc__xml_v2export_support (hwloc__xml_export_state_t parentstate , hwloc_topology_t topology )
2700
+ {
2701
+ struct hwloc__xml_export_state_s state ;
2702
+ char tmp [11 ];
2703
+
2704
+ #ifdef HWLOC_DEBUG
2705
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_support ) == 3 * sizeof (void * ));
2706
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_discovery_support ) == 5 );
2707
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_cpubind_support ) == 11 );
2708
+ HWLOC_BUILD_ASSERT (sizeof (struct hwloc_topology_membind_support ) == 15 );
2709
+ #endif
2710
+
2711
+ #define DO (_cat ,_name ) do { \
2712
+ if (topology->support._cat->_name) { \
2713
+ parentstate->new_child(parentstate, &state, "support"); \
2714
+ state.new_prop(&state, "name", #_cat "." #_name); \
2715
+ if (topology->support._cat->_name != 1) { \
2716
+ sprintf(tmp, "%u", topology->support._cat->_name); \
2717
+ state.new_prop(&state, "value", tmp); \
2718
+ } \
2719
+ state.end_object(&state, "support"); \
2720
+ } \
2721
+ } while (0)
2722
+
2723
+ DO (discovery ,pu );
2724
+ DO (discovery ,numa );
2725
+ DO (discovery ,numa_memory );
2726
+ DO (discovery ,disallowed_pu );
2727
+ DO (discovery ,disallowed_numa );
2728
+ DO (cpubind ,set_thisproc_cpubind );
2729
+ DO (cpubind ,get_thisproc_cpubind );
2730
+ DO (cpubind ,set_proc_cpubind );
2731
+ DO (cpubind ,get_proc_cpubind );
2732
+ DO (cpubind ,set_thisthread_cpubind );
2733
+ DO (cpubind ,get_thisthread_cpubind );
2734
+ DO (cpubind ,set_thread_cpubind );
2735
+ DO (cpubind ,get_thread_cpubind );
2736
+ DO (cpubind ,get_thisproc_last_cpu_location );
2737
+ DO (cpubind ,get_proc_last_cpu_location );
2738
+ DO (cpubind ,get_thisthread_last_cpu_location );
2739
+ DO (membind ,set_thisproc_membind );
2740
+ DO (membind ,get_thisproc_membind );
2741
+ DO (membind ,set_proc_membind );
2742
+ DO (membind ,get_proc_membind );
2743
+ DO (membind ,set_thisthread_membind );
2744
+ DO (membind ,get_thisthread_membind );
2745
+ DO (membind ,set_area_membind );
2746
+ DO (membind ,get_area_membind );
2747
+ DO (membind ,alloc_membind );
2748
+ DO (membind ,firsttouch_membind );
2749
+ DO (membind ,bind_membind );
2750
+ DO (membind ,interleave_membind );
2751
+ DO (membind ,nexttouch_membind );
2752
+ DO (membind ,migrate_membind );
2753
+ DO (membind ,get_area_memlocation );
2754
+
2755
+ #undef DO
2756
+ }
2757
+
2625
2758
void
2626
2759
hwloc__xml_export_topology (hwloc__xml_export_state_t state , hwloc_topology_t topology , unsigned long flags )
2627
2760
{
2761
+ char * env ;
2628
2762
hwloc_obj_t root = hwloc_get_root_obj (topology );
2629
2763
2630
2764
if (flags & HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 ) {
@@ -2667,6 +2801,9 @@ hwloc__xml_export_topology(hwloc__xml_export_state_t state, hwloc_topology_t top
2667
2801
} else {
2668
2802
hwloc__xml_v2export_object (state , topology , root , flags );
2669
2803
hwloc__xml_v2export_distances (state , topology );
2804
+ env = getenv ("HWLOC_XML_EXPORT_SUPPORT" );
2805
+ if (!env || atoi (env ))
2806
+ hwloc__xml_v2export_support (state , topology );
2670
2807
}
2671
2808
}
2672
2809
0 commit comments