60
60
#include "pmix_common.h"
61
61
62
62
#include "pmix_hwloc.h"
63
- #if HWLOC_API_VERSION >= 0x20000
64
- # include <hwloc/shmem.h>
65
- #endif
63
+ #include <hwloc/shmem.h>
66
64
67
65
static bool topo_in_shmem = false;
68
66
static bool passed_thru = false;
@@ -73,7 +71,6 @@ static char *testcpuset = NULL;
73
71
static int pmix_hwloc_output = -1 ;
74
72
static int pmix_hwloc_verbose = 0 ;
75
73
76
- #if HWLOC_API_VERSION >= 0x20000
77
74
static size_t shmemsize = 0 ;
78
75
static size_t shmemaddr ;
79
76
static char * shmemfile = NULL ;
@@ -83,13 +80,10 @@ static uint64_t amount_space_avail = 0;
83
80
84
81
static int enough_space (const char * filename , size_t space_req , uint64_t * space_avail ,
85
82
bool * result );
86
- #endif
87
83
static pmix_status_t load_xml (char * xml );
88
84
static char * popstr (pmix_cb_t * cb );
89
- #if HWLOC_API_VERSION >= 0x20000
90
85
static size_t popsize (pmix_cb_t * cb );
91
86
static void print_maps (void );
92
- #endif
93
87
static pmix_topology_t * popptr (pmix_cb_t * cb );
94
88
static int get_locality_string_by_depth (int d , hwloc_cpuset_t cpuset , hwloc_cpuset_t result );
95
89
static int set_flags (hwloc_topology_t topo , unsigned int flags );
@@ -141,15 +135,13 @@ pmix_status_t pmix_hwloc_register(void)
141
135
142
136
void pmix_hwloc_finalize (void )
143
137
{
144
- #if HWLOC_API_VERSION >= 0x20000
145
138
if (NULL != shmemfile ) {
146
139
unlink (shmemfile );
147
140
free (shmemfile );
148
141
}
149
142
if (0 <= shmemfd ) {
150
143
close (shmemfd );
151
144
}
152
- #endif
153
145
if (NULL != pmix_globals .topology .topology && !pmix_globals .external_topology
154
146
&& !topo_in_shmem ) {
155
147
hwloc_topology_destroy (pmix_globals .topology .topology );
@@ -229,7 +221,6 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
229
221
PMIX_LOAD_PROCID (& wildcard , pmix_globals .myid .nspace , PMIX_RANK_WILDCARD );
230
222
231
223
/* try to get it ourselves */
232
- #if HWLOC_API_VERSION >= 0x20000
233
224
int fd ;
234
225
uint64_t addr , size ;
235
226
@@ -285,11 +276,7 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
285
276
pmix_output_verbose (2 , pmix_hwloc_output , "%s:%s shmem adopted" ,
286
277
__FILE__ , __func__ );
287
278
/* got it - we are done */
288
- # ifdef HWLOC_VERSION
289
279
pmix_asprintf (& pmix_globals .topology .source , "hwloc:%s" , HWLOC_VERSION );
290
- # else
291
- pmix_globals .topology .source = strdup ("hwloc" );
292
- # endif
293
280
/* record locally in case someone does a PMIx_Get to retrieve it */
294
281
kv .key = PMIX_TOPOLOGY2 ;
295
282
kv .value = & val ;
@@ -351,7 +338,6 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
351
338
}
352
339
353
340
tryv1 :
354
- #endif
355
341
356
342
/* try to get the v1 XML string */
357
343
pmix_output_verbose (2 , pmix_hwloc_output ,
@@ -439,11 +425,7 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
439
425
hwloc_topology_destroy (pmix_globals .topology .topology );
440
426
return PMIX_ERR_NOT_SUPPORTED ;
441
427
}
442
- #ifdef HWLOC_VERSION
443
428
pmix_asprintf (& pmix_globals .topology .source , "hwloc:%s" , HWLOC_VERSION );
444
- #else
445
- pmix_globals .topology .source = strdup ("hwloc" );
446
- #endif
447
429
pmix_output_verbose (2 , pmix_hwloc_output ,
448
430
"%s:%s discovery complete - source %s" , __FILE__ , __func__ ,
449
431
pmix_globals .topology .source );
@@ -469,33 +451,6 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
469
451
"%s:%s sharing topology" ,
470
452
__FILE__ , __func__ );
471
453
472
- #if HWLOC_API_VERSION < 0x20000
473
- /* pass the topology string as we don't
474
- * have HWLOC shared memory available - we do
475
- * this so the procs won't read the topology
476
- * themselves as this could overwhelm the local
477
- * system on large-scale SMPs */
478
- if (0 == hwloc_topology_export_xmlbuffer (pmix_globals .topology .topology , & xmlbuffer , & len )) {
479
- pmix_output_verbose (2 , pmix_hwloc_output ,
480
- "%s:%s export v1 xml" ,
481
- __FILE__ , __func__ );
482
- kptr = PMIX_NEW (pmix_kval_t );
483
- kptr -> key = strdup (PMIX_HWLOC_XML_V1 );
484
- kptr -> value = (pmix_value_t * ) malloc (sizeof (pmix_value_t ));
485
- PMIX_VALUE_LOAD (kptr -> value , xmlbuffer , PMIX_STRING );
486
- pmix_list_append (& pmix_server_globals .gdata , & kptr -> super );
487
- /* save it with the deprecated key for older RMs */
488
- kptr = PMIX_NEW (pmix_kval_t );
489
- kptr -> key = strdup (PMIX_LOCAL_TOPO );
490
- kptr -> value = (pmix_value_t * ) malloc (sizeof (pmix_value_t ));
491
- PMIX_VALUE_LOAD (kptr -> value , xmlbuffer , PMIX_STRING );
492
- pmix_list_append (& pmix_server_globals .gdata , & kptr -> super );
493
- /* done with the buffer */
494
- hwloc_free_xmlbuffer (pmix_globals .topology .topology , xmlbuffer );
495
- }
496
- /* we don't have the ability to do shared memory, so we are done */
497
- return PMIX_SUCCESS ;
498
- #else
499
454
/* pass the topology as a v2 xml string */
500
455
if (0 == hwloc_topology_export_xmlbuffer (pmix_globals .topology .topology , & xmlbuffer , & len , 0 )) {
501
456
pmix_output_verbose (2 , pmix_hwloc_output , "%s:%s export v2 xml" ,
@@ -624,8 +579,6 @@ pmix_status_t pmix_hwloc_setup_topology(pmix_info_t *info, size_t ninfo)
624
579
PMIX_VALUE_LOAD (kptr -> value , & shmemsize , PMIX_SIZE );
625
580
pmix_list_append (& pmix_server_globals .gdata , & kptr -> super );
626
581
627
- #endif
628
-
629
582
return PMIX_SUCCESS ;
630
583
}
631
584
@@ -790,11 +743,7 @@ pmix_status_t pmix_hwloc_generate_locality_string(const pmix_cpuset_t *cpuset, c
790
743
type = hwloc_get_depth_type (pmix_globals .topology .topology , d );
791
744
/* if it isn't one of interest, then ignore it */
792
745
if (HWLOC_OBJ_NUMANODE != type && HWLOC_OBJ_PACKAGE != type &&
793
- #if HWLOC_API_VERSION < 0x20000
794
- HWLOC_OBJ_CACHE != type &&
795
- #else
796
746
HWLOC_OBJ_L1CACHE != type && HWLOC_OBJ_L2CACHE != type && HWLOC_OBJ_L3CACHE != type &&
797
- #endif
798
747
HWLOC_OBJ_CORE != type && HWLOC_OBJ_PU != type ) {
799
748
continue ;
800
749
}
@@ -822,34 +771,6 @@ pmix_status_t pmix_hwloc_generate_locality_string(const pmix_cpuset_t *cpuset, c
822
771
}
823
772
locality = t2 ;
824
773
break ;
825
- #if HWLOC_API_VERSION < 0x20000
826
- case HWLOC_OBJ_CACHE : {
827
- unsigned cachedepth = hwloc_get_obj_by_depth (pmix_globals .topology .topology , d , 0 )
828
- -> attr -> cache .depth ;
829
- if (3 == cachedepth ) {
830
- pmix_asprintf (& t2 , "%sL3%s:" , (NULL == locality ) ? "" : locality , tmp );
831
- if (NULL != locality ) {
832
- free (locality );
833
- }
834
- locality = t2 ;
835
- break ;
836
- } else if (2 == cachedepth ) {
837
- pmix_asprintf (& t2 , "%sL2%s:" , (NULL == locality ) ? "" : locality , tmp );
838
- if (NULL != locality ) {
839
- free (locality );
840
- }
841
- locality = t2 ;
842
- break ;
843
- } else {
844
- pmix_asprintf (& t2 , "%sL1%s:" , (NULL == locality ) ? "" : locality , tmp );
845
- if (NULL != locality ) {
846
- free (locality );
847
- }
848
- locality = t2 ;
849
- break ;
850
- }
851
- } break ;
852
- #else
853
774
case HWLOC_OBJ_L3CACHE :
854
775
pmix_asprintf (& t2 , "%sL3%s:" , (NULL == locality ) ? "" : locality , tmp );
855
776
if (NULL != locality ) {
@@ -871,7 +792,6 @@ pmix_status_t pmix_hwloc_generate_locality_string(const pmix_cpuset_t *cpuset, c
871
792
}
872
793
locality = t2 ;
873
794
break ;
874
- #endif
875
795
case HWLOC_OBJ_CORE :
876
796
pmix_asprintf (& t2 , "%sCR%s:" , (NULL == locality ) ? "" : locality , tmp );
877
797
if (NULL != locality ) {
@@ -895,7 +815,6 @@ pmix_status_t pmix_hwloc_generate_locality_string(const pmix_cpuset_t *cpuset, c
895
815
hwloc_bitmap_zero (result );
896
816
}
897
817
898
- #if HWLOC_API_VERSION >= 0x20000
899
818
if (get_locality_string_by_depth (HWLOC_TYPE_DEPTH_NUMANODE , cpuset -> bitmap , result ) == 0 ) {
900
819
/* it should be impossible, but allow for the possibility
901
820
* that we came up empty at this depth */
@@ -910,7 +829,6 @@ pmix_status_t pmix_hwloc_generate_locality_string(const pmix_cpuset_t *cpuset, c
910
829
}
911
830
hwloc_bitmap_zero (result );
912
831
}
913
- #endif
914
832
915
833
hwloc_bitmap_free (result );
916
834
@@ -1082,9 +1000,7 @@ static pmix_type_conversion_t table[] = {
1082
1000
{.hwtype = HWLOC_OBJ_OSDEV_NETWORK , .pxtype = PMIX_DEVTYPE_NETWORK , .name = "NETWORK" },
1083
1001
{.hwtype = HWLOC_OBJ_OSDEV_OPENFABRICS , .pxtype = PMIX_DEVTYPE_OPENFABRICS , .name = "OPENFABRICS" },
1084
1002
{.hwtype = HWLOC_OBJ_OSDEV_DMA , .pxtype = PMIX_DEVTYPE_DMA , .name = "DMA" },
1085
- #if HWLOC_API_VERSION >= 0x00010800
1086
1003
{.hwtype = HWLOC_OBJ_OSDEV_COPROC , .pxtype = PMIX_DEVTYPE_COPROC , .name = "COPROCESSOR" },
1087
- #endif
1088
1004
};
1089
1005
1090
1006
static int countcolons (char * str )
@@ -1189,9 +1105,7 @@ pmix_status_t pmix_hwloc_compute_distances(pmix_topology_t *topo, pmix_cpuset_t
1189
1105
continue ;
1190
1106
}
1191
1107
if (HWLOC_OBJ_OSDEV_BLOCK == table [n ].hwtype || HWLOC_OBJ_OSDEV_DMA == table [n ].hwtype
1192
- #if HWLOC_API_VERSION >= 0x00010800
1193
1108
|| HWLOC_OBJ_OSDEV_COPROC == table [n ].hwtype
1194
- #endif
1195
1109
) {
1196
1110
continue ;
1197
1111
}
@@ -1394,29 +1308,20 @@ pmix_status_t pmix_hwloc_check_vendor(pmix_topology_t *topo,
1394
1308
1395
1309
static int set_flags (hwloc_topology_t topo , unsigned int flags )
1396
1310
{
1397
- #if HWLOC_API_VERSION < 0x20000
1398
- flags = HWLOC_TOPOLOGY_FLAG_IO_DEVICES ;
1399
- #else
1400
1311
int ret = hwloc_topology_set_io_types_filter (topo , HWLOC_TYPE_FILTER_KEEP_IMPORTANT );
1401
- if (0 != ret )
1312
+ if (0 != ret ) {
1402
1313
return ret ;
1403
- #endif
1314
+ }
1404
1315
if (0 != hwloc_topology_set_flags (topo , flags )) {
1405
1316
return PMIX_ERR_INIT ;
1406
1317
}
1407
- #ifdef HWLOC_VERSION_MAJOR
1408
1318
// Blacklist the "gl" component due to potential conflicts.
1409
1319
// See "https://github.com/open-mpi/ompi/issues/10025" for
1410
1320
// an explanation. Sadly, HWLOC doesn't define version numbers
1411
1321
// until v2.0, so we cannot check versions here. Fortunately,
1412
1322
// the blacklist ability was added in HWLOC v2.1, so we can't
1413
1323
// do it for earlier versions anyway.
1414
- #if HWLOC_VERSION_MAJOR > 2
1415
- hwloc_topology_set_components (topo , HWLOC_TOPOLOGY_COMPONENTS_FLAG_BLACKLIST , "gl" );
1416
- #elif HWLOC_VERSION_MAJOR == 2 && HWLOC_VERSION_MINOR >= 1
1417
1324
hwloc_topology_set_components (topo , HWLOC_TOPOLOGY_COMPONENTS_FLAG_BLACKLIST , "gl" );
1418
- #endif
1419
- #endif
1420
1325
1421
1326
return PMIX_SUCCESS ;
1422
1327
}
@@ -1444,7 +1349,6 @@ static char *popstr(pmix_cb_t *cb)
1444
1349
return str ;
1445
1350
}
1446
1351
1447
- #if HWLOC_API_VERSION >= 0x20000
1448
1352
static size_t popsize (pmix_cb_t * cb )
1449
1353
{
1450
1354
pmix_list_t * kvs = & cb -> kvs ;
@@ -1466,7 +1370,6 @@ static size_t popsize(pmix_cb_t *cb)
1466
1370
}
1467
1371
return sz ;
1468
1372
}
1469
- #endif
1470
1373
1471
1374
static pmix_topology_t * popptr (pmix_cb_t * cb )
1472
1375
{
@@ -1517,7 +1420,6 @@ static pmix_status_t load_xml(char *xml)
1517
1420
return PMIX_SUCCESS ;
1518
1421
}
1519
1422
1520
- #if HWLOC_API_VERSION >= 0x20000
1521
1423
static void print_maps (void )
1522
1424
{
1523
1425
@@ -1535,7 +1437,6 @@ static void print_maps(void)
1535
1437
fclose (maps_file );
1536
1438
}
1537
1439
}
1538
- #endif
1539
1440
1540
1441
static int get_locality_string_by_depth (int d , hwloc_cpuset_t cpuset , hwloc_cpuset_t result )
1541
1442
{
@@ -1563,7 +1464,6 @@ static int get_locality_string_by_depth(int d, hwloc_cpuset_t cpuset, hwloc_cpus
1563
1464
return 0 ;
1564
1465
}
1565
1466
1566
- #if HWLOC_API_VERSION >= 0x20000
1567
1467
static int enough_space (const char * filename , size_t space_req , uint64_t * space_avail , bool * result )
1568
1468
{
1569
1469
uint64_t avail = 0 ;
@@ -1599,4 +1499,3 @@ static int enough_space(const char *filename, size_t space_req, uint64_t *space_
1599
1499
* space_avail = avail ;
1600
1500
return rc ;
1601
1501
}
1602
- #endif
0 commit comments