Skip to content

Commit 416476d

Browse files
committed
hwloc v2
1 parent 47def0d commit 416476d

File tree

7 files changed

+146
-37
lines changed

7 files changed

+146
-37
lines changed

opal/mca/hwloc/base/base.h

Lines changed: 8 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 OPAL_HAVE_HWLOC_OBJ_CACHE
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
*/
@@ -282,6 +288,8 @@ OPAL_DECLSPEC char* opal_hwloc_base_get_location(char *locality,
282288

283289
OPAL_DECLSPEC opal_hwloc_locality_t opal_hwloc_compute_relative_locality(char *loc1, char *loc2);
284290

291+
OPAL_DECLSPEC int opal_hwloc_base_topology_export_xmlbuffer(hwloc_topology_t topology, char **xmlpath, int *buflen);
292+
285293
END_C_DECLS
286294

287295
#endif /* OPAL_HWLOC_BASE_H */

opal/mca/hwloc/base/hwloc_base_dt.c

Lines changed: 8 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,11 @@ 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 != hwloc_topology_set_flags(t, (HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
110+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
111+
| HWLOC_TOPOLOGY_FLAG_IO_DEVICES
112+
#endif
113+
))) {
111114
rc = OPAL_ERROR;
112115
hwloc_topology_destroy(t);
113116
goto cleanup;
@@ -191,10 +194,10 @@ int opal_hwloc_compare(const hwloc_topology_t topo1,
191194
* where we really need to do a tree-wise search so we only compare
192195
* the things we care about, and ignore stuff like MAC addresses
193196
*/
194-
if (0 != hwloc_topology_export_xmlbuffer(t1, &x1, &l1)) {
197+
if (0 != opal_hwloc_base_topology_export_xmlbuffer(t1, &x1, &l1)) {
195198
return OPAL_EQUAL;
196199
}
197-
if (0 != hwloc_topology_export_xmlbuffer(t2, &x2, &l2)) {
200+
if (0 != opal_hwloc_base_topology_export_xmlbuffer(t2, &x2, &l2)) {
198201
free(x1);
199202
return OPAL_EQUAL;
200203
}

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
};

opal/mca/hwloc/base/hwloc_base_util.c

Lines changed: 109 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static void fill_cache_line_size(void)
111111
{
112112
int i = 0, cache_level = 2;
113113
unsigned size;
114+
unsigned int cache_object = HWLOC_OBJ_L2CACHE;
114115
hwloc_obj_t obj;
115116
bool found = false;
116117

@@ -120,10 +121,11 @@ static void fill_cache_line_size(void)
120121
i=0;
121122
while (1) {
122123
obj = opal_hwloc_base_get_obj_by_type(opal_hwloc_topology,
123-
HWLOC_OBJ_CACHE, cache_level,
124+
cache_object, cache_level,
124125
i, OPAL_HWLOC_LOGICAL);
125126
if (NULL == obj) {
126127
--cache_level;
128+
cache_object = HWLOC_OBJ_L1CACHE;
127129
break;
128130
} else {
129131
if (NULL != obj->attr &&
@@ -186,9 +188,11 @@ int opal_hwloc_base_get_topology(void)
186188
* explicitly set a flag so hwloc sets things up correctly
187189
*/
188190
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+
))) {
192196
hwloc_topology_destroy(opal_hwloc_topology);
193197
free(val);
194198
return OPAL_ERROR;
@@ -202,8 +206,10 @@ int opal_hwloc_base_get_topology(void)
202206
free(val);
203207
} else if (NULL == opal_hwloc_base_topo_file) {
204208
if (0 != hwloc_topology_init(&opal_hwloc_topology) ||
209+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
205210
0 != hwloc_topology_set_flags(opal_hwloc_topology,
206211
HWLOC_TOPOLOGY_FLAG_IO_DEVICES) ||
212+
#endif
207213
0 != hwloc_topology_load(opal_hwloc_topology)) {
208214
return OPAL_ERR_NOT_SUPPORTED;
209215
}
@@ -248,8 +254,11 @@ int opal_hwloc_base_set_topology(char *topofile)
248254
* explicitly set a flag so hwloc sets things up correctly
249255
*/
250256
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+
))) {
253262
hwloc_topology_destroy(opal_hwloc_topology);
254263
return OPAL_ERR_NOT_SUPPORTED;
255264
}
@@ -499,10 +508,13 @@ unsigned int opal_hwloc_base_get_obj_idx(hwloc_topology_t topo,
499508
return data->idx;
500509
}
501510

511+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
502512
/* determine the number of objects of this type */
503513
if (HWLOC_OBJ_CACHE == obj->type) {
504514
cache_level = obj->attr->cache.depth;
505515
}
516+
#endif
517+
506518
nobjs = opal_hwloc_base_get_nbobjs_by_type(topo, obj->type, cache_level, rtype);
507519

508520
OPAL_OUTPUT_VERBOSE((5, opal_hwloc_base_framework.framework_output,
@@ -552,9 +564,11 @@ static hwloc_obj_t df_search(hwloc_topology_t topo,
552564
opal_hwloc_obj_data_t *data;
553565

554566
if (target == start->type) {
567+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
555568
if (HWLOC_OBJ_CACHE == start->type && cache_level != start->attr->cache.depth) {
556569
goto notfound;
557570
}
571+
#endif
558572
if (OPAL_HWLOC_LOGICAL == rtype) {
559573
/* the hwloc tree is composed of LOGICAL objects, so the only
560574
* 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,
660674
* use the hwloc accessor to get it, unless it is a CACHE
661675
* as these are treated as special cases
662676
*/
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+
) {
664682
/* we should not get an error back, but just in case... */
665683
if (0 > (rc = hwloc_get_nbobjs_by_type(topo, target))) {
666684
opal_output(0, "UNKNOWN HWLOC ERROR");
@@ -729,9 +747,11 @@ static hwloc_obj_t df_search_min_bound(hwloc_topology_t topo,
729747
if (0 == (k = opal_hwloc_base_get_npus(topo, start))) {
730748
goto notfound;
731749
}
750+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
732751
if (HWLOC_OBJ_CACHE == start->type && cache_level != start->attr->cache.depth) {
733752
goto notfound;
734753
}
754+
#endif
735755
/* see how many procs are bound to us */
736756
data = (opal_hwloc_obj_data_t*)start->userdata;
737757
if (NULL == data) {
@@ -794,10 +814,12 @@ hwloc_obj_t opal_hwloc_base_find_min_bound_target_under_obj(hwloc_topology_t top
794814
/* again, we have to treat caches differently as
795815
* the levels distinguish them
796816
*/
817+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
797818
if (HWLOC_OBJ_CACHE == target &&
798819
cache_level < obj->attr->cache.depth) {
799820
goto moveon;
800821
}
822+
#endif
801823
return obj;
802824
}
803825

@@ -810,16 +832,17 @@ hwloc_obj_t opal_hwloc_base_find_min_bound_target_under_obj(hwloc_topology_t top
810832
loc = df_search_min_bound(topo, obj, target, cache_level, &min_bound);
811833

812834
if (NULL != loc) {
835+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
813836
if (HWLOC_OBJ_CACHE == target) {
814837
OPAL_OUTPUT_VERBOSE((5, opal_hwloc_base_framework.framework_output,
815838
"hwloc:base:min_bound_under_obj found min bound of %u on %s:%u:%u",
816839
min_bound, hwloc_obj_type_string(target),
817840
cache_level, loc->logical_index));
818-
} else {
841+
} else
842+
#endif
819843
OPAL_OUTPUT_VERBOSE((5, opal_hwloc_base_framework.framework_output,
820844
"hwloc:base:min_bound_under_obj found min bound of %u on %s:%u",
821845
min_bound, hwloc_obj_type_string(target), loc->logical_index));
822-
}
823846
}
824847

825848
return loc;
@@ -846,7 +869,11 @@ hwloc_obj_t opal_hwloc_base_get_obj_by_type(hwloc_topology_t topo,
846869
* use the hwloc accessor to get it, unless it is a CACHE
847870
* as these are treated as special cases
848871
*/
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+
) {
850877
return hwloc_get_obj_by_type(topo, target, instance);
851878
}
852879

@@ -1231,7 +1258,13 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
12311258
/* if it isn't one of interest, then ignore it */
12321259
if (HWLOC_OBJ_NODE != type &&
12331260
HWLOC_OBJ_SOCKET != type &&
1261+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
12341262
HWLOC_OBJ_CACHE != type &&
1263+
#else
1264+
HWLOC_OBJ_L3CACHE != type &&
1265+
HWLOC_OBJ_L2CACHE != type &&
1266+
HWLOC_OBJ_L1CACHE != type &&
1267+
#endif
12351268
HWLOC_OBJ_CORE != type &&
12361269
HWLOC_OBJ_PU != type) {
12371270
continue;
@@ -1258,6 +1291,7 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
12581291
case HWLOC_OBJ_SOCKET:
12591292
locality |= OPAL_PROC_ON_SOCKET;
12601293
break;
1294+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
12611295
case HWLOC_OBJ_CACHE:
12621296
if (3 == obj->attr->cache.depth) {
12631297
locality |= OPAL_PROC_ON_L3CACHE;
@@ -1267,6 +1301,17 @@ opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t top
12671301
locality |= OPAL_PROC_ON_L1CACHE;
12681302
}
12691303
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
12701315
case HWLOC_OBJ_CORE:
12711316
locality |= OPAL_PROC_ON_CORE;
12721317
break;
@@ -1961,9 +2006,9 @@ char* opal_hwloc_base_get_topo_signature(hwloc_topology_t topo)
19612006

19622007
nnuma = opal_hwloc_base_get_nbobjs_by_type(topo, HWLOC_OBJ_NODE, 0, OPAL_HWLOC_AVAILABLE);
19632008
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);
19672012
ncore = opal_hwloc_base_get_nbobjs_by_type(topo, HWLOC_OBJ_CORE, 0, OPAL_HWLOC_AVAILABLE);
19682013
nhwt = opal_hwloc_base_get_nbobjs_by_type(topo, HWLOC_OBJ_PU, 0, OPAL_HWLOC_AVAILABLE);
19692014

@@ -2022,7 +2067,13 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
20222067
/* if it isn't one of interest, then ignore it */
20232068
if (HWLOC_OBJ_NODE != type &&
20242069
HWLOC_OBJ_SOCKET != type &&
2070+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
20252071
HWLOC_OBJ_CACHE != type &&
2072+
#else
2073+
HWLOC_OBJ_L1CACHE != type &&
2074+
HWLOC_OBJ_L2CACHE != type &&
2075+
HWLOC_OBJ_L3CACHE != type &&
2076+
#endif
20262077
HWLOC_OBJ_CORE != type &&
20272078
HWLOC_OBJ_PU != type) {
20282079
continue;
@@ -2064,6 +2115,7 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
20642115
}
20652116
locality = t2;
20662117
break;
2118+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
20672119
case HWLOC_OBJ_CACHE:
20682120
if (3 == obj->attr->cache.depth) {
20692121
asprintf(&t2, "%sL3%s:", (NULL == locality) ? "" : locality, tmp);
@@ -2088,6 +2140,29 @@ char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo,
20882140
break;
20892141
}
20902142
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
20912166
case HWLOC_OBJ_CORE:
20922167
asprintf(&t2, "%sCR%s:", (NULL == locality) ? "" : locality, tmp);
20932168
if (NULL != locality) {
@@ -2138,6 +2213,7 @@ char* opal_hwloc_base_get_location(char *locality,
21382213
case HWLOC_OBJ_SOCKET:
21392214
srch = "SK";
21402215
break;
2216+
#if OPAL_HAVE_HWLOC_OBJ_CACHE
21412217
case HWLOC_OBJ_CACHE:
21422218
if (3 == index) {
21432219
srch = "L3";
@@ -2147,6 +2223,17 @@ char* opal_hwloc_base_get_location(char *locality,
21472223
srch = "L0";
21482224
}
21492225
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
21502237
case HWLOC_OBJ_CORE:
21512238
srch = "CR";
21522239
break;
@@ -2232,3 +2319,12 @@ opal_hwloc_locality_t opal_hwloc_compute_relative_locality(char *loc1, char *loc
22322319
hwloc_bitmap_free(bit2);
22332320
return locality;
22342321
}
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+

opal/mca/hwloc/configure.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
dnl -*- shell-script -*-
22
dnl
33
dnl Copyright (c) 2010-2017 Cisco Systems, Inc. All rights reserved
4+
dnl Copyright (c) 2017 Research Organization for Information Science
5+
dnl and Technology (RIST). All rights reserved.
46
dnl $COPYRIGHT$
57
dnl
68
dnl Additional copyrights may follow

0 commit comments

Comments
 (0)