1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef OPAL_MCA_HWLOC_H
14 #define OPAL_MCA_HWLOC_H
15
16 #include "opal_config.h"
17
18 #ifdef HAVE_SYS_TYPES_H
19 #include <sys/types.h>
20 #endif
21 #ifdef HAVE_SYS_TIME_H
22 #include <sys/time.h>
23 #endif
24 #include <stdint.h>
25 #include <stdarg.h>
26
27 #include "opal/class/opal_list.h"
28 #include "opal/class/opal_value_array.h"
29
30 #include "opal/mca/mca.h"
31 #include "opal/mca/base/base.h"
32
33 BEGIN_C_DECLS
34
35 #ifdef WIN32
36 #define WIN32_LEAN_AND_MEAN
37 #include <windows.h>
38 #undef WIN32_LEAN_AND_MEAN
39 typedef unsigned char u_char;
40 typedef unsigned short u_short;
41 #endif
42
43
44
45
46 struct opal_hwloc_base_component_2_0_0_t {
47
48 mca_base_component_t base_version;
49
50 mca_base_component_data_t base_data;
51 };
52
53
54
55
56 typedef struct opal_hwloc_base_component_2_0_0_t opal_hwloc_base_component_2_0_0_t;
57 typedef struct opal_hwloc_base_component_2_0_0_t opal_hwloc_component_t;
58
59
60
61
62 #define OPAL_HWLOC_BASE_VERSION_2_0_0 \
63 OPAL_MCA_BASE_VERSION_2_1_0("hwloc", 2, 0, 0)
64
65
66
67
68
69
70
71
72
73 typedef uint16_t opal_hwloc_locality_t;
74 #define OPAL_HWLOC_LOCALITY_T OPAL_UINT16
75
76
77 enum {
78 OPAL_PROC_LOCALITY_UNKNOWN = 0x0000,
79 OPAL_PROC_NON_LOCAL = 0x8000,
80 OPAL_PROC_ON_CLUSTER = 0x0001,
81 OPAL_PROC_ON_CU = 0x0002,
82 OPAL_PROC_ON_HOST = 0x0004,
83 OPAL_PROC_ON_BOARD = 0x0008,
84 OPAL_PROC_ON_NODE = 0x000c,
85 OPAL_PROC_ON_NUMA = 0x0010,
86 OPAL_PROC_ON_SOCKET = 0x0020,
87 OPAL_PROC_ON_L3CACHE = 0x0040,
88 OPAL_PROC_ON_L2CACHE = 0x0080,
89 OPAL_PROC_ON_L1CACHE = 0x0100,
90 OPAL_PROC_ON_CORE = 0x0200,
91 OPAL_PROC_ON_HWTHREAD = 0x0400,
92 OPAL_PROC_ALL_LOCAL = 0x0fff,
93 };
94
95
96 #define OPAL_PROC_ON_LOCAL_CLUSTER(n) (!!((n) & OPAL_PROC_ON_CLUSTER))
97 #define OPAL_PROC_ON_LOCAL_CU(n) (!!((n) & OPAL_PROC_ON_CU))
98 #define OPAL_PROC_ON_LOCAL_HOST(n) (!!((n) & OPAL_PROC_ON_HOST))
99 #define OPAL_PROC_ON_LOCAL_BOARD(n) (!!((n) & OPAL_PROC_ON_BOARD))
100 #define OPAL_PROC_ON_LOCAL_NODE(n) (OPAL_PROC_ON_LOCAL_HOST(n) && OPAL_PROC_ON_LOCAL_BOARD(n))
101 #define OPAL_PROC_ON_LOCAL_NUMA(n) (!!((n) & OPAL_PROC_ON_NUMA))
102 #define OPAL_PROC_ON_LOCAL_SOCKET(n) (!!((n) & OPAL_PROC_ON_SOCKET))
103 #define OPAL_PROC_ON_LOCAL_L3CACHE(n) (!!((n) & OPAL_PROC_ON_L3CACHE))
104 #define OPAL_PROC_ON_LOCAL_L2CACHE(n) (!!((n) & OPAL_PROC_ON_L2CACHE))
105 #define OPAL_PROC_ON_LOCAL_L1CACHE(n) (!!((n) & OPAL_PROC_ON_L1CACHE))
106 #define OPAL_PROC_ON_LOCAL_CORE(n) (!!((n) & OPAL_PROC_ON_CORE))
107 #define OPAL_PROC_ON_LOCAL_HWTHREAD(n) (!!((n) & OPAL_PROC_ON_HWTHREAD))
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 typedef struct {
124
125 void *mbs_start_addr;
126
127 size_t mbs_len;
128 } opal_hwloc_base_memory_segment_t;
129
130
131 #include MCA_hwloc_IMPLEMENTATION_HEADER
132
133
134 typedef uint8_t opal_hwloc_resource_type_t;
135 #define OPAL_HWLOC_PHYSICAL 1
136 #define OPAL_HWLOC_LOGICAL 2
137 #define OPAL_HWLOC_AVAILABLE 3
138
139
140 typedef struct {
141 opal_object_t super;
142 bool npus_calculated;
143 unsigned int npus;
144 unsigned int idx;
145 unsigned int num_bound;
146 } opal_hwloc_obj_data_t;
147 OBJ_CLASS_DECLARATION(opal_hwloc_obj_data_t);
148
149 typedef struct {
150 opal_list_item_t super;
151 hwloc_obj_type_t type;
152 unsigned cache_level;
153 unsigned int num_objs;
154 opal_hwloc_resource_type_t rtype;
155 opal_list_t sorted_by_dist_list;
156 } opal_hwloc_summary_t;
157 OBJ_CLASS_DECLARATION(opal_hwloc_summary_t);
158
159 typedef struct {
160 opal_object_t super;
161 hwloc_cpuset_t available;
162 opal_list_t summaries;
163
164
165 void *userdata;
166 } opal_hwloc_topo_data_t;
167 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_hwloc_topo_data_t);
168
169
170 typedef uint16_t opal_binding_policy_t;
171 #define OPAL_BINDING_POLICY OPAL_UINT16
172
173
174 #define OPAL_BIND_IF_SUPPORTED 0x1000
175
176
177 #define OPAL_BIND_ALLOW_OVERLOAD 0x2000
178
179 #define OPAL_BIND_GIVEN 0x4000
180
181
182 #define OPAL_BIND_ORDERED 0x8000
183
184
185
186
187 #define OPAL_BIND_TO_NONE 1
188 #define OPAL_BIND_TO_BOARD 2
189 #define OPAL_BIND_TO_NUMA 3
190 #define OPAL_BIND_TO_SOCKET 4
191 #define OPAL_BIND_TO_L3CACHE 5
192 #define OPAL_BIND_TO_L2CACHE 6
193 #define OPAL_BIND_TO_L1CACHE 7
194 #define OPAL_BIND_TO_CORE 8
195 #define OPAL_BIND_TO_HWTHREAD 9
196 #define OPAL_BIND_TO_CPUSET 10
197 #define OPAL_GET_BINDING_POLICY(pol) \
198 ((pol) & 0x0fff)
199 #define OPAL_SET_BINDING_POLICY(target, pol) \
200 (target) = (pol) | (((target) & 0xf000) | OPAL_BIND_GIVEN)
201 #define OPAL_SET_DEFAULT_BINDING_POLICY(target, pol) \
202 do { \
203 if (!OPAL_BINDING_POLICY_IS_SET((target))) { \
204 (target) = (pol) | (((target) & 0xf000) | \
205 OPAL_BIND_IF_SUPPORTED); \
206 } \
207 } while(0);
208
209
210 #define OPAL_BINDING_POLICY_IS_SET(pol) \
211 ((pol) & 0x4000)
212
213 #define OPAL_BINDING_REQUIRED(n) \
214 (!(OPAL_BIND_IF_SUPPORTED & (n)))
215
216 #define OPAL_BIND_OVERLOAD_ALLOWED(n) \
217 (OPAL_BIND_ALLOW_OVERLOAD & (n))
218 #define OPAL_BIND_ORDERED_REQUESTED(n) \
219 (OPAL_BIND_ORDERED & (n))
220
221
222 OPAL_DECLSPEC extern hwloc_topology_t opal_hwloc_topology;
223 OPAL_DECLSPEC extern opal_binding_policy_t opal_hwloc_binding_policy;
224 OPAL_DECLSPEC extern hwloc_cpuset_t opal_hwloc_my_cpuset;
225 OPAL_DECLSPEC extern bool opal_hwloc_report_bindings;
226 OPAL_DECLSPEC extern hwloc_obj_type_t opal_hwloc_levels[];
227 OPAL_DECLSPEC extern bool opal_hwloc_use_hwthreads_as_cpus;
228
229 END_C_DECLS
230
231 #endif