1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef OPAL_HWLOC_BASE_H
14 #define OPAL_HWLOC_BASE_H
15
16 #include "opal_config.h"
17
18 #include "opal/dss/dss_types.h"
19
20 #include "opal/mca/hwloc/hwloc-internal.h"
21
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
28
29
30
31
32 BEGIN_C_DECLS
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 OPAL_DECLSPEC extern bool opal_hwloc_base_inited;
53 OPAL_DECLSPEC extern bool opal_hwloc_topology_inited;
54
55 OPAL_DECLSPEC extern mca_base_framework_t opal_hwloc_base_framework;
56
57
58 #define OPAL_HWLOC_PRINT_MAX_SIZE 50
59 #define OPAL_HWLOC_PRINT_NUM_BUFS 16
60 typedef struct {
61 char *buffers[OPAL_HWLOC_PRINT_NUM_BUFS];
62 int cntr;
63 } opal_hwloc_print_buffers_t;
64 opal_hwloc_print_buffers_t *opal_hwloc_get_print_buffer(void);
65 extern char* opal_hwloc_print_null;
66 OPAL_DECLSPEC char* opal_hwloc_base_print_locality(opal_hwloc_locality_t locality);
67
68 OPAL_DECLSPEC extern char *opal_hwloc_base_cpu_list;
69 OPAL_DECLSPEC extern hwloc_cpuset_t opal_hwloc_base_given_cpus;
70 OPAL_DECLSPEC extern char *opal_hwloc_base_topo_file;
71
72
73 #define OPAL_HWLOC_SHOW_BINDING(n, v, t) \
74 do { \
75 char tmp1[1024]; \
76 hwloc_cpuset_t bind; \
77 bind = opal_hwloc_alloc(); \
78 if (hwloc_get_cpubind(t, bind, \
79 HWLOC_CPUBIND_PROCESS) < 0) { \
80 opal_output_verbose(n, v, \
81 "CANNOT DETERMINE BINDING AT %s:%d", \
82 __FILE__, __LINE__); \
83 } else { \
84 opal_hwloc_base_cset2mapstr(tmp1, sizeof(tmp1), t, bind); \
85 opal_output_verbose(n, v, \
86 "BINDINGS AT %s:%d: %s", \
87 __FILE__, __LINE__, tmp1); \
88 } \
89 hwloc_bitmap_free(bind); \
90 } while(0);
91
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
106 OPAL_DECLSPEC opal_hwloc_locality_t opal_hwloc_base_get_relative_locality(hwloc_topology_t topo,
107 char *cpuset1, char *cpuset2);
108
109 OPAL_DECLSPEC int opal_hwloc_base_set_binding_policy(opal_binding_policy_t *policy, char *spec);
110
111
112
113
114
115
116
117
118 OPAL_DECLSPEC void opal_hwloc_base_get_local_cpuset(void);
119
120 struct opal_rmaps_numa_node_t {
121 opal_list_item_t super;
122 int index;
123 float dist_from_closed;
124 };
125 typedef struct opal_rmaps_numa_node_t opal_rmaps_numa_node_t;
126 OBJ_CLASS_DECLARATION(opal_rmaps_numa_node_t);
127
128
129
130
131
132 typedef enum {
133 OPAL_HWLOC_BASE_MAP_NONE,
134 OPAL_HWLOC_BASE_MAP_LOCAL_ONLY
135 } opal_hwloc_base_map_t;
136
137
138
139
140 OPAL_DECLSPEC extern opal_hwloc_base_map_t opal_hwloc_base_map;
141
142
143
144
145
146 typedef enum {
147 OPAL_HWLOC_BASE_MBFA_SILENT,
148 OPAL_HWLOC_BASE_MBFA_WARN,
149 OPAL_HWLOC_BASE_MBFA_ERROR
150 } opal_hwloc_base_mbfa_t;
151
152
153
154
155 OPAL_DECLSPEC extern opal_hwloc_base_mbfa_t opal_hwloc_base_mbfa;
156
157
158
159
160
161 OPAL_DECLSPEC int opal_hwloc_base_get_topology(void);
162
163
164
165
166 OPAL_DECLSPEC int opal_hwloc_base_set_topology(char *topofile);
167
168 OPAL_DECLSPEC int opal_hwloc_base_filter_cpus(hwloc_topology_t topo);
169
170
171
172
173 OPAL_DECLSPEC void opal_hwloc_base_free_topology(hwloc_topology_t topo);
174 OPAL_DECLSPEC unsigned int opal_hwloc_base_get_nbobjs_by_type(hwloc_topology_t topo,
175 hwloc_obj_type_t target,
176 unsigned cache_level,
177 opal_hwloc_resource_type_t rtype);
178 OPAL_DECLSPEC void opal_hwloc_base_clear_usage(hwloc_topology_t topo);
179
180 OPAL_DECLSPEC hwloc_obj_t opal_hwloc_base_get_obj_by_type(hwloc_topology_t topo,
181 hwloc_obj_type_t target,
182 unsigned cache_level,
183 unsigned int instance,
184 opal_hwloc_resource_type_t rtype);
185 OPAL_DECLSPEC unsigned int opal_hwloc_base_get_obj_idx(hwloc_topology_t topo,
186 hwloc_obj_t obj,
187 opal_hwloc_resource_type_t rtype);
188
189 OPAL_DECLSPEC int opal_hwloc_get_sorted_numa_list(hwloc_topology_t topo,
190 char* device_name,
191 opal_list_t *sorted_list);
192
193
194
195
196 OPAL_DECLSPEC unsigned int opal_hwloc_base_get_npus(hwloc_topology_t topo,
197 hwloc_obj_t target);
198 OPAL_DECLSPEC char* opal_hwloc_base_print_binding(opal_binding_policy_t binding);
199
200
201
202
203 OPAL_DECLSPEC bool opal_hwloc_base_single_cpu(hwloc_cpuset_t cpuset);
204
205
206
207
208
209 OPAL_DECLSPEC int opal_hwloc_base_cpu_list_parse(const char *slot_str,
210 hwloc_topology_t topo,
211 opal_hwloc_resource_type_t rtype,
212 hwloc_cpuset_t cpumask);
213
214 OPAL_DECLSPEC char* opal_hwloc_base_find_coprocessors(hwloc_topology_t topo);
215 OPAL_DECLSPEC char* opal_hwloc_base_check_on_coprocessor(void);
216
217
218
219
220
221
222
223 OPAL_DECLSPEC int opal_hwloc_base_report_bind_failure(const char *file,
224 int line,
225 const char *msg,
226 int rc);
227
228
229
230
231
232
233
234
235
236 OPAL_DECLSPEC int opal_hwloc_base_set_process_membind_policy(void);
237
238 OPAL_DECLSPEC int opal_hwloc_base_membind(opal_hwloc_base_memory_segment_t *segs,
239 size_t count, int node_id);
240
241 OPAL_DECLSPEC int opal_hwloc_base_node_name_to_id(char *node_name, int *id);
242
243 OPAL_DECLSPEC int opal_hwloc_base_memory_set(opal_hwloc_base_memory_segment_t *segments,
244 size_t num_segments);
245
246
247 OPAL_DECLSPEC int opal_hwloc_pack(opal_buffer_t *buffer, const void *src,
248 int32_t num_vals,
249 opal_data_type_t type);
250 OPAL_DECLSPEC int opal_hwloc_unpack(opal_buffer_t *buffer, void *dest,
251 int32_t *num_vals,
252 opal_data_type_t type);
253 OPAL_DECLSPEC int opal_hwloc_copy(hwloc_topology_t *dest,
254 hwloc_topology_t src,
255 opal_data_type_t type);
256 OPAL_DECLSPEC int opal_hwloc_compare(const hwloc_topology_t topo1,
257 const hwloc_topology_t topo2,
258 opal_data_type_t type);
259 OPAL_DECLSPEC int opal_hwloc_print(char **output, char *prefix,
260 hwloc_topology_t src,
261 opal_data_type_t type);
262
263
264
265
266
267 OPAL_DECLSPEC int opal_hwloc_base_cset2str(char *str, int len,
268 hwloc_topology_t topo,
269 hwloc_cpuset_t cpuset);
270
271
272
273
274
275
276
277
278
279 OPAL_DECLSPEC int opal_hwloc_base_cset2mapstr(char *str, int len,
280 hwloc_topology_t topo,
281 hwloc_cpuset_t cpuset);
282
283
284 OPAL_DECLSPEC hwloc_obj_t opal_hwloc_base_get_pu(hwloc_topology_t topo,
285 int lid,
286 opal_hwloc_resource_type_t rtype);
287
288
289
290 OPAL_DECLSPEC char* opal_hwloc_base_get_topo_signature(hwloc_topology_t topo);
291
292
293
294 OPAL_DECLSPEC char* opal_hwloc_base_get_locality_string(hwloc_topology_t topo, char *bitmap);
295
296
297 OPAL_DECLSPEC char* opal_hwloc_base_get_location(char *locality,
298 hwloc_obj_type_t type,
299 unsigned index);
300
301 OPAL_DECLSPEC opal_hwloc_locality_t opal_hwloc_compute_relative_locality(char *loc1, char *loc2);
302
303 OPAL_DECLSPEC int opal_hwloc_base_topology_export_xmlbuffer(hwloc_topology_t topology, char **xmlpath, int *buflen);
304
305 OPAL_DECLSPEC int opal_hwloc_base_topology_set_flags (hwloc_topology_t topology, unsigned long flags, bool io);
306 END_C_DECLS
307
308 #endif