-
Notifications
You must be signed in to change notification settings - Fork 0
/
impl-rma-functions.c
710 lines (636 loc) · 29.8 KB
/
impl-rma-functions.c
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include <mpi.h>
//#include "muk-dl.h"
#include "muk-predefined.h"
#include "impl-scalar-types.h"
#include "wrap-handle-typedefs.h"
#define MUK_EXTERN extern
#include "impl-fpointers.h"
#include "impl-constant-conversions.h"
#include "impl-handle-conversions.h"
#include "impl-predefined-handle.h"
#include "impl-keyval-map.h"
extern int WIN_EH_HANDLE_KEY;
// used by WRAP_Win_create_keyval
int win_copy_attr_trampoline(MPI_Win impl_win, int win_keyval, void *extra_state, void *attribute_val_in, void *attribute_val_out, int *flag)
{
WRAP_Win_copy_attr_function * win_copy_attr_fn;
int rc = find_win_keyval_callbacks(win_keyval, &win_copy_attr_fn, NULL);
if (rc==0) {
printf("%s: find_win_keyval_callbacks failed for win_keyval=%d\n",__func__,win_keyval);
return MPI_ERR_INTERN;
}
if ((intptr_t)win_copy_attr_fn == (intptr_t)MPI_WIN_NULL_COPY_FN) {
#ifdef DEBUG
printf("%s: find_win_keyval_callbacks found MPI_WIN_NULL_COPY_FN for win_keyval=%d\n",__func__,win_keyval);
#endif
*flag = 0;
return MPI_SUCCESS;
}
else if ((intptr_t)win_copy_attr_fn == (intptr_t)MPI_WIN_DUP_FN) {
#ifdef DEBUG
printf("%s: find_win_keyval_callbacks found MPI_WIN_DUP_FN for win_keyval=%d\n",__func__,win_keyval);
#endif
*(void**)attribute_val_out = attribute_val_in;
*flag = 1;
return MPI_SUCCESS;
}
else {
#ifdef DEBUG
printf("%s: find_win_keyval_callbacks found win_copy_attr_fn=%p for win_keyval=%d\n",
__func__,win_copy_attr_fn,win_keyval);
#endif
WRAP_Win wrap_win = OUTPUT_MPI_Win(impl_win);
rc = (*win_copy_attr_fn)(wrap_win, win_keyval, extra_state, attribute_val_in, attribute_val_out, flag);
return RETURN_CODE_MUK_TO_IMPL(rc);
}
}
int win_delete_attr_trampoline(MPI_Win impl_win, int win_keyval, void *attribute_val, void *extra_state)
{
WRAP_Win_delete_attr_function * win_delete_attr_fn;
int rc = find_win_keyval_callbacks(win_keyval, NULL, &win_delete_attr_fn);
if (rc==0) {
printf("%s: find_win_keyval_callbacks failed for win_keyval=%d\n",__func__,win_keyval);
return MPI_ERR_INTERN;
}
if ((intptr_t)win_delete_attr_fn == (intptr_t)MPI_WIN_NULL_DELETE_FN) {
#ifdef DEBUG
printf("%s: find_win_keyval_callbacks found MPI_WIN_NULL_DELETE_FN for win_keyval=%d\n",__func__,win_keyval);
#endif
return MPI_SUCCESS;
}
else {
#ifdef DEBUG
printf("%s: find_win_keyval_callbacks found win_copy_attr_fn=%p for win_keyval=%d\n",
__func__,win_copy_attr_fn,win_keyval);
#endif
WRAP_Win wrap_win = OUTPUT_MPI_Win(impl_win);
rc = (*win_delete_attr_fn)(wrap_win, win_keyval, attribute_val, extra_state);
return RETURN_CODE_MUK_TO_IMPL(rc);
}
}
// errhandler stuff
// "The first argument is the communicator in use.
// The second is the error code to be returned by the MPI routine that raised the error.
// If the routine would have returned MPI_ERR_IN_STATUS, it is the error code returned
// in the status for the request that caused the error handler to be invoked.
// The remaining arguments are “varargs” arguments whose number and meaning is
// implementation-dependent. An implementation should clearly document these arguments."
// TODO document that MUK supports no additional arguments.
void win_errhandler_trampoline(MPI_Win *win, int *error_code, ...)
{
int flag;
WRAP_Win_errhandler_function * fp = NULL;
int rc = IMPL_Win_get_attr(*win, WIN_EH_HANDLE_KEY, &fp, &flag);
if (rc != MPI_SUCCESS || !flag) {
printf("%s: IMPL_Win_get_attr failed: flag=%d rc=%d\n", __func__, flag, rc);
}
WRAP_Win wrap_win = OUTPUT_MPI_Win(*win);
(*fp)(&wrap_win,error_code);
}
int WRAP_Win_create_errhandler(WRAP_Win_errhandler_function *win_errhandler_fn, WRAP_Errhandler *errhandler)
{
MPI_Errhandler impl_errhandler;
//int rc = IMPL_Win_create_errhandler(win_errhandler_fn, &impl_errhandler);
int rc = IMPL_Win_create_errhandler(win_errhandler_trampoline, &impl_errhandler);
*errhandler = OUTPUT_MPI_Errhandler(impl_errhandler);
add_win_errhandler_callback(impl_errhandler, win_errhandler_fn);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_set_errhandler(WRAP_Win win, WRAP_Errhandler errhandler)
{
int rc;
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Errhandler impl_errhandler = CONVERT_MPI_Errhandler(errhandler);
rc = IMPL_Win_set_errhandler(impl_win, impl_errhandler);
if (!IS_PREDEFINED_ERRHANDLER(impl_errhandler))
{
WRAP_Win_errhandler_function * win_errhandler_fn;
if (find_win_errhandler_callback(impl_errhandler, &win_errhandler_fn)) {
rc = IMPL_Win_set_attr(impl_win, WIN_EH_HANDLE_KEY, win_errhandler_fn);
if (rc) {
printf("%s: Win_set_attr failed\n",__func__);
goto end;
}
}
else {
printf("%s: lookup_win_err_pair failed to find a callback for errhandler=%lx\n",
__func__, (intptr_t)impl_errhandler);
}
}
end:
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_get_errhandler(WRAP_Win win, WRAP_Errhandler *errhandler)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Errhandler impl_errhandler;
int rc = IMPL_Win_get_errhandler(impl_win, &impl_errhandler);
*errhandler = OUTPUT_MPI_Errhandler(impl_errhandler);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_call_errhandler(WRAP_Win win, int errorcode)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_call_errhandler(impl_win, errorcode);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
// attribute stuff
int WRAP_Win_create_keyval(WRAP_Win_copy_attr_function *win_copy_attr_fn, WRAP_Win_delete_attr_function *win_delete_attr_fn, int *win_keyval, void *extra_state)
{
bool needs_trampoline = false;
MPI_Win_copy_attr_function * impl_win_copy_attr_fn;
if ((intptr_t)win_copy_attr_fn == (intptr_t)MUK_WIN_NULL_COPY_FN) {
impl_win_copy_attr_fn = MPI_WIN_NULL_COPY_FN;
}
else if ((intptr_t)win_copy_attr_fn == (intptr_t)MUK_WIN_DUP_FN) {
impl_win_copy_attr_fn = MPI_WIN_DUP_FN;
}
else {
needs_trampoline = true;
impl_win_copy_attr_fn = win_copy_attr_trampoline;
}
MPI_Win_delete_attr_function * impl_win_delete_attr_fn;
if ((intptr_t)win_delete_attr_fn == (intptr_t)MUK_WIN_NULL_DELETE_FN) {
impl_win_delete_attr_fn = MPI_WIN_NULL_DELETE_FN;
}
else {
needs_trampoline = true;
impl_win_delete_attr_fn = win_delete_attr_trampoline;
}
int rc = IMPL_Win_create_keyval(impl_win_copy_attr_fn, impl_win_delete_attr_fn, win_keyval, extra_state);
if (rc) goto end;
if (needs_trampoline) {
int rc = add_win_keyval_callbacks(*win_keyval, win_copy_attr_fn, win_delete_attr_fn);
if (rc==0) rc = MPI_ERR_INTERN;
}
end:
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_free_keyval(int *win_keyval)
{
int rc = IMPL_Win_free_keyval(win_keyval);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_get_attr(WRAP_Win win, int win_keyval, void *attribute_val, int *flag)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
const int impl_keyval = KEY_MUK_TO_IMPL(win_keyval);
int rc = IMPL_Win_get_attr(impl_win, impl_keyval, attribute_val, flag);
if (impl_keyval == MPI_WIN_MODEL) {
// this is the only place this is needed, so we inline it
if (**(int**)attribute_val == MPI_WIN_SEPARATE) {
**(int**)attribute_val = MUK_WIN_SEPARATE;
} else if (**(int**)attribute_val == MPI_WIN_UNIFIED) {
**(int**)attribute_val = MUK_WIN_UNIFIED;
}
}
// MPI_WIN_CREATE_FLAVOR does not require conversion
// because MUK, MPICH and OMPI use the same constants
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_set_attr(WRAP_Win win, int win_keyval, void *attribute_val)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_set_attr(impl_win, win_keyval, attribute_val);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_delete_attr(WRAP_Win win, int win_keyval)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_delete_attr(impl_win, win_keyval);
if (rc) goto end;
end:
return RETURN_CODE_IMPL_TO_MUK(rc);
}
// important functions
int WRAP_Accumulate(const void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Accumulate(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Accumulate_c(const void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Accumulate_c(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Compare_and_swap(const void *origin_addr, const void *compare_addr, void *result_addr, WRAP_Datatype datatype, int target_rank, WRAP_Aint target_disp, WRAP_Win win)
{
MPI_Datatype impl_datatype = CONVERT_MPI_Datatype(datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Compare_and_swap(origin_addr, compare_addr, result_addr, impl_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Fetch_and_op(const void *origin_addr, void *result_addr, WRAP_Datatype datatype, int target_rank, WRAP_Aint target_disp, WRAP_Op op, WRAP_Win win)
{
MPI_Datatype impl_datatype = CONVERT_MPI_Datatype(datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Fetch_and_op(origin_addr, result_addr, impl_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, impl_op, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Get(void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Get(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Get_accumulate(const void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, void *result_addr, int result_count, WRAP_Datatype result_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_result_datatype = CONVERT_MPI_Datatype(result_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Get_accumulate(origin_addr, origin_count, impl_origin_datatype, result_addr, result_count, impl_result_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Get_accumulate_c(const void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, void *result_addr, WRAP_Count result_count, WRAP_Datatype result_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_result_datatype = CONVERT_MPI_Datatype(result_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Get_accumulate_c(origin_addr, origin_count, impl_origin_datatype, result_addr, result_count, impl_result_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
#if MPI_VERSION >= 4
int WRAP_Get_c(void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Get_c(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Put(const void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Put(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Put_c(const void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Win win)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Put_c(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Raccumulate(const void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Raccumulate(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Raccumulate_c(const void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Raccumulate_c(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Rget(void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Rget(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Rget_accumulate(const void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, void *result_addr, int result_count, WRAP_Datatype result_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_result_datatype = CONVERT_MPI_Datatype(result_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Rget_accumulate(origin_addr, origin_count, impl_origin_datatype, result_addr, result_count, impl_result_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Rget_accumulate_c(const void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, void *result_addr, WRAP_Count result_count, WRAP_Datatype result_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Op op, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_result_datatype = CONVERT_MPI_Datatype(result_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Op impl_op = CONVERT_MPI_Op(op);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Rget_accumulate_c(origin_addr, origin_count, impl_origin_datatype, result_addr, result_count, impl_result_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_op, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
#if MPI_VERSION >= 4
int WRAP_Rget_c(void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Rget_c(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Rput(const void *origin_addr, int origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, int target_count, WRAP_Datatype target_datatype, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Rput(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Rput_c(const void *origin_addr, WRAP_Count origin_count, WRAP_Datatype origin_datatype, int target_rank, WRAP_Aint target_disp, WRAP_Count target_count, WRAP_Datatype target_datatype, WRAP_Win win, WRAP_Request *request)
{
MPI_Datatype impl_origin_datatype = CONVERT_MPI_Datatype(origin_datatype);
MPI_Datatype impl_target_datatype = CONVERT_MPI_Datatype(target_datatype);
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Request impl_request;
int rc = IMPL_Rput_c(origin_addr, origin_count, impl_origin_datatype, RANK_MUK_TO_IMPL(target_rank), target_disp, target_count, impl_target_datatype, impl_win, &impl_request);
*request = OUTPUT_MPI_Request(impl_request);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Win_allocate(WRAP_Aint size, int disp_unit, WRAP_Info info, WRAP_Comm comm, void *baseptr, WRAP_Win *win)
{
MPI_Comm impl_comm = CONVERT_MPI_Comm(comm);
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win;
int rc = IMPL_Win_allocate(size, disp_unit, impl_info, impl_comm, baseptr, &impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Win_allocate_c(WRAP_Aint size, WRAP_Aint disp_unit, WRAP_Info info, WRAP_Comm comm, void *baseptr, WRAP_Win *win)
{
MPI_Comm impl_comm = CONVERT_MPI_Comm(comm);
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win;
int rc = IMPL_Win_allocate_c(size, disp_unit, impl_info, impl_comm, baseptr, &impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Win_allocate_shared(WRAP_Aint size, int disp_unit, WRAP_Info info, WRAP_Comm comm, void *baseptr, WRAP_Win *win)
{
MPI_Comm impl_comm = CONVERT_MPI_Comm(comm);
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win;
int rc = IMPL_Win_allocate_shared(size, disp_unit, impl_info, impl_comm, baseptr, &impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Win_allocate_shared_c(WRAP_Aint size, WRAP_Aint disp_unit, WRAP_Info info, WRAP_Comm comm, void *baseptr, WRAP_Win *win)
{
MPI_Comm impl_comm = CONVERT_MPI_Comm(comm);
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win;
int rc = IMPL_Win_allocate_shared_c(size, disp_unit, impl_info, impl_comm, baseptr, &impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Win_attach(WRAP_Win win, void *base, WRAP_Aint size)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_attach(impl_win, base, size);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_complete(WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_complete(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_create(void *base, WRAP_Aint size, int disp_unit, WRAP_Info info, WRAP_Comm comm, WRAP_Win *win)
{
MPI_Comm impl_comm = CONVERT_MPI_Comm(comm);
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win;
int rc = IMPL_Win_create(base, size, disp_unit, impl_info, impl_comm, &impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Win_create_c(void *base, WRAP_Aint size, WRAP_Aint disp_unit, WRAP_Info info, WRAP_Comm comm, WRAP_Win *win)
{
MPI_Comm impl_comm = CONVERT_MPI_Comm(comm);
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win;
int rc = IMPL_Win_create_c(base, size, disp_unit, impl_info, impl_comm, &impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Win_create_dynamic(WRAP_Info info, WRAP_Comm comm, WRAP_Win *win)
{
MPI_Comm impl_comm = CONVERT_MPI_Comm(comm);
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win;
int rc = IMPL_Win_create_dynamic(impl_info, impl_comm, &impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_detach(WRAP_Win win, const void *base)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_detach(impl_win, base);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_fence(int assert, WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_fence(RMA_MODE_MUK_TO_IMPL(assert), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_flush(int rank, WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_flush(RANK_MUK_TO_IMPL(rank), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_flush_all(WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_flush_all(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_flush_local(int rank, WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_flush_local(RANK_MUK_TO_IMPL(rank), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_flush_local_all(WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_flush_local_all(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_free(WRAP_Win *win)
{
MPI_Win impl_win = CONVERT_MPI_Win(*win);
int rc = IMPL_Win_free(&impl_win);
*win = OUTPUT_MPI_Win(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_get_group(WRAP_Win win, WRAP_Group *group)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Group impl_group;
int rc = IMPL_Win_get_group(impl_win, &impl_group);
*group = OUTPUT_MPI_Group(impl_group);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_get_info(WRAP_Win win, WRAP_Info *info_used)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
MPI_Info impl_info_used;
int rc = IMPL_Win_get_info(impl_win, &impl_info_used);
*info_used = OUTPUT_MPI_Info(impl_info_used);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_get_name(WRAP_Win win, char *win_name, int *resultlen)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_get_name(impl_win, win_name, resultlen);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_lock(int lock_type, int rank, int assert, WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
// this is the only place this is used so we inline it
int impl_type = MPI_UNDEFINED;
if (lock_type == MUK_LOCK_EXCLUSIVE) {
impl_type = MPI_LOCK_EXCLUSIVE;
} else if (lock_type == MUK_LOCK_SHARED) {
impl_type = MPI_LOCK_SHARED;
}
int rc = IMPL_Win_lock(impl_type, RANK_MUK_TO_IMPL(rank), RMA_MODE_MUK_TO_IMPL(assert), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_lock_all(int assert, WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_lock_all(RMA_MODE_MUK_TO_IMPL(assert), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_post(WRAP_Group group, int assert, WRAP_Win win)
{
MPI_Group impl_group = CONVERT_MPI_Group(group);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_post(impl_group, RMA_MODE_MUK_TO_IMPL(assert), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_set_info(WRAP_Win win, WRAP_Info info)
{
MPI_Info impl_info = CONVERT_MPI_Info(info);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_set_info(impl_win, impl_info);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_set_name(WRAP_Win win, const char *win_name)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_set_name(impl_win, win_name);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_shared_query(WRAP_Win win, int rank, WRAP_Aint *size, int *disp_unit, void *baseptr)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_shared_query(impl_win, RANK_MUK_TO_IMPL(rank), size, disp_unit, baseptr);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#if MPI_VERSION >= 4
int WRAP_Win_shared_query_c(WRAP_Win win, int rank, WRAP_Aint *size, WRAP_Aint *disp_unit, void *baseptr)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_shared_query_c(impl_win, RANK_MUK_TO_IMPL(rank), size, disp_unit, baseptr);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
#endif
int WRAP_Win_start(WRAP_Group group, int assert, WRAP_Win win)
{
MPI_Group impl_group = CONVERT_MPI_Group(group);
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_start(impl_group, RMA_MODE_MUK_TO_IMPL(assert), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_sync(WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_sync(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_test(WRAP_Win win, int *flag)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_test(impl_win, flag);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_unlock(int rank, WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_unlock(RANK_MUK_TO_IMPL(rank), impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_unlock_all(WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_unlock_all(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}
int WRAP_Win_wait(WRAP_Win win)
{
MPI_Win impl_win = CONVERT_MPI_Win(win);
int rc = IMPL_Win_wait(impl_win);
return RETURN_CODE_IMPL_TO_MUK(rc);
}