This source file includes following definitions.
- ompi_group_size
- ompi_group_rank
- ompi_group_dense_lookup
- ompi_group_get_proc_ptr
- ompi_group_get_proc_name
- ompi_group_peer_lookup
- ompi_group_peer_lookup_existing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #ifndef OMPI_GROUP_H
34 #define OMPI_GROUP_H
35
36 #include "ompi_config.h"
37 #include "ompi/proc/proc.h"
38 #include "mpi.h"
39 #include "opal/class/opal_pointer_array.h"
40 #include "opal/util/output.h"
41
42 BEGIN_C_DECLS
43
44 #define BSIZE ((int)sizeof(unsigned char)*8)
45
46 struct ompi_group_sporadic_list_t
47 {
48 int rank_first;
49 int length;
50 };
51
52 struct ompi_group_sporadic_data_t
53 {
54 struct ompi_group_sporadic_list_t *grp_sporadic_list;
55
56 int grp_sporadic_list_len;
57 };
58 struct ompi_group_strided_data_t
59 {
60 int grp_strided_offset;
61 int grp_strided_stride;
62 int grp_strided_last_element;
63 };
64 struct ompi_group_bitmap_data_t
65 {
66 unsigned char *grp_bitmap_array;
67 int grp_bitmap_array_len;
68 };
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 struct ompi_group_t {
84 opal_object_t super;
85 int grp_proc_count;
86 int grp_my_rank;
87 int grp_f_to_c_index;
88 struct ompi_proc_t **grp_proc_pointers;
89
90
91 uint32_t grp_flags;
92
93 struct ompi_group_t *grp_parent_group_ptr;
94 union
95 {
96 struct ompi_group_sporadic_data_t grp_sporadic;
97 struct ompi_group_strided_data_t grp_strided;
98 struct ompi_group_bitmap_data_t grp_bitmap;
99 } sparse_data;
100 };
101
102 typedef struct ompi_group_t ompi_group_t;
103 OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_group_t);
104
105
106
107
108
109
110 #define PREDEFINED_GROUP_PAD 256
111
112 struct ompi_predefined_group_t {
113 struct ompi_group_t group;
114 char padding[PREDEFINED_GROUP_PAD - sizeof(ompi_group_t)];
115 };
116
117 typedef struct ompi_predefined_group_t ompi_predefined_group_t;
118
119
120
121
122
123
124 #include "group_dbg.h"
125
126 #define OMPI_GROUP_IS_INTRINSIC(_group) ((_group)->grp_flags&OMPI_GROUP_INTRINSIC)
127 #define OMPI_GROUP_IS_DENSE(_group) ((_group)->grp_flags & OMPI_GROUP_DENSE)
128 #define OMPI_GROUP_IS_SPORADIC(_group) ((_group)->grp_flags & OMPI_GROUP_SPORADIC)
129 #define OMPI_GROUP_IS_STRIDED(_group) ((_group)->grp_flags & OMPI_GROUP_STRIDED)
130 #define OMPI_GROUP_IS_BITMAP(_group) ((_group)->grp_flags & OMPI_GROUP_BITMAP)
131
132 #define OMPI_GROUP_SET_INTRINSIC(_group) ( (_group)->grp_flags |= OMPI_GROUP_INTRINSIC)
133 #define OMPI_GROUP_SET_DENSE(_group) ( (_group)->grp_flags |= OMPI_GROUP_DENSE)
134 #define OMPI_GROUP_SET_SPORADIC(_group) ( (_group)->grp_flags |= OMPI_GROUP_SPORADIC)
135 #define OMPI_GROUP_SET_STRIDED(_group) ( (_group)->grp_flags |= OMPI_GROUP_STRIDED)
136 #define OMPI_GROUP_SET_BITMAP(_group) ( (_group)->grp_flags |= OMPI_GROUP_BITMAP)
137
138
139
140
141 OMPI_DECLSPEC extern struct opal_pointer_array_t ompi_group_f_to_c_table;
142 OMPI_DECLSPEC extern struct ompi_predefined_group_t ompi_mpi_group_null;
143 OMPI_DECLSPEC extern struct ompi_predefined_group_t *ompi_mpi_group_null_addr;
144
145
146
147
148
149
150
151
152
153
154
155
156
157 OMPI_DECLSPEC ompi_group_t *ompi_group_allocate(int group_size);
158 ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_size);
159 ompi_group_t *ompi_group_allocate_sporadic(int group_size);
160 ompi_group_t *ompi_group_allocate_strided(void);
161 ompi_group_t *ompi_group_allocate_bmap(int orig_group_size, int group_size);
162
163
164
165
166
167
168
169 OMPI_DECLSPEC void ompi_group_increment_proc_count(ompi_group_t *group);
170
171
172
173
174
175
176
177 OMPI_DECLSPEC void ompi_group_decrement_proc_count(ompi_group_t *group);
178
179
180
181
182
183
184
185 int ompi_group_init(void);
186
187
188
189
190
191
192
193 int ompi_group_finalize(void);
194
195
196
197
198
199
200
201
202
203 static inline int ompi_group_size(ompi_group_t *group)
204 {
205 return group->grp_proc_count;
206 }
207
208
209
210
211
212
213
214
215
216 static inline int ompi_group_rank(ompi_group_t *group)
217 {
218 return group->grp_my_rank;
219 }
220
221
222
223
224
225
226
227
228
229
230
231
232
233 void ompi_set_group_rank(ompi_group_t *group, struct ompi_proc_t *proc_pointer);
234
235
236
237
238 OMPI_DECLSPEC int ompi_group_translate_ranks ( ompi_group_t *group1,
239 int n_ranks, const int *ranks1,
240 ompi_group_t *group2,
241 int *ranks2);
242
243
244
245
246 OMPI_DECLSPEC int ompi_group_compare(ompi_group_t *group1,
247 ompi_group_t *group2,
248 int *result);
249
250
251
252
253 int ompi_group_free (ompi_group_t **group);
254
255
256
257
258 int ompi_group_translate_ranks_sporadic ( ompi_group_t *group1,
259 int n_ranks, const int *ranks1,
260 ompi_group_t *group2,
261 int *ranks2);
262 int ompi_group_translate_ranks_sporadic_reverse ( ompi_group_t *group1,
263 int n_ranks, const int *ranks1,
264 ompi_group_t *group2,
265 int *ranks2);
266 int ompi_group_translate_ranks_strided ( ompi_group_t *group1,
267 int n_ranks, const int *ranks1,
268 ompi_group_t *group2,
269 int *ranks2);
270 int ompi_group_translate_ranks_strided_reverse ( ompi_group_t *group1,
271 int n_ranks, const int *ranks1,
272 ompi_group_t *group2,
273 int *ranks2);
274 int ompi_group_translate_ranks_bmap ( ompi_group_t *group1,
275 int n_ranks, const int *ranks1,
276 ompi_group_t *group2,
277 int *ranks2);
278 int ompi_group_translate_ranks_bmap_reverse ( ompi_group_t *group1,
279 int n_ranks, const int *ranks1,
280 ompi_group_t *group2,
281 int *ranks2);
282
283
284
285
286
287 int ompi_group_incl(ompi_group_t* group, int n, const int *ranks,
288 ompi_group_t **new_group);
289 int ompi_group_excl(ompi_group_t* group, int n, const int *ranks,
290 ompi_group_t **new_group);
291 int ompi_group_range_incl(ompi_group_t* group, int n_triplets,
292 int ranges[][3],ompi_group_t **new_group);
293 int ompi_group_range_excl(ompi_group_t* group, int n_triplets,
294 int ranges[][3],ompi_group_t **new_group);
295 int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
296 ompi_group_t **new_group);
297 int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2,
298 ompi_group_t **new_group);
299 int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
300 ompi_group_t **new_group);
301
302
303
304
305
306 int ompi_group_incl_plist(ompi_group_t* group, int n, const int *ranks,
307 ompi_group_t **new_group);
308 int ompi_group_incl_spor(ompi_group_t* group, int n, const int *ranks,
309 ompi_group_t **new_group);
310 int ompi_group_incl_strided(ompi_group_t* group, int n, const int *ranks,
311 ompi_group_t **new_group);
312 int ompi_group_incl_bmap(ompi_group_t* group, int n, const int *ranks,
313 ompi_group_t **new_group);
314
315
316
317
318 int ompi_group_calc_plist ( int n, const int *ranks );
319 int ompi_group_calc_strided ( int n, const int *ranks );
320 int ompi_group_calc_sporadic ( int n, const int *ranks );
321 int ompi_group_calc_bmap ( int n, int orig_size , const int *ranks );
322
323
324
325
326 int ompi_group_minloc (int list[], int length);
327
328
329
330
331
332
333
334
335
336
337 static inline struct ompi_proc_t *ompi_group_dense_lookup (ompi_group_t *group, const int peer_id, const bool allocate)
338 {
339 ompi_proc_t *proc;
340
341 #if OPAL_ENABLE_DEBUG
342 if (peer_id >= group->grp_proc_count) {
343 opal_output(0, "ompi_group_dense_lookup: invalid peer index (%d)", peer_id);
344 return (struct ompi_proc_t *) NULL;
345 }
346 #endif
347
348 proc = group->grp_proc_pointers[peer_id];
349
350 if (OPAL_UNLIKELY(ompi_proc_is_sentinel (proc))) {
351 if (!allocate) {
352 return NULL;
353 }
354
355
356 ompi_proc_t *real_proc =
357 (ompi_proc_t *) ompi_proc_for_name (ompi_proc_sentinel_to_name ((uintptr_t) proc));
358
359 if (opal_atomic_compare_exchange_strong_ptr ((opal_atomic_intptr_t *)(group->grp_proc_pointers + peer_id),
360 (intptr_t *) &proc, (intptr_t) real_proc)) {
361 OBJ_RETAIN(real_proc);
362 }
363
364 proc = real_proc;
365 }
366
367 return proc;
368 }
369
370
371
372
373
374 static inline ompi_proc_t *ompi_group_get_proc_ptr (ompi_group_t *group, int rank, const bool allocate)
375 {
376 #if OMPI_GROUP_SPARSE
377 do {
378 if (OMPI_GROUP_IS_DENSE(group)) {
379 return ompi_group_dense_lookup (group, rank, allocate);
380 }
381 int ranks1 = rank;
382 ompi_group_translate_ranks (group, 1, &ranks1, group->grp_parent_group_ptr, &rank);
383 group = group->grp_parent_group_ptr;
384 } while (1);
385 #else
386 return ompi_group_dense_lookup (group, rank, allocate);
387 #endif
388 }
389
390
391
392
393
394
395
396
397 ompi_proc_t *ompi_group_get_proc_ptr_raw (ompi_group_t *group, int rank);
398
399 static inline opal_process_name_t ompi_group_get_proc_name (ompi_group_t *group, int rank)
400 {
401 ompi_proc_t *proc = ompi_group_get_proc_ptr_raw (group, rank);
402 if (ompi_proc_is_sentinel (proc)) {
403 return ompi_proc_sentinel_to_name ((intptr_t) proc);
404 }
405
406 return proc->super.proc_name;
407 }
408
409
410
411
412
413 static inline struct ompi_proc_t* ompi_group_peer_lookup(ompi_group_t *group, int peer_id)
414 {
415 return ompi_group_get_proc_ptr (group, peer_id, true);
416 }
417
418 static inline struct ompi_proc_t *ompi_group_peer_lookup_existing (ompi_group_t *group, int peer_id)
419 {
420 return ompi_group_get_proc_ptr (group, peer_id, false);
421 }
422
423 bool ompi_group_have_remote_peers (ompi_group_t *group);
424
425
426
427
428 int ompi_group_dump (ompi_group_t* group);
429
430
431
432
433 int ompi_group_div_ceil (int num, int den);
434
435 END_C_DECLS
436 #endif