Skip to content

Commit 60aa9cf

Browse files
committed
hwloc: add support for hwloc v2 API
Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 9f29f3b commit 60aa9cf

File tree

14 files changed

+233
-82
lines changed

14 files changed

+233
-82
lines changed

ompi/mca/topo/treematch/treematch/tm_hwloc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ tm_topology_t* hwloc_to_tm(char *filename,double **pcost)
159159
exit(-1);
160160
}
161161

162+
#if HWLOC_API_VERSION < 0x20000
162163
hwloc_topology_ignore_all_keep_structure(topology);
164+
#else
165+
#warning FIXME hwloc v2
166+
#endif
163167
hwloc_topology_load(topology);
164168

165169

@@ -229,7 +233,11 @@ tm_topology_t* get_local_topo_with_hwloc(void)
229233

230234
/* Build the topology */
231235
hwloc_topology_init(&topology);
236+
#if HWLOC_API_VERSION < 0x20000
232237
hwloc_topology_ignore_all_keep_structure(topology);
238+
#else
239+
#warning FIXME hwloc v2
240+
#endif
233241
hwloc_topology_load(topology);
234242

235243
/* Test if symetric */

opal/mca/btl/openib/btl_openib_component.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Copyright (c) 2011-2015 NVIDIA Corporation. All rights reserved.
2020
* Copyright (c) 2012 Oak Ridge National Laboratory. All rights reserved
2121
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
22-
* Copyright (c) 2014-2016 Research Organization for Information Science
22+
* Copyright (c) 2014-2017 Research Organization for Information Science
2323
* and Technology (RIST). All rights reserved.
2424
* Copyright (c) 2014 Bull SAS. All rights reserved.
2525
* $COPYRIGHT$
@@ -2331,6 +2331,7 @@ static float get_ib_dev_distance(struct ibv_device *dev)
23312331
because we have no way of measuring. */
23322332
float distance = 0;
23332333

2334+
#if HWLOC_API_VERSION < 0x20000
23342335
/* Override any distance logic so all devices are used */
23352336
if (0 != mca_btl_openib_component.ignore_locality ||
23362337
OPAL_SUCCESS != opal_hwloc_base_get_topology()) {
@@ -2475,6 +2476,9 @@ static float get_ib_dev_distance(struct ibv_device *dev)
24752476
if (NULL != my_cpuset) {
24762477
hwloc_bitmap_free(my_cpuset);
24772478
}
2479+
#else
2480+
#warning FIXME get_ib_dev_distance is not implemented with hwloc v2
2481+
#endif
24782482

24792483
return distance;
24802484
}

opal/mca/hwloc/base/base.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020
#include "opal/mca/hwloc/hwloc-internal.h"
2121

22+
#if HWLOC_API_VERSION < 0x20000
23+
#define HWLOC_OBJ_L3CACHE HWLOC_OBJ_CACHE
24+
#define HWLOC_OBJ_L2CACHE HWLOC_OBJ_CACHE
25+
#define HWLOC_OBJ_L1CACHE HWLOC_OBJ_CACHE
26+
#endif
27+
2228
/*
2329
* Global functions for MCA overall hwloc open and close
2430
*/
@@ -83,6 +89,20 @@ OPAL_DECLSPEC extern char *opal_hwloc_base_topo_file;
8389
hwloc_bitmap_free(bind); \
8490
} while(0);
8591

92+
#if HWLOC_API_VERSION < 0x20000
93+
#define OPAL_HWLOC_MAKE_OBJ_CACHE(level, obj, cache_level) \
94+
do { \
95+
obj = HWLOC_OBJ_CACHE; \
96+
cache_level = level; \
97+
} while(0)
98+
#else
99+
#define OPAL_HWLOC_MAKE_OBJ_CACHE(level, obj, cache_level) \
100+
do { \
101+
obj = HWLOC_OBJ_L##level##CACHE; \
102+
cache_level = 0; \
103+
} while(0)
104+
#endif
105+
86106
OPAL_DECLSPEC opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t topo,
87107
char *cpuset1, char *cpuset2);
88108

@@ -282,6 +302,9 @@ OPAL_DECLSPEC char* opal_hwloc_base_get_location(char *locality,
282302

283303
OPAL_DECLSPEC opal_hwloc_locality_t opal_hwloc_compute_relative_locality(char *loc1, char *loc2);
284304

305+
OPAL_DECLSPEC int opal_hwloc_base_topology_export_xmlbuffer(hwloc_topology_t topology, char **xmlpath, int *buflen);
306+
307+
OPAL_DECLSPEC int opal_hwloc_base_topology_set_flags (hwloc_topology_t topology, unsigned long flags, bool io);
285308
END_C_DECLS
286309

287310
#endif /* OPAL_HWLOC_BASE_H */

opal/mca/hwloc/base/hwloc_base_dt.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int opal_hwloc_pack(opal_buffer_t *buffer, const void *src,
3131
t = tarray[i];
3232

3333
/* extract an xml-buffer representation of the tree */
34-
if (0 != hwloc_topology_export_xmlbuffer(t, &xmlbuffer, &len)) {
34+
if (0 != opal_hwloc_base_topology_export_xmlbuffer(t, &xmlbuffer, &len)) {
3535
return OPAL_ERROR;
3636
}
3737

@@ -106,8 +106,7 @@ int opal_hwloc_unpack(opal_buffer_t *buffer, void *dest,
106106
/* since we are loading this from an external source, we have to
107107
* explicitly set a flag so hwloc sets things up correctly
108108
*/
109-
if (0 != hwloc_topology_set_flags(t, (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM |
110-
HWLOC_TOPOLOGY_FLAG_IO_DEVICES))) {
109+
if (0 != opal_hwloc_base_topology_set_flags(t, HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM, true)) {
111110
rc = OPAL_ERROR;
112111
hwloc_topology_destroy(t);
113112
goto cleanup;
@@ -191,10 +190,10 @@ int opal_hwloc_compare(const hwloc_topology_t topo1,
191190
* where we really need to do a tree-wise search so we only compare
192191
* the things we care about, and ignore stuff like MAC addresses
193192
*/
194-
if (0 != hwloc_topology_export_xmlbuffer(t1, &x1, &l1)) {
193+
if (0 != opal_hwloc_base_topology_export_xmlbuffer(t1, &x1, &l1)) {
195194
return OPAL_EQUAL;
196195
}
197-
if (0 != hwloc_topology_export_xmlbuffer(t2, &x2, &l2)) {
196+
if (0 != opal_hwloc_base_topology_export_xmlbuffer(t2, &x2, &l2)) {
198197
free(x1);
199198
return OPAL_EQUAL;
200199
}

opal/mca/hwloc/base/hwloc_base_frame.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 2011-2017 Cisco Systems, Inc. All rights reserved
33
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
4-
* Copyright (c) 2016 Research Organization for Information Science
4+
* Copyright (c) 2016-2017 Research Organization for Information Science
55
* and Technology (RIST). All rights reserved.
66
* $COPYRIGHT$
77
*
@@ -50,9 +50,9 @@ hwloc_obj_type_t opal_hwloc_levels[] = {
5050
HWLOC_OBJ_MACHINE,
5151
HWLOC_OBJ_NODE,
5252
HWLOC_OBJ_SOCKET,
53-
HWLOC_OBJ_CACHE,
54-
HWLOC_OBJ_CACHE,
55-
HWLOC_OBJ_CACHE,
53+
HWLOC_OBJ_L3CACHE,
54+
HWLOC_OBJ_L2CACHE,
55+
HWLOC_OBJ_L1CACHE,
5656
HWLOC_OBJ_CORE,
5757
HWLOC_OBJ_PU
5858
};

0 commit comments

Comments
 (0)