This source file includes following definitions.
- oshmem_proc_local
- oshmem_proc_for_find
- oshmem_proc_find
- oshmem_proc_pe
- oshmem_proc_group_create_nofail
- oshmem_proc_group_all
- oshmem_proc_group_find
- oshmem_proc_group_find_id
- oshmem_proc_group_is_member
- oshmem_num_procs
- oshmem_my_proc_id
- oshmem_get_transport_id
- oshmem_get_transport_count
1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef OSHMEM_PROC_PROC_H
14 #define OSHMEM_PROC_PROC_H
15
16 #include "oshmem_config.h"
17 #include "oshmem/types.h"
18 #include "oshmem/constants.h"
19
20 #include "opal/class/opal_list.h"
21 #include "opal/util/proc.h"
22 #include "opal/dss/dss_types.h"
23 #include "opal/mca/hwloc/hwloc-internal.h"
24
25 #include "ompi/proc/proc.h"
26 #include "ompi/communicator/communicator.h"
27
28 #include "oshmem/mca/scoll/scoll.h"
29 #include "oshmem/runtime/runtime.h"
30 #include "oshmem/shmem/shmem_api_logger.h"
31
32 BEGIN_C_DECLS
33
34
35
36 struct oshmem_group_t;
37
38 #define OSHMEM_PE_INVALID (-1)
39
40
41
42
43 struct oshmem_proc_data_t {
44 char * transport_ids;
45 int num_transports;
46 };
47
48 typedef struct oshmem_proc_data_t oshmem_proc_data_t;
49
50 #define OSHMEM_PROC_DATA(proc) \
51 ((oshmem_proc_data_t *)(proc)->padding)
52
53
54
55
56
57
58 struct oshmem_group_t {
59 opal_object_t base;
60 int id;
61 int my_pe;
62 int proc_count;
63 int is_member;
64 struct ompi_proc_t **proc_array;
65
66 opal_list_t peer_list;
67
68
69 mca_scoll_base_group_scoll_t g_scoll;
70 ompi_communicator_t* ompi_comm;
71 };
72 typedef struct oshmem_group_t oshmem_group_t;
73 OSHMEM_DECLSPEC OBJ_CLASS_DECLARATION(oshmem_group_t);
74
75 OSHMEM_DECLSPEC extern oshmem_group_t* oshmem_group_all;
76 OSHMEM_DECLSPEC extern oshmem_group_t* oshmem_group_self;
77 OSHMEM_DECLSPEC extern oshmem_group_t* oshmem_group_null;
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 OSHMEM_DECLSPEC int oshmem_proc_init(void);
101
102
103
104
105
106
107
108
109
110
111 OSHMEM_DECLSPEC int oshmem_proc_finalize(void);
112
113
114
115
116
117
118
119
120
121
122 static inline ompi_proc_t *oshmem_proc_local(void)
123 {
124 return (ompi_proc_t *)ompi_proc_local_proc;
125 }
126
127
128
129
130
131
132
133
134
135
136
137
138 static inline ompi_proc_t *oshmem_proc_for_find(const ompi_process_name_t name)
139 {
140 return (ompi_proc_t *)ompi_proc_for_name(name);
141 }
142
143 static inline ompi_proc_t *oshmem_proc_find(int pe)
144 {
145 ompi_process_name_t name;
146
147 name.jobid = OMPI_PROC_MY_NAME->jobid;
148 name.vpid = pe;
149 return oshmem_proc_for_find(name);
150 }
151
152 static inline int oshmem_proc_pe(ompi_proc_t *proc)
153 {
154 return (proc ? (int) ((ompi_process_name_t*)&proc->super.proc_name)->vpid : -1);
155 }
156
157 #define OSHMEM_PROC_JOBID(PROC) (((ompi_process_name_t*)&((PROC)->super.proc_name))->jobid)
158 #define OSHMEM_PROC_VPID(PROC) (((ompi_process_name_t*)&((PROC)->super.proc_name))->vpid)
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174 OSHMEM_DECLSPEC int oshmem_proc_group_init(void);
175
176
177
178
179
180
181
182 OSHMEM_DECLSPEC int oshmem_proc_group_finalize(void);
183
184
185
186
187
188 OSHMEM_DECLSPEC void oshmem_proc_group_finalize_scoll(void);
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 OSHMEM_DECLSPEC oshmem_group_t *oshmem_proc_group_create(int pe_start,
204 int pe_stride,
205 int pe_size);
206
207
208
209
210 static inline oshmem_group_t *
211 oshmem_proc_group_create_nofail(int pe_start, int pe_stride, int pe_size)
212 {
213 oshmem_group_t *group;
214
215 group = oshmem_proc_group_create(pe_start, pe_stride, pe_size);
216 if (NULL == group) {
217 goto fatal;
218 }
219 return group;
220
221 fatal:
222 SHMEM_API_ERROR("Failed to create group (%d,%d,%d)",
223 pe_start, pe_stride, pe_size);
224 oshmem_shmem_abort(-1);
225 return NULL;
226 }
227
228
229
230
231
232
233 OSHMEM_DECLSPEC void oshmem_proc_group_destroy(oshmem_group_t* group);
234
235 static inline ompi_proc_t *oshmem_proc_group_all(int pe)
236 {
237 return oshmem_group_all->proc_array[pe];
238 }
239
240 static inline ompi_proc_t *oshmem_proc_group_find(oshmem_group_t* group,
241 int pe)
242 {
243 int i = 0;
244 ompi_proc_t* proc = NULL;
245
246 if (OPAL_LIKELY(group)) {
247 if (OPAL_LIKELY(group == oshmem_group_all)) {
248
249 proc = group->proc_array[pe];
250 } else {
251 for (i = 0; i < group->proc_count; i++) {
252 if (pe == oshmem_proc_pe(group->proc_array[i])) {
253 proc = group->proc_array[i];
254 break;
255 }
256 }
257 }
258 } else {
259 ompi_process_name_t name;
260
261 name.jobid = OMPI_PROC_MY_NAME->jobid;
262 name.vpid = pe;
263 proc = oshmem_proc_for_find(name);
264 }
265
266 return proc;
267 }
268
269 static inline int oshmem_proc_group_find_id(oshmem_group_t* group, int pe)
270 {
271 int i = 0;
272 int id = -1;
273
274 if (group) {
275 for (i = 0; i < group->proc_count; i++) {
276 if (pe == oshmem_proc_pe(group->proc_array[i])) {
277 id = i;
278 break;
279 }
280 }
281 }
282
283 return id;
284 }
285
286 static inline int oshmem_proc_group_is_member(oshmem_group_t *group)
287 {
288 return group->is_member;
289 }
290
291 static inline int oshmem_num_procs(void)
292 {
293 return (oshmem_group_all ?
294 oshmem_group_all->proc_count : (int)opal_list_get_size(&ompi_proc_list));
295 }
296
297 static inline int oshmem_my_proc_id(void)
298 {
299 return oshmem_group_self->my_pe;
300 }
301
302 static inline int oshmem_get_transport_id(int pe)
303 {
304 ompi_proc_t *proc;
305
306 proc = oshmem_proc_group_find(oshmem_group_all, pe);
307
308 return (int) OSHMEM_PROC_DATA(proc)->transport_ids[0];
309 }
310
311 static inline int oshmem_get_transport_count(int pe)
312 {
313 ompi_proc_t *proc;
314 proc = oshmem_proc_group_find(oshmem_group_all, pe);
315 return OSHMEM_PROC_DATA(proc)->num_transports;
316 }
317
318 END_C_DECLS
319
320 #endif