@@ -111,6 +111,7 @@ static void fill_cache_line_size(void)
111
111
{
112
112
int i = 0 , cache_level = 2 ;
113
113
unsigned size ;
114
+ unsigned int cache_object = HWLOC_OBJ_L2CACHE ;
114
115
hwloc_obj_t obj ;
115
116
bool found = false;
116
117
@@ -120,10 +121,11 @@ static void fill_cache_line_size(void)
120
121
i = 0 ;
121
122
while (1 ) {
122
123
obj = opal_hwloc_base_get_obj_by_type (opal_hwloc_topology ,
123
- HWLOC_OBJ_CACHE , cache_level ,
124
+ cache_object , cache_level ,
124
125
i , OPAL_HWLOC_LOGICAL );
125
126
if (NULL == obj ) {
126
127
-- cache_level ;
128
+ cache_object = HWLOC_OBJ_L1CACHE ;
127
129
break ;
128
130
} else {
129
131
if (NULL != obj -> attr &&
@@ -186,9 +188,11 @@ int opal_hwloc_base_get_topology(void)
186
188
* explicitly set a flag so hwloc sets things up correctly
187
189
*/
188
190
if (0 != hwloc_topology_set_flags (opal_hwloc_topology ,
189
- (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
190
- HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM |
191
- HWLOC_TOPOLOGY_FLAG_IO_DEVICES ))) {
191
+ (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
192
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
193
+ | HWLOC_TOPOLOGY_FLAG_IO_DEVICES
194
+ #endif
195
+ ))) {
192
196
hwloc_topology_destroy (opal_hwloc_topology );
193
197
free (val );
194
198
return OPAL_ERROR ;
@@ -202,8 +206,10 @@ int opal_hwloc_base_get_topology(void)
202
206
free (val );
203
207
} else if (NULL == opal_hwloc_base_topo_file ) {
204
208
if (0 != hwloc_topology_init (& opal_hwloc_topology ) ||
209
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
205
210
0 != hwloc_topology_set_flags (opal_hwloc_topology ,
206
211
HWLOC_TOPOLOGY_FLAG_IO_DEVICES ) ||
212
+ #endif
207
213
0 != hwloc_topology_load (opal_hwloc_topology )) {
208
214
return OPAL_ERR_NOT_SUPPORTED ;
209
215
}
@@ -248,8 +254,11 @@ int opal_hwloc_base_set_topology(char *topofile)
248
254
* explicitly set a flag so hwloc sets things up correctly
249
255
*/
250
256
if (0 != hwloc_topology_set_flags (opal_hwloc_topology ,
251
- (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
252
- HWLOC_TOPOLOGY_FLAG_IO_DEVICES ))) {
257
+ (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
258
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
259
+ | HWLOC_TOPOLOGY_FLAG_IO_DEVICES
260
+ #endif
261
+ ))) {
253
262
hwloc_topology_destroy (opal_hwloc_topology );
254
263
return OPAL_ERR_NOT_SUPPORTED ;
255
264
}
@@ -499,10 +508,13 @@ unsigned int opal_hwloc_base_get_obj_idx(hwloc_topology_t topo,
499
508
return data -> idx ;
500
509
}
501
510
511
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
502
512
/* determine the number of objects of this type */
503
513
if (HWLOC_OBJ_CACHE == obj -> type ) {
504
514
cache_level = obj -> attr -> cache .depth ;
505
515
}
516
+ #endif
517
+
506
518
nobjs = opal_hwloc_base_get_nbobjs_by_type (topo , obj -> type , cache_level , rtype );
507
519
508
520
OPAL_OUTPUT_VERBOSE ((5 , opal_hwloc_base_framework .framework_output ,
@@ -552,9 +564,11 @@ static hwloc_obj_t df_search(hwloc_topology_t topo,
552
564
opal_hwloc_obj_data_t * data ;
553
565
554
566
if (target == start -> type ) {
567
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
555
568
if (HWLOC_OBJ_CACHE == start -> type && cache_level != start -> attr -> cache .depth ) {
556
569
goto notfound ;
557
570
}
571
+ #endif
558
572
if (OPAL_HWLOC_LOGICAL == rtype ) {
559
573
/* the hwloc tree is composed of LOGICAL objects, so the only
560
574
* time we come here is when we are looking for logical caches
@@ -660,7 +674,11 @@ unsigned int opal_hwloc_base_get_nbobjs_by_type(hwloc_topology_t topo,
660
674
* use the hwloc accessor to get it, unless it is a CACHE
661
675
* as these are treated as special cases
662
676
*/
663
- if (OPAL_HWLOC_LOGICAL == rtype && HWLOC_OBJ_CACHE != target ) {
677
+ if (OPAL_HWLOC_LOGICAL == rtype
678
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
679
+ && HWLOC_OBJ_CACHE != target
680
+ #endif
681
+ ) {
664
682
/* we should not get an error back, but just in case... */
665
683
if (0 > (rc = hwloc_get_nbobjs_by_type (topo , target ))) {
666
684
opal_output (0 , "UNKNOWN HWLOC ERROR" );
@@ -729,9 +747,11 @@ static hwloc_obj_t df_search_min_bound(hwloc_topology_t topo,
729
747
if (0 == (k = opal_hwloc_base_get_npus (topo , start ))) {
730
748
goto notfound ;
731
749
}
750
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
732
751
if (HWLOC_OBJ_CACHE == start -> type && cache_level != start -> attr -> cache .depth ) {
733
752
goto notfound ;
734
753
}
754
+ #endif
735
755
/* see how many procs are bound to us */
736
756
data = (opal_hwloc_obj_data_t * )start -> userdata ;
737
757
if (NULL == data ) {
@@ -794,10 +814,12 @@ hwloc_obj_t opal_hwloc_base_find_min_bound_target_under_obj(hwloc_topology_t top
794
814
/* again, we have to treat caches differently as
795
815
* the levels distinguish them
796
816
*/
817
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
797
818
if (HWLOC_OBJ_CACHE == target &&
798
819
cache_level < obj -> attr -> cache .depth ) {
799
820
goto moveon ;
800
821
}
822
+ #endif
801
823
return obj ;
802
824
}
803
825
@@ -810,16 +832,17 @@ hwloc_obj_t opal_hwloc_base_find_min_bound_target_under_obj(hwloc_topology_t top
810
832
loc = df_search_min_bound (topo , obj , target , cache_level , & min_bound );
811
833
812
834
if (NULL != loc ) {
835
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
813
836
if (HWLOC_OBJ_CACHE == target ) {
814
837
OPAL_OUTPUT_VERBOSE ((5 , opal_hwloc_base_framework .framework_output ,
815
838
"hwloc:base:min_bound_under_obj found min bound of %u on %s:%u:%u" ,
816
839
min_bound , hwloc_obj_type_string (target ),
817
840
cache_level , loc -> logical_index ));
818
- } else {
841
+ } else
842
+ #endif
819
843
OPAL_OUTPUT_VERBOSE ((5 , opal_hwloc_base_framework .framework_output ,
820
844
"hwloc:base:min_bound_under_obj found min bound of %u on %s:%u" ,
821
845
min_bound , hwloc_obj_type_string (target ), loc -> logical_index ));
822
- }
823
846
}
824
847
825
848
return loc ;
@@ -846,7 +869,11 @@ hwloc_obj_t opal_hwloc_base_get_obj_by_type(hwloc_topology_t topo,
846
869
* use the hwloc accessor to get it, unless it is a CACHE
847
870
* as these are treated as special cases
848
871
*/
849
- if (OPAL_HWLOC_LOGICAL == rtype && HWLOC_OBJ_CACHE != target ) {
872
+ if (OPAL_HWLOC_LOGICAL == rtype
873
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
874
+ && HWLOC_OBJ_CACHE != target
875
+ #endif
876
+ ) {
850
877
return hwloc_get_obj_by_type (topo , target , instance );
851
878
}
852
879
@@ -1231,7 +1258,13 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
1231
1258
/* if it isn't one of interest, then ignore it */
1232
1259
if (HWLOC_OBJ_NODE != type &&
1233
1260
HWLOC_OBJ_SOCKET != type &&
1261
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
1234
1262
HWLOC_OBJ_CACHE != type &&
1263
+ #else
1264
+ HWLOC_OBJ_L3CACHE != type &&
1265
+ HWLOC_OBJ_L2CACHE != type &&
1266
+ HWLOC_OBJ_L1CACHE != type &&
1267
+ #endif
1235
1268
HWLOC_OBJ_CORE != type &&
1236
1269
HWLOC_OBJ_PU != type ) {
1237
1270
continue ;
@@ -1258,6 +1291,7 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
1258
1291
case HWLOC_OBJ_SOCKET :
1259
1292
locality |= OPAL_PROC_ON_SOCKET ;
1260
1293
break ;
1294
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
1261
1295
case HWLOC_OBJ_CACHE :
1262
1296
if (3 == obj -> attr -> cache .depth ) {
1263
1297
locality |= OPAL_PROC_ON_L3CACHE ;
@@ -1267,6 +1301,17 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
1267
1301
locality |= OPAL_PROC_ON_L1CACHE ;
1268
1302
}
1269
1303
break ;
1304
+ #else
1305
+ case HWLOC_OBJ_L3CACHE :
1306
+ locality |= OPAL_PROC_ON_L3CACHE ;
1307
+ break ;
1308
+ case HWLOC_OBJ_L2CACHE :
1309
+ locality |= OPAL_PROC_ON_L2CACHE ;
1310
+ break ;
1311
+ case HWLOC_OBJ_L1CACHE :
1312
+ locality |= OPAL_PROC_ON_L1CACHE ;
1313
+ break ;
1314
+ #endif
1270
1315
case HWLOC_OBJ_CORE :
1271
1316
locality |= OPAL_PROC_ON_CORE ;
1272
1317
break ;
@@ -1961,9 +2006,9 @@ char* opal_hwloc_base_get_topo_signature(hwloc_topology_t topo)
1961
2006
1962
2007
nnuma = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_NODE , 0 , OPAL_HWLOC_AVAILABLE );
1963
2008
nsocket = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_SOCKET , 0 , OPAL_HWLOC_AVAILABLE );
1964
- nl3 = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_CACHE , 3 , OPAL_HWLOC_AVAILABLE );
1965
- nl2 = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_CACHE , 2 , OPAL_HWLOC_AVAILABLE );
1966
- nl1 = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_CACHE , 1 , OPAL_HWLOC_AVAILABLE );
2009
+ nl3 = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_L3CACHE , 3 , OPAL_HWLOC_AVAILABLE );
2010
+ nl2 = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_L2CACHE , 2 , OPAL_HWLOC_AVAILABLE );
2011
+ nl1 = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_L1CACHE , 1 , OPAL_HWLOC_AVAILABLE );
1967
2012
ncore = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_CORE , 0 , OPAL_HWLOC_AVAILABLE );
1968
2013
nhwt = opal_hwloc_base_get_nbobjs_by_type (topo , HWLOC_OBJ_PU , 0 , OPAL_HWLOC_AVAILABLE );
1969
2014
@@ -2022,7 +2067,13 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
2022
2067
/* if it isn't one of interest, then ignore it */
2023
2068
if (HWLOC_OBJ_NODE != type &&
2024
2069
HWLOC_OBJ_SOCKET != type &&
2070
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
2025
2071
HWLOC_OBJ_CACHE != type &&
2072
+ #else
2073
+ HWLOC_OBJ_L1CACHE != type &&
2074
+ HWLOC_OBJ_L2CACHE != type &&
2075
+ HWLOC_OBJ_L3CACHE != type &&
2076
+ #endif
2026
2077
HWLOC_OBJ_CORE != type &&
2027
2078
HWLOC_OBJ_PU != type ) {
2028
2079
continue ;
@@ -2064,6 +2115,7 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
2064
2115
}
2065
2116
locality = t2 ;
2066
2117
break ;
2118
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
2067
2119
case HWLOC_OBJ_CACHE :
2068
2120
if (3 == obj -> attr -> cache .depth ) {
2069
2121
asprintf (& t2 , "%sL3%s:" , (NULL == locality ) ? "" : locality , tmp );
@@ -2088,6 +2140,29 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
2088
2140
break ;
2089
2141
}
2090
2142
break ;
2143
+ #else
2144
+ case HWLOC_OBJ_L3CACHE :
2145
+ asprintf (& t2 , "%sL3%s:" , (NULL == locality ) ? "" : locality , tmp );
2146
+ if (NULL != locality ) {
2147
+ free (locality );
2148
+ }
2149
+ locality = t2 ;
2150
+ break ;
2151
+ case HWLOC_OBJ_L2CACHE :
2152
+ asprintf (& t2 , "%sL2%s:" , (NULL == locality ) ? "" : locality , tmp );
2153
+ if (NULL != locality ) {
2154
+ free (locality );
2155
+ }
2156
+ locality = t2 ;
2157
+ break ;
2158
+ case HWLOC_OBJ_L1CACHE :
2159
+ asprintf (& t2 , "%sL1%s:" , (NULL == locality ) ? "" : locality , tmp );
2160
+ if (NULL != locality ) {
2161
+ free (locality );
2162
+ }
2163
+ locality = t2 ;
2164
+ break ;
2165
+ #endif
2091
2166
case HWLOC_OBJ_CORE :
2092
2167
asprintf (& t2 , "%sCR%s:" , (NULL == locality ) ? "" : locality , tmp );
2093
2168
if (NULL != locality ) {
@@ -2138,6 +2213,7 @@ char* opal_hwloc_base_get_location(char *locality,
2138
2213
case HWLOC_OBJ_SOCKET :
2139
2214
srch = "SK" ;
2140
2215
break ;
2216
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
2141
2217
case HWLOC_OBJ_CACHE :
2142
2218
if (3 == index ) {
2143
2219
srch = "L3" ;
@@ -2147,6 +2223,17 @@ char* opal_hwloc_base_get_location(char *locality,
2147
2223
srch = "L0" ;
2148
2224
}
2149
2225
break ;
2226
+ #else
2227
+ case HWLOC_OBJ_L3CACHE :
2228
+ srch = "L3" ;
2229
+ break ;
2230
+ case HWLOC_OBJ_L2CACHE :
2231
+ srch = "L2" ;
2232
+ break ;
2233
+ case HWLOC_OBJ_L1CACHE :
2234
+ srch = "L0" ;
2235
+ break ;
2236
+ #endif
2150
2237
case HWLOC_OBJ_CORE :
2151
2238
srch = "CR" ;
2152
2239
break ;
@@ -2232,3 +2319,12 @@ opal_hwloc_locality_t opal_hwloc_compute_relative_locality(char *loc1, char *loc
2232
2319
hwloc_bitmap_free (bit2 );
2233
2320
return locality ;
2234
2321
}
2322
+
2323
+ int opal_hwloc_base_topology_export_xmlbuffer (hwloc_topology_t topology , char * * xmlpath , int * buflen ) {
2324
+ #if OPAL_HAVE_HWLOC_OBJ_CACHE
2325
+ return hwloc_topology_export_xmlbuffer (topology , xmlpath , buflen );
2326
+ #else
2327
+ return hwloc_topology_export_xmlbuffer (topology , xmlpath , buflen , 0 );
2328
+ #endif
2329
+ }
2330
+
0 commit comments