@@ -754,6 +754,26 @@ hwloc__xml_import_object(hwloc_topology_t topology,
754
754
obj -> type = HWLOC_OBJ_DIE ;
755
755
}
756
756
757
+ /* 2.x backward compatibility */
758
+ if (data -> version_major <= 2 && obj -> type == HWLOC_OBJ_OS_DEVICE ) {
759
+ /* check if we need to add backend info to the root */
760
+ const char * backend = hwloc_obj_get_info_by_name (obj , "Backend" );
761
+ if (backend ) {
762
+ if (!strcmp (backend , "CUDA" ))
763
+ data -> need_cuda_backend_info = 1 ;
764
+ else if (!strcmp (backend , "NVML" ))
765
+ data -> need_nvml_backend_info = 1 ;
766
+ else if (!strcmp (backend , "RSMI" ))
767
+ data -> need_rsmi_backend_info = 1 ;
768
+ else if (!strcmp (backend , "LevelZero" ))
769
+ data -> need_levelzero_backend_info = 1 ;
770
+ else if (!strcmp (backend , "OpenCL" ))
771
+ data -> need_opencl_backend_info = 1 ;
772
+ else if (!strcmp (backend , "GL" ))
773
+ data -> need_gl_backend_info = 1 ;
774
+ }
775
+ }
776
+
757
777
/* check that cache attributes are coherent with the actual type */
758
778
if (hwloc__obj_type_is_cache (obj -> type )
759
779
&& obj -> type != hwloc_cache_type_by_depth_type (obj -> attr -> cache .depth , obj -> attr -> cache .type )) {
@@ -1690,6 +1710,12 @@ hwloc_look_xml(struct hwloc_backend *backend, struct hwloc_disc_status *dstatus)
1690
1710
hwloc_localeswitch_init ();
1691
1711
1692
1712
data -> nbnumanodes = 0 ;
1713
+ data -> need_cuda_backend_info = 0 ;
1714
+ data -> need_nvml_backend_info = 0 ;
1715
+ data -> need_rsmi_backend_info = 0 ;
1716
+ data -> need_levelzero_backend_info = 0 ;
1717
+ data -> need_opencl_backend_info = 0 ;
1718
+ data -> need_gl_backend_info = 0 ;
1693
1719
1694
1720
ret = data -> look_init (data , & state );
1695
1721
if (ret < 0 )
@@ -1805,7 +1831,39 @@ hwloc_look_xml(struct hwloc_backend *backend, struct hwloc_disc_status *dstatus)
1805
1831
/* allocate default cpusets and nodesets if missing, the core will restrict them */
1806
1832
hwloc_alloc_root_sets (root );
1807
1833
1808
- /* keep the "Backend" information intact */
1834
+ /* keep the "Backend" information intact, but we had missing ones from v3 */
1835
+ if (data -> version_major <= 2 ) {
1836
+ unsigned i ;
1837
+ /* check if root already has some backend info */
1838
+ for (i = 0 ; i < root -> infos_count ; i ++ )
1839
+ if (!strcmp (root -> infos [i ].name , "Backend" )) {
1840
+ if (!strcmp (root -> infos [i ].value , "CUDA" ))
1841
+ data -> need_cuda_backend_info = 0 ;
1842
+ if (!strcmp (root -> infos [i ].value , "NVML" ))
1843
+ data -> need_nvml_backend_info = 0 ;
1844
+ if (!strcmp (root -> infos [i ].value , "RSMI" ))
1845
+ data -> need_rsmi_backend_info = 0 ;
1846
+ if (!strcmp (root -> infos [i ].value , "LevelZero" ))
1847
+ data -> need_levelzero_backend_info = 0 ;
1848
+ if (!strcmp (root -> infos [i ].value , "OpenCL" ))
1849
+ data -> need_opencl_backend_info = 0 ;
1850
+ if (!strcmp (root -> infos [i ].value , "GL" ))
1851
+ data -> need_gl_backend_info = 0 ;
1852
+ }
1853
+ /* add missing backend info */
1854
+ if (data -> need_cuda_backend_info )
1855
+ hwloc_obj_add_info (root , "Backend" , "CUDA" );
1856
+ if (data -> need_nvml_backend_info )
1857
+ hwloc_obj_add_info (root , "Backend" , "NVML" );
1858
+ if (data -> need_rsmi_backend_info )
1859
+ hwloc_obj_add_info (root , "Backend" , "RSMI" );
1860
+ if (data -> need_levelzero_backend_info )
1861
+ hwloc_obj_add_info (root , "Backend" , "LevelZero" );
1862
+ if (data -> need_opencl_backend_info )
1863
+ hwloc_obj_add_info (root , "Backend" , "OpenCL" );
1864
+ if (data -> need_gl_backend_info )
1865
+ hwloc_obj_add_info (root , "Backend" , "GL" );
1866
+ }
1809
1867
/* we could add "BackendSource=XML" to notify that XML was used between the actual backend and here */
1810
1868
1811
1869
if (!(topology -> flags & HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT )) {
0 commit comments