Skip to content

Commit 7c6bd7d

Browse files
author
Ralph Castain
authored
Merge pull request #3302 from ggouaillardet/poc/hwloc2
POC: add support for hwloc v2
2 parents fca68b0 + 593e4ce commit 7c6bd7d

File tree

174 files changed

+50250
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+50250
-391
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 */

ompi/mpiext/affinity/c/mpiext_affinity_str.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static int get_rsrc_current_binding(char str[OMPI_AFFINITY_STRING_MAX])
131131

132132
/* get our root object */
133133
root = hwloc_get_root_obj(opal_hwloc_topology);
134-
rootset = opal_hwloc_base_get_available_cpus(opal_hwloc_topology, root);
134+
rootset = root->cpuset;
135135

136136
/* get our bindings */
137137
boundset = hwloc_bitmap_alloc();
@@ -324,7 +324,7 @@ static int get_layout_current_binding(char str[OMPI_AFFINITY_STRING_MAX])
324324

325325
/* get our root object */
326326
root = hwloc_get_root_obj(opal_hwloc_topology);
327-
rootset = opal_hwloc_base_get_available_cpus(opal_hwloc_topology, root);
327+
rootset = root->cpuset;
328328

329329
/* get our bindings */
330330
boundset = hwloc_bitmap_alloc();

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/btl/smcuda/btl_smcuda.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2012-2015 NVIDIA Corporation. All rights reserved.
1818
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
19-
* Copyright (c) 2014 Research Organization for Information Science
19+
* Copyright (c) 2014-2017 Research Organization for Information Science
2020
* and Technology (RIST). All rights reserved.
2121
* Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
2222
* $COPYRIGHT$
@@ -296,7 +296,6 @@ smcuda_btl_first_time_init(mca_btl_smcuda_t *smcuda_btl,
296296
num_mem_nodes > 0 && NULL != opal_process_info.cpuset) {
297297
int numa=0, w;
298298
unsigned n_bound=0;
299-
hwloc_cpuset_t avail;
300299
hwloc_obj_t obj;
301300

302301
/* count the number of NUMA nodes to which we are bound */
@@ -306,10 +305,8 @@ smcuda_btl_first_time_init(mca_btl_smcuda_t *smcuda_btl,
306305
OPAL_HWLOC_AVAILABLE))) {
307306
continue;
308307
}
309-
/* get that NUMA node's available cpus */
310-
avail = opal_hwloc_base_get_available_cpus(opal_hwloc_topology, obj);
311-
/* see if we intersect */
312-
if (hwloc_bitmap_intersects(avail, opal_hwloc_my_cpuset)) {
308+
/* see if we intersect with that NUMA node's cpus */
309+
if (hwloc_bitmap_intersects(obj->cpuset, opal_hwloc_my_cpuset)) {
313310
n_bound++;
314311
numa = w;
315312
}

opal/mca/hwloc/base/base.h

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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) 2017 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
46
* $COPYRIGHT$
57
*
68
* Additional copyrights may follow
@@ -17,6 +19,12 @@
1719

1820
#include "opal/mca/hwloc/hwloc-internal.h"
1921

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+
2028
/*
2129
* Global functions for MCA overall hwloc open and close
2230
*/
@@ -81,6 +89,20 @@ OPAL_DECLSPEC extern char *opal_hwloc_base_topo_file;
8189
hwloc_bitmap_free(bind); \
8290
} while(0);
8391

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+
84106
OPAL_DECLSPEC opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t topo,
85107
char *cpuset1, char *cpuset2);
86108

@@ -132,9 +154,6 @@ typedef enum {
132154
*/
133155
OPAL_DECLSPEC extern opal_hwloc_base_mbfa_t opal_hwloc_base_mbfa;
134156

135-
/* some critical helper functions */
136-
OPAL_DECLSPEC int opal_hwloc_base_filter_cpus(hwloc_topology_t topo);
137-
138157
/**
139158
* Discover / load the hwloc topology (i.e., call hwloc_topology_init() and
140159
* hwloc_topology_load()).
@@ -150,8 +169,6 @@ OPAL_DECLSPEC int opal_hwloc_base_set_topology(char *topofile);
150169
* Free the hwloc topology.
151170
*/
152171
OPAL_DECLSPEC void opal_hwloc_base_free_topology(hwloc_topology_t topo);
153-
OPAL_DECLSPEC hwloc_cpuset_t opal_hwloc_base_get_available_cpus(hwloc_topology_t topo,
154-
hwloc_obj_t obj);
155172
OPAL_DECLSPEC unsigned int opal_hwloc_base_get_nbobjs_by_type(hwloc_topology_t topo,
156173
hwloc_obj_type_t target,
157174
unsigned cache_level,
@@ -285,6 +302,9 @@ OPAL_DECLSPEC char* opal_hwloc_base_get_location(char *locality,
285302

286303
OPAL_DECLSPEC opal_hwloc_locality_t opal_hwloc_compute_relative_locality(char *loc1, char *loc2);
287304

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);
288308
END_C_DECLS
289309

290310
#endif /* OPAL_HWLOC_BASE_H */

opal/mca/hwloc/base/hwloc_base_dt.c

Lines changed: 4 additions & 23 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,9 +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_WHOLE_SYSTEM |
111-
HWLOC_TOPOLOGY_FLAG_IO_DEVICES))) {
109+
if (0 != opal_hwloc_base_topology_set_flags(t, HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM, true)) {
112110
rc = OPAL_ERROR;
113111
hwloc_topology_destroy(t);
114112
goto cleanup;
@@ -137,11 +135,6 @@ int opal_hwloc_unpack(opal_buffer_t *buffer, void *dest,
137135
goto cleanup;
138136
}
139137

140-
/* filter the cpus thru any default cpu set */
141-
if (OPAL_SUCCESS != (rc = opal_hwloc_base_filter_cpus(t))) {
142-
goto cleanup;
143-
}
144-
145138
/* pass it back */
146139
tarray[i] = t;
147140

@@ -197,10 +190,10 @@ int opal_hwloc_compare(const hwloc_topology_t topo1,
197190
* where we really need to do a tree-wise search so we only compare
198191
* the things we care about, and ignore stuff like MAC addresses
199192
*/
200-
if (0 != hwloc_topology_export_xmlbuffer(t1, &x1, &l1)) {
193+
if (0 != opal_hwloc_base_topology_export_xmlbuffer(t1, &x1, &l1)) {
201194
return OPAL_EQUAL;
202195
}
203-
if (0 != hwloc_topology_export_xmlbuffer(t2, &x2, &l2)) {
196+
if (0 != opal_hwloc_base_topology_export_xmlbuffer(t2, &x2, &l2)) {
204197
free(x1);
205198
return OPAL_EQUAL;
206199
}
@@ -269,18 +262,6 @@ static void print_hwloc_obj(char **output, char *prefix,
269262
free(tmp);
270263
tmp = tmp2;
271264
}
272-
if (NULL != obj->online_cpuset) {
273-
hwloc_bitmap_snprintf(string, OPAL_HWLOC_MAX_STRING, obj->online_cpuset);
274-
asprintf(&tmp2, "%s%sOnline: %s", tmp, pfx, string);
275-
free(tmp);
276-
tmp = tmp2;
277-
}
278-
if (NULL != obj->allowed_cpuset) {
279-
hwloc_bitmap_snprintf(string, OPAL_HWLOC_MAX_STRING, obj->allowed_cpuset);
280-
asprintf(&tmp2, "%s%sAllowed: %s", tmp, pfx, string);
281-
free(tmp);
282-
tmp = tmp2;
283-
}
284265
if (HWLOC_OBJ_MACHINE == obj->type) {
285266
/* root level object - add support values */
286267
support = (struct hwloc_topology_support*)hwloc_topology_get_support(topo);

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)