@@ -189,7 +189,7 @@ int opal_hwloc_base_get_topology(void)
189189 */
190190 if (0 != hwloc_topology_set_flags (opal_hwloc_topology ,
191191 (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
192- #if OPAL_HAVE_HWLOC_OBJ_CACHE
192+ #if HWLOC_API_VERSION < 0x20000
193193 | HWLOC_TOPOLOGY_FLAG_IO_DEVICES
194194#endif
195195 ))) {
@@ -206,7 +206,7 @@ int opal_hwloc_base_get_topology(void)
206206 free (val );
207207 } else if (NULL == opal_hwloc_base_topo_file ) {
208208 if (0 != hwloc_topology_init (& opal_hwloc_topology ) ||
209- #if OPAL_HAVE_HWLOC_OBJ_CACHE
209+ #if HWLOC_API_VERSION < 0x20000
210210 0 != hwloc_topology_set_flags (opal_hwloc_topology ,
211211 HWLOC_TOPOLOGY_FLAG_IO_DEVICES ) ||
212212#endif
@@ -255,7 +255,7 @@ int opal_hwloc_base_set_topology(char *topofile)
255255 */
256256 if (0 != hwloc_topology_set_flags (opal_hwloc_topology ,
257257 (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
258- #if OPAL_HAVE_HWLOC_OBJ_CACHE
258+ #if HWLOC_API_VERSION < 0x20000
259259 | HWLOC_TOPOLOGY_FLAG_IO_DEVICES
260260#endif
261261 ))) {
@@ -508,7 +508,7 @@ unsigned int opal_hwloc_base_get_obj_idx(hwloc_topology_t topo,
508508 return data -> idx ;
509509 }
510510
511- #if OPAL_HAVE_HWLOC_OBJ_CACHE
511+ #if HWLOC_API_VERSION < 0x20000
512512 /* determine the number of objects of this type */
513513 if (HWLOC_OBJ_CACHE == obj -> type ) {
514514 cache_level = obj -> attr -> cache .depth ;
@@ -564,7 +564,7 @@ static hwloc_obj_t df_search(hwloc_topology_t topo,
564564 opal_hwloc_obj_data_t * data ;
565565
566566 if (target == start -> type ) {
567- #if OPAL_HAVE_HWLOC_OBJ_CACHE
567+ #if HWLOC_API_VERSION < 0x20000
568568 if (HWLOC_OBJ_CACHE == start -> type && cache_level != start -> attr -> cache .depth ) {
569569 goto notfound ;
570570 }
@@ -675,7 +675,7 @@ unsigned int opal_hwloc_base_get_nbobjs_by_type(hwloc_topology_t topo,
675675 * as these are treated as special cases
676676 */
677677 if (OPAL_HWLOC_LOGICAL == rtype
678- #if OPAL_HAVE_HWLOC_OBJ_CACHE
678+ #if HWLOC_API_VERSION < 0x20000
679679 && HWLOC_OBJ_CACHE != target
680680#endif
681681 ) {
@@ -747,7 +747,7 @@ static hwloc_obj_t df_search_min_bound(hwloc_topology_t topo,
747747 if (0 == (k = opal_hwloc_base_get_npus (topo , start ))) {
748748 goto notfound ;
749749 }
750- #if OPAL_HAVE_HWLOC_OBJ_CACHE
750+ #if HWLOC_API_VERSION < 0x20000
751751 if (HWLOC_OBJ_CACHE == start -> type && cache_level != start -> attr -> cache .depth ) {
752752 goto notfound ;
753753 }
@@ -814,7 +814,7 @@ hwloc_obj_t opal_hwloc_base_find_min_bound_target_under_obj(hwloc_topology_t top
814814 /* again, we have to treat caches differently as
815815 * the levels distinguish them
816816 */
817- #if OPAL_HAVE_HWLOC_OBJ_CACHE
817+ #if HWLOC_API_VERSION < 0x20000
818818 if (HWLOC_OBJ_CACHE == target &&
819819 cache_level < obj -> attr -> cache .depth ) {
820820 goto moveon ;
@@ -832,7 +832,7 @@ hwloc_obj_t opal_hwloc_base_find_min_bound_target_under_obj(hwloc_topology_t top
832832 loc = df_search_min_bound (topo , obj , target , cache_level , & min_bound );
833833
834834 if (NULL != loc ) {
835- #if OPAL_HAVE_HWLOC_OBJ_CACHE
835+ #if HWLOC_API_VERSION < 0x20000
836836 if (HWLOC_OBJ_CACHE == target ) {
837837 OPAL_OUTPUT_VERBOSE ((5 , opal_hwloc_base_framework .framework_output ,
838838 "hwloc:base:min_bound_under_obj found min bound of %u on %s:%u:%u" ,
@@ -870,7 +870,7 @@ hwloc_obj_t opal_hwloc_base_get_obj_by_type(hwloc_topology_t topo,
870870 * as these are treated as special cases
871871 */
872872 if (OPAL_HWLOC_LOGICAL == rtype
873- #if OPAL_HAVE_HWLOC_OBJ_CACHE
873+ #if HWLOC_API_VERSION < 0x20000
874874 && HWLOC_OBJ_CACHE != target
875875#endif
876876 ) {
@@ -1258,7 +1258,7 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
12581258 /* if it isn't one of interest, then ignore it */
12591259 if (HWLOC_OBJ_NODE != type &&
12601260 HWLOC_OBJ_SOCKET != type &&
1261- #if OPAL_HAVE_HWLOC_OBJ_CACHE
1261+ #if HWLOC_API_VERSION < 0x20000
12621262 HWLOC_OBJ_CACHE != type &&
12631263#else
12641264 HWLOC_OBJ_L3CACHE != type &&
@@ -1291,7 +1291,7 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
12911291 case HWLOC_OBJ_SOCKET :
12921292 locality |= OPAL_PROC_ON_SOCKET ;
12931293 break ;
1294- #if OPAL_HAVE_HWLOC_OBJ_CACHE
1294+ #if HWLOC_API_VERSION < 0x20000
12951295 case HWLOC_OBJ_CACHE :
12961296 if (3 == obj -> attr -> cache .depth ) {
12971297 locality |= OPAL_PROC_ON_L3CACHE ;
@@ -1847,13 +1847,14 @@ static void sort_by_dist(hwloc_topology_t topo, char* device_name, opal_list_t *
18471847{
18481848 hwloc_obj_t device_obj = NULL ;
18491849 hwloc_obj_t obj = NULL , root = NULL ;
1850- const struct hwloc_distances_s * distances ;
1850+ struct hwloc_distances_s * distances ;
18511851 opal_rmaps_numa_node_t * numa_node ;
18521852 int close_node_index ;
18531853 float latency ;
18541854 unsigned int j ;
18551855 int depth ;
18561856 unsigned i ;
1857+ unsigned distances_nr = 0 ;
18571858
18581859 for (device_obj = hwloc_get_obj_by_type (topo , HWLOC_OBJ_OS_DEVICE , 0 ); device_obj ; device_obj = hwloc_get_next_osdev (topo , device_obj )) {
18591860 if (device_obj -> attr -> osdev .type == HWLOC_OBJ_OSDEV_OPENFABRICS
@@ -1874,6 +1875,7 @@ static void sort_by_dist(hwloc_topology_t topo, char* device_name, opal_list_t *
18741875 }
18751876
18761877 /* find distance matrix for all numa nodes */
1878+ #if HWLOC_API_VERSION < 0x20000
18771879 distances = hwloc_get_whole_distance_matrix_by_type (topo , HWLOC_OBJ_NODE );
18781880 if (NULL == distances ) {
18791881 /* we can try to find distances under group object. This info can be there. */
@@ -1910,6 +1912,22 @@ static void sort_by_dist(hwloc_topology_t topo, char* device_name, opal_list_t *
19101912 numa_node -> dist_from_closed = latency ;
19111913 opal_list_append (sorted_list , & numa_node -> super );
19121914 }
1915+ #else
1916+ if (0 != hwloc_distances_get_by_type (topo , HWLOC_OBJ_NODE , & distances_nr , & distances , 0 , 0 ) || 0 == distances_nr ) {
1917+ opal_output_verbose (5 , opal_hwloc_base_framework .framework_output ,
1918+ "hwloc:base:get_sorted_numa_list: There is no information about distances on the node." );
1919+ return ;
1920+ }
1921+ /* fill list of numa nodes */
1922+ for (j = 0 ; j < distances -> nbobjs ; j ++ ) {
1923+ latency = distances -> values [close_node_index + distances -> nbobjs * j ];
1924+ numa_node = OBJ_NEW (opal_rmaps_numa_node_t );
1925+ numa_node -> index = j ;
1926+ numa_node -> dist_from_closed = latency ;
1927+ opal_list_append (sorted_list , & numa_node -> super );
1928+ }
1929+ hwloc_distances_release (topo , distances );
1930+ #endif
19131931 /* sort numa nodes by distance from the closest one to PCI */
19141932 opal_list_sort (sorted_list , dist_cmp_fn );
19151933 return ;
@@ -2067,7 +2085,7 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
20672085 /* if it isn't one of interest, then ignore it */
20682086 if (HWLOC_OBJ_NODE != type &&
20692087 HWLOC_OBJ_SOCKET != type &&
2070- #if OPAL_HAVE_HWLOC_OBJ_CACHE
2088+ #if HWLOC_API_VERSION < 0x20000
20712089 HWLOC_OBJ_CACHE != type &&
20722090#else
20732091 HWLOC_OBJ_L1CACHE != type &&
@@ -2115,7 +2133,7 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
21152133 }
21162134 locality = t2 ;
21172135 break ;
2118- #if OPAL_HAVE_HWLOC_OBJ_CACHE
2136+ #if HWLOC_API_VERSION < 0x20000
21192137 case HWLOC_OBJ_CACHE :
21202138 if (3 == obj -> attr -> cache .depth ) {
21212139 asprintf (& t2 , "%sL3%s:" , (NULL == locality ) ? "" : locality , tmp );
@@ -2213,7 +2231,7 @@ char* opal_hwloc_base_get_location(char *locality,
22132231 case HWLOC_OBJ_SOCKET :
22142232 srch = "SK" ;
22152233 break ;
2216- #if OPAL_HAVE_HWLOC_OBJ_CACHE
2234+ #if HWLOC_API_VERSION < 0x20000
22172235 case HWLOC_OBJ_CACHE :
22182236 if (3 == index ) {
22192237 srch = "L3" ;
@@ -2321,7 +2339,7 @@ opal_hwloc_locality_t opal_hwloc_compute_relative_locality(char *loc1, char *loc
23212339}
23222340
23232341int opal_hwloc_base_topology_export_xmlbuffer (hwloc_topology_t topology , char * * xmlpath , int * buflen ) {
2324- #if OPAL_HAVE_HWLOC_OBJ_CACHE
2342+ #if HWLOC_API_VERSION < 0x20000
23252343 return hwloc_topology_export_xmlbuffer (topology , xmlpath , buflen );
23262344#else
23272345 return hwloc_topology_export_xmlbuffer (topology , xmlpath , buflen , 0 );
0 commit comments