MeDiPack  1.3.3
A Message Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
ampiFunctions.hpp
Go to the documentation of this file.
1/*
2 * MeDiPack, a Message Differentiation Package
3 *
4 * Copyright (C) 2015-2025 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of MeDiPack (http://scicomp.rptu.de/software/medi).
11 *
12 * MeDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation, either
15 * version 3 of the License, or (at your option) any later version.
16 *
17 * MeDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU
23 * Lesser General Public License along with MeDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * Authors: Max Sagebaum, Tim Albring (SciComp, University of Kaiserslautern-Landau)
27 */
28
29#pragma once
30
31#include "../ampi/async.hpp"
32#include "../ampi/message.hpp"
37#include "../mpiTools.h"
38
42namespace medi {
43#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
44 template<typename DATATYPE>
47 typename DATATYPE::IndexType* bufIndices;
48 typename DATATYPE::PrimalType* bufPrimals;
49 /* required for async */ void* bufAdjoints;
52 int count;
53 DATATYPE* datatype;
54 int dest;
55 int tag;
57
59 if(nullptr != bufIndices) {
60 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
61 bufIndices = nullptr;
62 }
63 if(nullptr != bufPrimals) {
64 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
65 bufPrimals = nullptr;
66 }
67 }
68 };
69
70
71 template<typename DATATYPE>
72 void AMPI_Bsend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
74 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
75 (void)adType;
76
77 h->bufAdjoints = nullptr;
78 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
79 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
80 // Primal buffers are always linear in space so we can accesses them in one sweep
81 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
82
83
85
86 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
87 }
88
89 template<typename DATATYPE>
90 void AMPI_Bsend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
92 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
93 (void)adType;
94
95 h->bufAdjoints = nullptr;
96 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
97 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
98 // Adjoint buffers are always linear in space so we can accesses them in one sweep
99 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
100
101
103
104 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
105 }
106
107 template<typename DATATYPE>
108 void AMPI_Bsend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
110 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
111 (void)adType;
112
113 h->bufAdjoints = nullptr;
114 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
115 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
116
118
119 // Adjoint buffers are always linear in space so we can accesses them in one sweep
120 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
121 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
122 }
123
124 template<typename DATATYPE>
125 int AMPI_Bsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
126 AMPI_Comm comm) {
127 int rStatus;
128 ADToolInterface const* adType = selectADTool(datatype->getADTool());
129
130 if(!adType->isActiveType()) {
131 // call the regular function if the type is not active
132 rStatus = MPI_Bsend(buf, count, datatype->getMpiType(), dest, tag, comm);
133 } else {
134
135 // the type is an AD type so handle the buffers
137 typename DATATYPE::ModifiedType* bufMod = nullptr;
138 int bufElements = 0;
139
140 // compute the total size of the buffer
141 bufElements = count;
142
143 if(datatype->isModifiedBufferRequired() ) {
144 datatype->createModifiedTypeBuffer(bufMod, bufElements);
145 } else {
146 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
147 }
148
149 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
150 if(adType->isHandleRequired()) {
152 }
153 adType->startAssembly(h);
154 if(datatype->isModifiedBufferRequired()) {
155 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
156 }
157
158 if(nullptr != h) {
159 // gather the information for the reverse sweep
160
161 // create the index buffers
162 h->bufCount = datatype->computeActiveElements(count);
163 h->bufTotalSize = datatype->computeActiveElements(bufElements);
164 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
165
166
167
168
169 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
170
171
172 // pack all the variables in the handle
176 h->count = count;
177 h->datatype = datatype;
178 h->dest = dest;
179 h->tag = tag;
180 h->comm = comm;
181 }
182
183
184 rStatus = MPI_Bsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
185 adType->addToolAction(h);
186
187
188 if(nullptr != h) {
189 // handle the recv buffers
190 }
191
192 adType->stopAssembly(h);
193
194 if(datatype->isModifiedBufferRequired() ) {
195 datatype->deleteModifiedTypeBuffer(bufMod);
196 }
197
198 // handle is deleted by the AD tool
199 }
200
201 return rStatus;
202 }
203
204#endif
205#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
206 template<typename DATATYPE>
209 typename DATATYPE::IndexType* bufIndices;
210 typename DATATYPE::PrimalType* bufPrimals;
211 /* required for async */ void* bufAdjoints;
214 int count;
215 DATATYPE* datatype;
216 int dest;
217 int tag;
219
221 if(nullptr != bufIndices) {
222 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
223 bufIndices = nullptr;
224 }
225 if(nullptr != bufPrimals) {
226 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
227 bufPrimals = nullptr;
228 }
229 }
230 };
231
232 template<typename DATATYPE>
234 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
235 typename DATATYPE::ModifiedType* bufMod;
236 int count;
237 DATATYPE* datatype;
238 int dest;
239 int tag;
242 };
243
244 template<typename DATATYPE>
245 void AMPI_Ibsend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
247 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
248 (void)adType;
249
250 h->bufAdjoints = nullptr;
251 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
252 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
253 // Primal buffers are always linear in space so we can accesses them in one sweep
254 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
255
256
258 &h->requestReverse);
259
260 }
261
262 template<typename DATATYPE>
263 void AMPI_Ibsend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
264
266 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
267 (void)adType;
268 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
269
270 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
271 }
272
273 template<typename DATATYPE>
274 void AMPI_Ibsend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
276 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
277 (void)adType;
278
279 h->bufAdjoints = nullptr;
280 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
281 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
282 // Adjoint buffers are always linear in space so we can accesses them in one sweep
283 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
284
285
287 &h->requestReverse);
288
289 }
290
291 template<typename DATATYPE>
292 void AMPI_Ibsend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
293
295 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
296 (void)adType;
297 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
298
299 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
300 }
301
302 template<typename DATATYPE>
303 void AMPI_Ibsend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
305 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
306 (void)adType;
307
308 h->bufAdjoints = nullptr;
309 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
310 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
311
313 &h->requestReverse);
314
315 }
316
317 template<typename DATATYPE>
318 void AMPI_Ibsend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
319
321 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
322 (void)adType;
323 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
324
325 // Adjoint buffers are always linear in space so we can accesses them in one sweep
326 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
327 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
328 }
329
330 template<typename DATATYPE>
331 int AMPI_Ibsend_finish(HandleBase* handle);
332 template<typename DATATYPE>
333 int AMPI_Ibsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
334 AMPI_Comm comm, AMPI_Request* request) {
335 int rStatus;
336 ADToolInterface const* adType = selectADTool(datatype->getADTool());
337
338 if(!adType->isActiveType()) {
339 // call the regular function if the type is not active
340 rStatus = MPI_Ibsend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
341 } else {
342
343 // the type is an AD type so handle the buffers
345 typename DATATYPE::ModifiedType* bufMod = nullptr;
346 int bufElements = 0;
347
348 // compute the total size of the buffer
349 bufElements = count;
350
351 if(datatype->isModifiedBufferRequired() ) {
352 datatype->createModifiedTypeBuffer(bufMod, bufElements);
353 } else {
354 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
355 }
356
357 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
358 if(adType->isHandleRequired()) {
360 }
361 adType->startAssembly(h);
362 if(datatype->isModifiedBufferRequired()) {
363 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
364 }
365
366 if(nullptr != h) {
367 // gather the information for the reverse sweep
368
369 // create the index buffers
370 h->bufCount = datatype->computeActiveElements(count);
371 h->bufTotalSize = datatype->computeActiveElements(bufElements);
372 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
373
374
375
376
377 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
378
379
380 // pack all the variables in the handle
384 h->count = count;
385 h->datatype = datatype;
386 h->dest = dest;
387 h->tag = tag;
388 h->comm = comm;
389 }
390
391
392 rStatus = MPI_Ibsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
393
395 asyncHandle->buf = buf;
396 asyncHandle->bufMod = bufMod;
397 asyncHandle->count = count;
398 asyncHandle->datatype = datatype;
399 asyncHandle->dest = dest;
400 asyncHandle->tag = tag;
401 asyncHandle->comm = comm;
402 asyncHandle->toolHandle = h;
403 request->handle = asyncHandle;
405
406 // create adjoint wait
407 if(nullptr != h) {
410 adType->addToolAction(waitH);
411 }
412 }
413
414 return rStatus;
415 }
416
417 template<typename DATATYPE>
419 int rStatus = 0;
420
421 AMPI_Ibsend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Ibsend_AsyncHandle<DATATYPE>*>(handle);
422 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
423 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
424 int count = asyncHandle->count;
425 DATATYPE* datatype = asyncHandle->datatype;
426 int dest = asyncHandle->dest;
427 int tag = asyncHandle->tag;
428 AMPI_Comm comm = asyncHandle->comm;
429 AMPI_Request* request = asyncHandle->request;
431 ADToolInterface const* adType = selectADTool(datatype->getADTool());
432 MEDI_UNUSED(h); // Unused generated to ignore warnings
433 MEDI_UNUSED(buf); // Unused generated to ignore warnings
434 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
435 MEDI_UNUSED(count); // Unused generated to ignore warnings
436 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
437 MEDI_UNUSED(dest); // Unused generated to ignore warnings
438 MEDI_UNUSED(tag); // Unused generated to ignore warnings
439 MEDI_UNUSED(comm); // Unused generated to ignore warnings
440 MEDI_UNUSED(request); // Unused generated to ignore warnings
441
442 delete asyncHandle;
443
444 if(adType->isActiveType()) {
445
446 adType->addToolAction(h);
447
448
449 if(nullptr != h) {
450 // handle the recv buffers
451 }
452
453 adType->stopAssembly(h);
454
455 if(datatype->isModifiedBufferRequired() ) {
456 datatype->deleteModifiedTypeBuffer(bufMod);
457 }
458
459 // handle is deleted by the AD tool
460 }
461
462 return rStatus;
463 }
464
465#endif
466#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
467
468 template<typename DATATYPE>
470 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
471 typename DATATYPE::ModifiedType* bufMod;
472 int count;
473 DATATYPE* datatype;
474 int dest;
475 int tag;
478 };
479
480
481 template<typename DATATYPE>
483 template<typename DATATYPE>
485 template<typename DATATYPE>
487 template<typename DATATYPE>
488 int AMPI_Bsend_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
489 AMPI_Comm comm, AMPI_Request* request) {
490 int rStatus;
491 ADToolInterface const* adType = selectADTool(datatype->getADTool());
492
493 if(!adType->isActiveType()) {
494 // call the regular function if the type is not active
495 rStatus = MPI_Bsend_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
496 } else {
497
498 // the type is an AD type so handle the buffers
500 typename DATATYPE::ModifiedType* bufMod = nullptr;
501 int bufElements = 0;
502
503 // compute the total size of the buffer
504 bufElements = count;
505
506 if(datatype->isModifiedBufferRequired() ) {
507 datatype->createModifiedTypeBuffer(bufMod, bufElements);
508 } else {
509 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
510 }
511
512 rStatus = MPI_Bsend_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
513
515 asyncHandle->buf = buf;
516 asyncHandle->bufMod = bufMod;
517 asyncHandle->count = count;
518 asyncHandle->datatype = datatype;
519 asyncHandle->dest = dest;
520 asyncHandle->tag = tag;
521 asyncHandle->comm = comm;
522 asyncHandle->toolHandle = h;
523 request->handle = asyncHandle;
527 }
528
529 return rStatus;
530 }
531
532 template<typename DATATYPE>
534 int rStatus = 0;
535
537 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
538 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
539 int count = asyncHandle->count;
540 DATATYPE* datatype = asyncHandle->datatype;
541 int dest = asyncHandle->dest;
542 int tag = asyncHandle->tag;
543 AMPI_Comm comm = asyncHandle->comm;
544 AMPI_Request* request = asyncHandle->request;
546 ADToolInterface const* adType = selectADTool(datatype->getADTool());
547 MEDI_UNUSED(h); // Unused generated to ignore warnings
548 MEDI_UNUSED(buf); // Unused generated to ignore warnings
549 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
550 MEDI_UNUSED(count); // Unused generated to ignore warnings
551 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
552 MEDI_UNUSED(dest); // Unused generated to ignore warnings
553 MEDI_UNUSED(tag); // Unused generated to ignore warnings
554 MEDI_UNUSED(comm); // Unused generated to ignore warnings
555 MEDI_UNUSED(request); // Unused generated to ignore warnings
556
557
558 if(adType->isActiveType()) {
559
560 int bufElements = 0;
561
562 // recompute the total size of the buffer
563 bufElements = count;
564 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
565 if(adType->isHandleRequired()) {
567 }
568 adType->startAssembly(h);
569 if(datatype->isModifiedBufferRequired()) {
570 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
571 }
572
573 if(nullptr != h) {
574 // gather the information for the reverse sweep
575
576 // create the index buffers
577 h->bufCount = datatype->computeActiveElements(count);
578 h->bufTotalSize = datatype->computeActiveElements(bufElements);
579 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
580
581
582
583
584 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
585
586
587 // pack all the variables in the handle
591 h->count = count;
592 h->datatype = datatype;
593 h->dest = dest;
594 h->tag = tag;
595 h->comm = comm;
596 }
597
598
599 asyncHandle->toolHandle = h;
600
601 // create adjoint wait
602 if(nullptr != h) {
605 adType->addToolAction(waitH);
606 }
607 }
608
609 return rStatus;
610 }
611
612 template<typename DATATYPE>
614 int rStatus = 0;
615
617 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
618 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
619 int count = asyncHandle->count;
620 DATATYPE* datatype = asyncHandle->datatype;
621 int dest = asyncHandle->dest;
622 int tag = asyncHandle->tag;
623 AMPI_Comm comm = asyncHandle->comm;
624 AMPI_Request* request = asyncHandle->request;
626 ADToolInterface const* adType = selectADTool(datatype->getADTool());
627 MEDI_UNUSED(h); // Unused generated to ignore warnings
628 MEDI_UNUSED(buf); // Unused generated to ignore warnings
629 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
630 MEDI_UNUSED(count); // Unused generated to ignore warnings
631 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
632 MEDI_UNUSED(dest); // Unused generated to ignore warnings
633 MEDI_UNUSED(tag); // Unused generated to ignore warnings
634 MEDI_UNUSED(comm); // Unused generated to ignore warnings
635 MEDI_UNUSED(request); // Unused generated to ignore warnings
636
637
638 if(adType->isActiveType()) {
639
640 adType->addToolAction(h);
641
642
643 if(nullptr != h) {
644 // handle the recv buffers
645 }
646
647 adType->stopAssembly(h);
648 }
649
650 return rStatus;
651 }
652
653 template<typename DATATYPE>
655 int rStatus = 0;
656
658 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
659 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
660 int count = asyncHandle->count;
661 DATATYPE* datatype = asyncHandle->datatype;
662 int dest = asyncHandle->dest;
663 int tag = asyncHandle->tag;
664 AMPI_Comm comm = asyncHandle->comm;
665 AMPI_Request* request = asyncHandle->request;
667 ADToolInterface const* adType = selectADTool(datatype->getADTool());
668 MEDI_UNUSED(h); // Unused generated to ignore warnings
669 MEDI_UNUSED(buf); // Unused generated to ignore warnings
670 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
671 MEDI_UNUSED(count); // Unused generated to ignore warnings
672 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
673 MEDI_UNUSED(dest); // Unused generated to ignore warnings
674 MEDI_UNUSED(tag); // Unused generated to ignore warnings
675 MEDI_UNUSED(comm); // Unused generated to ignore warnings
676 MEDI_UNUSED(request); // Unused generated to ignore warnings
677
678 delete asyncHandle;
679
680 if(adType->isActiveType()) {
681
682
683 if(datatype->isModifiedBufferRequired() ) {
684 datatype->deleteModifiedTypeBuffer(bufMod);
685 }
686
687 // handle is deleted by the AD tool
688 }
689
690 return rStatus;
691 }
692
693#endif
694#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
695 template<typename DATATYPE>
698 typename DATATYPE::IndexType* bufIndices;
699 typename DATATYPE::PrimalType* bufPrimals;
700 typename DATATYPE::PrimalType* bufOldPrimals;
701 /* required for async */ void* bufAdjoints;
704 int count;
705 DATATYPE* datatype;
708
710 if(nullptr != bufIndices) {
711 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
712 bufIndices = nullptr;
713 }
714 if(nullptr != bufPrimals) {
715 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
716 bufPrimals = nullptr;
717 }
718 if(nullptr != bufOldPrimals) {
719 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
720 bufOldPrimals = nullptr;
721 }
722 }
723 };
724
725 template<typename DATATYPE>
727 typename DATATYPE::Type* buf;
728 typename DATATYPE::ModifiedType* bufMod;
729 int count;
730 DATATYPE* datatype;
734 };
735
736 template<typename DATATYPE>
737 void AMPI_Imrecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
739 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
740 (void)adType;
741
742 h->bufAdjoints = nullptr;
743 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
744 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
745
747 h->reverse_send);
748
749 }
750
751 template<typename DATATYPE>
752 void AMPI_Imrecv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
753
755 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
756 (void)adType;
757 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
758
759 if(adType->isOldPrimalsRequired()) {
760 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
761 }
762 // Primal buffers are always linear in space so we can accesses them in one sweep
763 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
764 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
765 }
766
767 template<typename DATATYPE>
768 void AMPI_Imrecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
770 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
771 (void)adType;
772
773 h->bufAdjoints = nullptr;
774 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
775 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
776
778 h->reverse_send);
779
780 }
781
782 template<typename DATATYPE>
783 void AMPI_Imrecv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
784
786 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
787 (void)adType;
788 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
789
790 // Adjoint buffers are always linear in space so we can accesses them in one sweep
791 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
792 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
793 }
794
795 template<typename DATATYPE>
796 void AMPI_Imrecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
798 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
799 (void)adType;
800
801 h->bufAdjoints = nullptr;
802 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
803 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
804 // Adjoint buffers are always linear in space so we can accesses them in one sweep
805 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
806
807 if(adType->isOldPrimalsRequired()) {
808 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
809 }
810
812 h->reverse_send);
813
814 }
815
816 template<typename DATATYPE>
817 void AMPI_Imrecv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
818
820 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
821 (void)adType;
822 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
823
824 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
825 }
826
827 template<typename DATATYPE>
828 int AMPI_Imrecv_finish(HandleBase* handle);
829 template<typename DATATYPE>
830 int AMPI_Imrecv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, AMPI_Message* message,
831 AMPI_Request* request, IrecvAdjCall reverse_send = IrecvAdjCall::Isend) {
832 int rStatus;
833 ADToolInterface const* adType = selectADTool(datatype->getADTool());
834
835 if(!adType->isActiveType()) {
836 // call the regular function if the type is not active
837 rStatus = MPI_Imrecv(buf, count, datatype->getMpiType(), &message->message, &request->request);
838 } else {
839
840 // the type is an AD type so handle the buffers
842 typename DATATYPE::ModifiedType* bufMod = nullptr;
843 int bufElements = 0;
844
845 // compute the total size of the buffer
846 bufElements = count;
847
848 if(datatype->isModifiedBufferRequired() ) {
849 datatype->createModifiedTypeBuffer(bufMod, bufElements);
850 } else {
851 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
852 }
853
854 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
855 if(adType->isHandleRequired()) {
857 }
858 adType->startAssembly(h);
859
860 if(nullptr != h) {
861 // gather the information for the reverse sweep
862
863 // create the index buffers
864 h->bufCount = datatype->computeActiveElements(count);
865 h->bufTotalSize = datatype->computeActiveElements(bufElements);
866 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
867
868
869 // extract the old primal values from the recv buffer if the AD tool
870 // needs the primal values reset
871 if(adType->isOldPrimalsRequired()) {
872 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
873 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
874 }
875
876
877
878 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
879
880 // pack all the variables in the handle
884 h->count = count;
885 h->datatype = datatype;
886 h->message = *message;
887 h->reverse_send = reverse_send;
888 }
889
890 if(!datatype->isModifiedBufferRequired()) {
891 datatype->clearIndices(buf, 0, count);
892 }
893
894 rStatus = MPI_Imrecv(bufMod, count, datatype->getModifiedMpiType(), &message->message, &request->request);
895
897 asyncHandle->buf = buf;
898 asyncHandle->bufMod = bufMod;
899 asyncHandle->count = count;
900 asyncHandle->datatype = datatype;
901 asyncHandle->message = message;
902 asyncHandle->reverse_send = reverse_send;
903 asyncHandle->toolHandle = h;
904 request->handle = asyncHandle;
906
907 // create adjoint wait
908 if(nullptr != h) {
911 adType->addToolAction(waitH);
912 }
913 }
914
915 return rStatus;
916 }
917
918 template<typename DATATYPE>
920 int rStatus = 0;
921
922 AMPI_Imrecv_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Imrecv_AsyncHandle<DATATYPE>*>(handle);
923 typename DATATYPE::Type* buf = asyncHandle->buf;
924 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
925 int count = asyncHandle->count;
926 DATATYPE* datatype = asyncHandle->datatype;
927 AMPI_Message* message = asyncHandle->message;
928 AMPI_Request* request = asyncHandle->request;
929 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
931 ADToolInterface const* adType = selectADTool(datatype->getADTool());
932 MEDI_UNUSED(h); // Unused generated to ignore warnings
933 MEDI_UNUSED(buf); // Unused generated to ignore warnings
934 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
935 MEDI_UNUSED(count); // Unused generated to ignore warnings
936 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
937 MEDI_UNUSED(message); // Unused generated to ignore warnings
938 MEDI_UNUSED(request); // Unused generated to ignore warnings
939 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
940
941 delete asyncHandle;
942
943 if(adType->isActiveType()) {
944
945 adType->addToolAction(h);
946
947 if(datatype->isModifiedBufferRequired()) {
948 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
949 }
950
951 if(nullptr != h) {
952 // handle the recv buffers
953 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
954 }
955
956 adType->stopAssembly(h);
957
958 if(datatype->isModifiedBufferRequired() ) {
959 datatype->deleteModifiedTypeBuffer(bufMod);
960 }
961
962 // handle is deleted by the AD tool
963 }
964
965 return rStatus;
966 }
967
968#endif
969#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
970 template<typename DATATYPE>
973 typename DATATYPE::IndexType* bufIndices;
974 typename DATATYPE::PrimalType* bufPrimals;
975 typename DATATYPE::PrimalType* bufOldPrimals;
976 /* required for async */ void* bufAdjoints;
979 int count;
980 DATATYPE* datatype;
982 int tag;
985
987 if(nullptr != bufIndices) {
988 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
989 bufIndices = nullptr;
990 }
991 if(nullptr != bufPrimals) {
992 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
993 bufPrimals = nullptr;
994 }
995 if(nullptr != bufOldPrimals) {
996 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
997 bufOldPrimals = nullptr;
998 }
999 }
1000 };
1001
1002 template<typename DATATYPE>
1004 typename DATATYPE::Type* buf;
1005 typename DATATYPE::ModifiedType* bufMod;
1007 DATATYPE* datatype;
1009 int tag;
1013 };
1014
1015 template<typename DATATYPE>
1016 void AMPI_Irecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1018 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1019 (void)adType;
1020
1021 h->bufAdjoints = nullptr;
1022 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1023 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1024
1027
1028 }
1029
1030 template<typename DATATYPE>
1031 void AMPI_Irecv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1032
1034 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1035 (void)adType;
1036 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1037
1038 if(adType->isOldPrimalsRequired()) {
1039 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
1040 }
1041 // Primal buffers are always linear in space so we can accesses them in one sweep
1042 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1043 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1044 }
1045
1046 template<typename DATATYPE>
1047 void AMPI_Irecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1049 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1050 (void)adType;
1051
1052 h->bufAdjoints = nullptr;
1053 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1054 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1055
1058
1059 }
1060
1061 template<typename DATATYPE>
1062 void AMPI_Irecv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1063
1065 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1066 (void)adType;
1067 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1068
1069 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1070 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1071 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1072 }
1073
1074 template<typename DATATYPE>
1075 void AMPI_Irecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
1077 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1078 (void)adType;
1079
1080 h->bufAdjoints = nullptr;
1081 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1082 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1083 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1084 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1085
1086 if(adType->isOldPrimalsRequired()) {
1087 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
1088 }
1089
1092
1093 }
1094
1095 template<typename DATATYPE>
1096 void AMPI_Irecv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1097
1099 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1100 (void)adType;
1101 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1102
1103 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1104 }
1105
1106 template<typename DATATYPE>
1107 int AMPI_Irecv_finish(HandleBase* handle);
1108 template<typename DATATYPE>
1109 int AMPI_Irecv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int source, int tag, AMPI_Comm comm,
1110 AMPI_Request* request, IrecvAdjCall reverse_send = IrecvAdjCall::Isend) {
1111 int rStatus;
1112 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1113
1114 if(!adType->isActiveType()) {
1115 // call the regular function if the type is not active
1116 rStatus = MPI_Irecv(buf, count, datatype->getMpiType(), source, tag, comm, &request->request);
1117 } else {
1118
1119 // the type is an AD type so handle the buffers
1121 typename DATATYPE::ModifiedType* bufMod = nullptr;
1122 int bufElements = 0;
1123
1124 // compute the total size of the buffer
1125 bufElements = count;
1126
1127 if(datatype->isModifiedBufferRequired() ) {
1128 datatype->createModifiedTypeBuffer(bufMod, bufElements);
1129 } else {
1130 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
1131 }
1132
1133 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
1134 if(adType->isHandleRequired()) {
1136 }
1137 adType->startAssembly(h);
1138
1139 if(nullptr != h) {
1140 // gather the information for the reverse sweep
1141
1142 // create the index buffers
1143 h->bufCount = datatype->computeActiveElements(count);
1144 h->bufTotalSize = datatype->computeActiveElements(bufElements);
1145 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
1146
1147
1148 // extract the old primal values from the recv buffer if the AD tool
1149 // needs the primal values reset
1150 if(adType->isOldPrimalsRequired()) {
1151 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
1152 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
1153 }
1154
1155
1156
1157 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
1158
1159 // pack all the variables in the handle
1163 h->count = count;
1164 h->datatype = datatype;
1165 h->source = source;
1166 h->tag = tag;
1167 h->comm = comm;
1168 h->reverse_send = reverse_send;
1169 }
1170
1171 if(!datatype->isModifiedBufferRequired()) {
1172 datatype->clearIndices(buf, 0, count);
1173 }
1174
1175 rStatus = MPI_Irecv(bufMod, count, datatype->getModifiedMpiType(), source, tag, comm, &request->request);
1176
1178 asyncHandle->buf = buf;
1179 asyncHandle->bufMod = bufMod;
1180 asyncHandle->count = count;
1181 asyncHandle->datatype = datatype;
1182 asyncHandle->source = source;
1183 asyncHandle->tag = tag;
1184 asyncHandle->comm = comm;
1185 asyncHandle->reverse_send = reverse_send;
1186 asyncHandle->toolHandle = h;
1187 request->handle = asyncHandle;
1189
1190 // create adjoint wait
1191 if(nullptr != h) {
1194 adType->addToolAction(waitH);
1195 }
1196 }
1197
1198 return rStatus;
1199 }
1200
1201 template<typename DATATYPE>
1203 int rStatus = 0;
1204
1205 AMPI_Irecv_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Irecv_AsyncHandle<DATATYPE>*>(handle);
1206 typename DATATYPE::Type* buf = asyncHandle->buf;
1207 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1208 int count = asyncHandle->count;
1209 DATATYPE* datatype = asyncHandle->datatype;
1210 int source = asyncHandle->source;
1211 int tag = asyncHandle->tag;
1212 AMPI_Comm comm = asyncHandle->comm;
1213 AMPI_Request* request = asyncHandle->request;
1214 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
1216 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1217 MEDI_UNUSED(h); // Unused generated to ignore warnings
1218 MEDI_UNUSED(buf); // Unused generated to ignore warnings
1219 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
1220 MEDI_UNUSED(count); // Unused generated to ignore warnings
1221 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
1222 MEDI_UNUSED(source); // Unused generated to ignore warnings
1223 MEDI_UNUSED(tag); // Unused generated to ignore warnings
1224 MEDI_UNUSED(comm); // Unused generated to ignore warnings
1225 MEDI_UNUSED(request); // Unused generated to ignore warnings
1226 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
1227
1228 delete asyncHandle;
1229
1230 if(adType->isActiveType()) {
1231
1232 adType->addToolAction(h);
1233
1234 if(datatype->isModifiedBufferRequired()) {
1235 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
1236 }
1237
1238 if(nullptr != h) {
1239 // handle the recv buffers
1240 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
1241 }
1242
1243 adType->stopAssembly(h);
1244
1245 if(datatype->isModifiedBufferRequired() ) {
1246 datatype->deleteModifiedTypeBuffer(bufMod);
1247 }
1248
1249 // handle is deleted by the AD tool
1250 }
1251
1252 return rStatus;
1253 }
1254
1255#endif
1256#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
1257 template<typename DATATYPE>
1260 typename DATATYPE::IndexType* bufIndices;
1261 typename DATATYPE::PrimalType* bufPrimals;
1262 /* required for async */ void* bufAdjoints;
1266 DATATYPE* datatype;
1267 int dest;
1268 int tag;
1270
1272 if(nullptr != bufIndices) {
1273 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
1274 bufIndices = nullptr;
1275 }
1276 if(nullptr != bufPrimals) {
1277 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
1278 bufPrimals = nullptr;
1279 }
1280 }
1281 };
1282
1283 template<typename DATATYPE>
1285 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
1286 typename DATATYPE::ModifiedType* bufMod;
1288 DATATYPE* datatype;
1289 int dest;
1290 int tag;
1293 };
1294
1295 template<typename DATATYPE>
1296 void AMPI_Irsend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1298 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1299 (void)adType;
1300
1301 h->bufAdjoints = nullptr;
1302 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1303 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1304 // Primal buffers are always linear in space so we can accesses them in one sweep
1305 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1306
1307
1309 &h->requestReverse);
1310
1311 }
1312
1313 template<typename DATATYPE>
1314 void AMPI_Irsend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1315
1317 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1318 (void)adType;
1319 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1320
1321 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1322 }
1323
1324 template<typename DATATYPE>
1325 void AMPI_Irsend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1327 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1328 (void)adType;
1329
1330 h->bufAdjoints = nullptr;
1331 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1332 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1333 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1334 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1335
1336
1338 &h->requestReverse);
1339
1340 }
1341
1342 template<typename DATATYPE>
1343 void AMPI_Irsend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1344
1346 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1347 (void)adType;
1348 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1349
1350 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1351 }
1352
1353 template<typename DATATYPE>
1354 void AMPI_Irsend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
1356 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1357 (void)adType;
1358
1359 h->bufAdjoints = nullptr;
1360 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1361 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1362
1364 &h->requestReverse);
1365
1366 }
1367
1368 template<typename DATATYPE>
1369 void AMPI_Irsend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1370
1372 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1373 (void)adType;
1374 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1375
1376 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1377 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1378 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1379 }
1380
1381 template<typename DATATYPE>
1382 int AMPI_Irsend_finish(HandleBase* handle);
1383 template<typename DATATYPE>
1384 int AMPI_Irsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
1385 AMPI_Comm comm, AMPI_Request* request) {
1386 int rStatus;
1387 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1388
1389 if(!adType->isActiveType()) {
1390 // call the regular function if the type is not active
1391 rStatus = MPI_Irsend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
1392 } else {
1393
1394 // the type is an AD type so handle the buffers
1396 typename DATATYPE::ModifiedType* bufMod = nullptr;
1397 int bufElements = 0;
1398
1399 // compute the total size of the buffer
1400 bufElements = count;
1401
1402 if(datatype->isModifiedBufferRequired() ) {
1403 datatype->createModifiedTypeBuffer(bufMod, bufElements);
1404 } else {
1405 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
1406 }
1407
1408 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
1409 if(adType->isHandleRequired()) {
1411 }
1412 adType->startAssembly(h);
1413 if(datatype->isModifiedBufferRequired()) {
1414 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
1415 }
1416
1417 if(nullptr != h) {
1418 // gather the information for the reverse sweep
1419
1420 // create the index buffers
1421 h->bufCount = datatype->computeActiveElements(count);
1422 h->bufTotalSize = datatype->computeActiveElements(bufElements);
1423 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
1424
1425
1426
1427
1428 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
1429
1430
1431 // pack all the variables in the handle
1435 h->count = count;
1436 h->datatype = datatype;
1437 h->dest = dest;
1438 h->tag = tag;
1439 h->comm = comm;
1440 }
1441
1442
1443 rStatus = MPI_Irsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
1444
1446 asyncHandle->buf = buf;
1447 asyncHandle->bufMod = bufMod;
1448 asyncHandle->count = count;
1449 asyncHandle->datatype = datatype;
1450 asyncHandle->dest = dest;
1451 asyncHandle->tag = tag;
1452 asyncHandle->comm = comm;
1453 asyncHandle->toolHandle = h;
1454 request->handle = asyncHandle;
1456
1457 // create adjoint wait
1458 if(nullptr != h) {
1461 adType->addToolAction(waitH);
1462 }
1463 }
1464
1465 return rStatus;
1466 }
1467
1468 template<typename DATATYPE>
1470 int rStatus = 0;
1471
1472 AMPI_Irsend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Irsend_AsyncHandle<DATATYPE>*>(handle);
1473 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
1474 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1475 int count = asyncHandle->count;
1476 DATATYPE* datatype = asyncHandle->datatype;
1477 int dest = asyncHandle->dest;
1478 int tag = asyncHandle->tag;
1479 AMPI_Comm comm = asyncHandle->comm;
1480 AMPI_Request* request = asyncHandle->request;
1482 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1483 MEDI_UNUSED(h); // Unused generated to ignore warnings
1484 MEDI_UNUSED(buf); // Unused generated to ignore warnings
1485 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
1486 MEDI_UNUSED(count); // Unused generated to ignore warnings
1487 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
1488 MEDI_UNUSED(dest); // Unused generated to ignore warnings
1489 MEDI_UNUSED(tag); // Unused generated to ignore warnings
1490 MEDI_UNUSED(comm); // Unused generated to ignore warnings
1491 MEDI_UNUSED(request); // Unused generated to ignore warnings
1492
1493 delete asyncHandle;
1494
1495 if(adType->isActiveType()) {
1496
1497 adType->addToolAction(h);
1498
1499
1500 if(nullptr != h) {
1501 // handle the recv buffers
1502 }
1503
1504 adType->stopAssembly(h);
1505
1506 if(datatype->isModifiedBufferRequired() ) {
1507 datatype->deleteModifiedTypeBuffer(bufMod);
1508 }
1509
1510 // handle is deleted by the AD tool
1511 }
1512
1513 return rStatus;
1514 }
1515
1516#endif
1517#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
1518 template<typename DATATYPE>
1521 typename DATATYPE::IndexType* bufIndices;
1522 typename DATATYPE::PrimalType* bufPrimals;
1523 /* required for async */ void* bufAdjoints;
1527 DATATYPE* datatype;
1528 int dest;
1529 int tag;
1531
1533 if(nullptr != bufIndices) {
1534 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
1535 bufIndices = nullptr;
1536 }
1537 if(nullptr != bufPrimals) {
1538 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
1539 bufPrimals = nullptr;
1540 }
1541 }
1542 };
1543
1544 template<typename DATATYPE>
1546 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
1547 typename DATATYPE::ModifiedType* bufMod;
1549 DATATYPE* datatype;
1550 int dest;
1551 int tag;
1554 };
1555
1556 template<typename DATATYPE>
1557 void AMPI_Isend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1559 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1560 (void)adType;
1561
1562 h->bufAdjoints = nullptr;
1563 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1564 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1565 // Primal buffers are always linear in space so we can accesses them in one sweep
1566 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1567
1568
1570 &h->requestReverse);
1571
1572 }
1573
1574 template<typename DATATYPE>
1575 void AMPI_Isend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1576
1578 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1579 (void)adType;
1580 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1581
1582 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1583 }
1584
1585 template<typename DATATYPE>
1586 void AMPI_Isend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1588 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1589 (void)adType;
1590
1591 h->bufAdjoints = nullptr;
1592 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1593 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1594 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1595 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1596
1597
1599 &h->requestReverse);
1600
1601 }
1602
1603 template<typename DATATYPE>
1604 void AMPI_Isend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1605
1607 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1608 (void)adType;
1609 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1610
1611 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1612 }
1613
1614 template<typename DATATYPE>
1615 void AMPI_Isend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
1617 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1618 (void)adType;
1619
1620 h->bufAdjoints = nullptr;
1621 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1622 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1623
1625 &h->requestReverse);
1626
1627 }
1628
1629 template<typename DATATYPE>
1630 void AMPI_Isend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1631
1633 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1634 (void)adType;
1635 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1636
1637 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1638 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1639 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1640 }
1641
1642 template<typename DATATYPE>
1643 int AMPI_Isend_finish(HandleBase* handle);
1644 template<typename DATATYPE>
1645 int AMPI_Isend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
1646 AMPI_Comm comm, AMPI_Request* request) {
1647 int rStatus;
1648 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1649
1650 if(!adType->isActiveType()) {
1651 // call the regular function if the type is not active
1652 rStatus = MPI_Isend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
1653 } else {
1654
1655 // the type is an AD type so handle the buffers
1657 typename DATATYPE::ModifiedType* bufMod = nullptr;
1658 int bufElements = 0;
1659
1660 // compute the total size of the buffer
1661 bufElements = count;
1662
1663 if(datatype->isModifiedBufferRequired() ) {
1664 datatype->createModifiedTypeBuffer(bufMod, bufElements);
1665 } else {
1666 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
1667 }
1668
1669 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
1670 if(adType->isHandleRequired()) {
1672 }
1673 adType->startAssembly(h);
1674 if(datatype->isModifiedBufferRequired()) {
1675 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
1676 }
1677
1678 if(nullptr != h) {
1679 // gather the information for the reverse sweep
1680
1681 // create the index buffers
1682 h->bufCount = datatype->computeActiveElements(count);
1683 h->bufTotalSize = datatype->computeActiveElements(bufElements);
1684 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
1685
1686
1687
1688
1689 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
1690
1691
1692 // pack all the variables in the handle
1696 h->count = count;
1697 h->datatype = datatype;
1698 h->dest = dest;
1699 h->tag = tag;
1700 h->comm = comm;
1701 }
1702
1703
1704 rStatus = MPI_Isend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
1705
1707 asyncHandle->buf = buf;
1708 asyncHandle->bufMod = bufMod;
1709 asyncHandle->count = count;
1710 asyncHandle->datatype = datatype;
1711 asyncHandle->dest = dest;
1712 asyncHandle->tag = tag;
1713 asyncHandle->comm = comm;
1714 asyncHandle->toolHandle = h;
1715 request->handle = asyncHandle;
1717
1718 // create adjoint wait
1719 if(nullptr != h) {
1722 adType->addToolAction(waitH);
1723 }
1724 }
1725
1726 return rStatus;
1727 }
1728
1729 template<typename DATATYPE>
1731 int rStatus = 0;
1732
1733 AMPI_Isend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Isend_AsyncHandle<DATATYPE>*>(handle);
1734 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
1735 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1736 int count = asyncHandle->count;
1737 DATATYPE* datatype = asyncHandle->datatype;
1738 int dest = asyncHandle->dest;
1739 int tag = asyncHandle->tag;
1740 AMPI_Comm comm = asyncHandle->comm;
1741 AMPI_Request* request = asyncHandle->request;
1743 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1744 MEDI_UNUSED(h); // Unused generated to ignore warnings
1745 MEDI_UNUSED(buf); // Unused generated to ignore warnings
1746 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
1747 MEDI_UNUSED(count); // Unused generated to ignore warnings
1748 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
1749 MEDI_UNUSED(dest); // Unused generated to ignore warnings
1750 MEDI_UNUSED(tag); // Unused generated to ignore warnings
1751 MEDI_UNUSED(comm); // Unused generated to ignore warnings
1752 MEDI_UNUSED(request); // Unused generated to ignore warnings
1753
1754 delete asyncHandle;
1755
1756 if(adType->isActiveType()) {
1757
1758 adType->addToolAction(h);
1759
1760
1761 if(nullptr != h) {
1762 // handle the recv buffers
1763 }
1764
1765 adType->stopAssembly(h);
1766
1767 if(datatype->isModifiedBufferRequired() ) {
1768 datatype->deleteModifiedTypeBuffer(bufMod);
1769 }
1770
1771 // handle is deleted by the AD tool
1772 }
1773
1774 return rStatus;
1775 }
1776
1777#endif
1778#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
1779 template<typename DATATYPE>
1782 typename DATATYPE::IndexType* bufIndices;
1783 typename DATATYPE::PrimalType* bufPrimals;
1784 /* required for async */ void* bufAdjoints;
1788 DATATYPE* datatype;
1789 int dest;
1790 int tag;
1792
1794 if(nullptr != bufIndices) {
1795 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
1796 bufIndices = nullptr;
1797 }
1798 if(nullptr != bufPrimals) {
1799 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
1800 bufPrimals = nullptr;
1801 }
1802 }
1803 };
1804
1805 template<typename DATATYPE>
1807 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
1808 typename DATATYPE::ModifiedType* bufMod;
1810 DATATYPE* datatype;
1811 int dest;
1812 int tag;
1815 };
1816
1817 template<typename DATATYPE>
1818 void AMPI_Issend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1820 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1821 (void)adType;
1822
1823 h->bufAdjoints = nullptr;
1824 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1825 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1826 // Primal buffers are always linear in space so we can accesses them in one sweep
1827 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1828
1829
1831 &h->requestReverse);
1832
1833 }
1834
1835 template<typename DATATYPE>
1836 void AMPI_Issend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1837
1839 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1840 (void)adType;
1841 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1842
1843 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1844 }
1845
1846 template<typename DATATYPE>
1847 void AMPI_Issend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1849 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1850 (void)adType;
1851
1852 h->bufAdjoints = nullptr;
1853 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1854 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1855 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1856 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1857
1858
1860 &h->requestReverse);
1861
1862 }
1863
1864 template<typename DATATYPE>
1865 void AMPI_Issend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1866
1868 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1869 (void)adType;
1870 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1871
1872 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1873 }
1874
1875 template<typename DATATYPE>
1876 void AMPI_Issend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
1878 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1879 (void)adType;
1880
1881 h->bufAdjoints = nullptr;
1882 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1883 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1884
1886 &h->requestReverse);
1887
1888 }
1889
1890 template<typename DATATYPE>
1891 void AMPI_Issend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1892
1894 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1895 (void)adType;
1896 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1897
1898 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1899 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1900 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1901 }
1902
1903 template<typename DATATYPE>
1904 int AMPI_Issend_finish(HandleBase* handle);
1905 template<typename DATATYPE>
1906 int AMPI_Issend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
1907 AMPI_Comm comm, AMPI_Request* request) {
1908 int rStatus;
1909 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1910
1911 if(!adType->isActiveType()) {
1912 // call the regular function if the type is not active
1913 rStatus = MPI_Issend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
1914 } else {
1915
1916 // the type is an AD type so handle the buffers
1918 typename DATATYPE::ModifiedType* bufMod = nullptr;
1919 int bufElements = 0;
1920
1921 // compute the total size of the buffer
1922 bufElements = count;
1923
1924 if(datatype->isModifiedBufferRequired() ) {
1925 datatype->createModifiedTypeBuffer(bufMod, bufElements);
1926 } else {
1927 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
1928 }
1929
1930 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
1931 if(adType->isHandleRequired()) {
1933 }
1934 adType->startAssembly(h);
1935 if(datatype->isModifiedBufferRequired()) {
1936 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
1937 }
1938
1939 if(nullptr != h) {
1940 // gather the information for the reverse sweep
1941
1942 // create the index buffers
1943 h->bufCount = datatype->computeActiveElements(count);
1944 h->bufTotalSize = datatype->computeActiveElements(bufElements);
1945 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
1946
1947
1948
1949
1950 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
1951
1952
1953 // pack all the variables in the handle
1957 h->count = count;
1958 h->datatype = datatype;
1959 h->dest = dest;
1960 h->tag = tag;
1961 h->comm = comm;
1962 }
1963
1964
1965 rStatus = MPI_Issend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
1966
1968 asyncHandle->buf = buf;
1969 asyncHandle->bufMod = bufMod;
1970 asyncHandle->count = count;
1971 asyncHandle->datatype = datatype;
1972 asyncHandle->dest = dest;
1973 asyncHandle->tag = tag;
1974 asyncHandle->comm = comm;
1975 asyncHandle->toolHandle = h;
1976 request->handle = asyncHandle;
1978
1979 // create adjoint wait
1980 if(nullptr != h) {
1983 adType->addToolAction(waitH);
1984 }
1985 }
1986
1987 return rStatus;
1988 }
1989
1990 template<typename DATATYPE>
1992 int rStatus = 0;
1993
1994 AMPI_Issend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Issend_AsyncHandle<DATATYPE>*>(handle);
1995 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
1996 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1997 int count = asyncHandle->count;
1998 DATATYPE* datatype = asyncHandle->datatype;
1999 int dest = asyncHandle->dest;
2000 int tag = asyncHandle->tag;
2001 AMPI_Comm comm = asyncHandle->comm;
2002 AMPI_Request* request = asyncHandle->request;
2004 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2005 MEDI_UNUSED(h); // Unused generated to ignore warnings
2006 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2007 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2008 MEDI_UNUSED(count); // Unused generated to ignore warnings
2009 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2010 MEDI_UNUSED(dest); // Unused generated to ignore warnings
2011 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2012 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2013 MEDI_UNUSED(request); // Unused generated to ignore warnings
2014
2015 delete asyncHandle;
2016
2017 if(adType->isActiveType()) {
2018
2019 adType->addToolAction(h);
2020
2021
2022 if(nullptr != h) {
2023 // handle the recv buffers
2024 }
2025
2026 adType->stopAssembly(h);
2027
2028 if(datatype->isModifiedBufferRequired() ) {
2029 datatype->deleteModifiedTypeBuffer(bufMod);
2030 }
2031
2032 // handle is deleted by the AD tool
2033 }
2034
2035 return rStatus;
2036 }
2037
2038#endif
2039#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
2040 template<typename DATATYPE>
2043 typename DATATYPE::IndexType* bufIndices;
2044 typename DATATYPE::PrimalType* bufPrimals;
2045 typename DATATYPE::PrimalType* bufOldPrimals;
2046 /* required for async */ void* bufAdjoints;
2050 DATATYPE* datatype;
2054
2056 if(nullptr != bufIndices) {
2057 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
2058 bufIndices = nullptr;
2059 }
2060 if(nullptr != bufPrimals) {
2061 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
2062 bufPrimals = nullptr;
2063 }
2064 if(nullptr != bufOldPrimals) {
2065 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
2066 bufOldPrimals = nullptr;
2067 }
2068 }
2069 };
2070
2071
2072 template<typename DATATYPE>
2073 void AMPI_Mrecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
2075 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2076 (void)adType;
2077
2078 h->bufAdjoints = nullptr;
2079 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2080 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
2081
2083
2084 if(adType->isOldPrimalsRequired()) {
2085 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2086 }
2087 // Primal buffers are always linear in space so we can accesses them in one sweep
2088 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
2089 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
2090 }
2091
2092 template<typename DATATYPE>
2093 void AMPI_Mrecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
2095 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2096 (void)adType;
2097
2098 h->bufAdjoints = nullptr;
2099 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2100 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2101
2103 h->reverse_send);
2104
2105 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2106 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2107 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2108 }
2109
2110 template<typename DATATYPE>
2111 void AMPI_Mrecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
2113 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2114 (void)adType;
2115
2116 h->bufAdjoints = nullptr;
2117 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2118 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2119 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2120 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2121
2122 if(adType->isOldPrimalsRequired()) {
2123 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2124 }
2125
2127 h->reverse_send);
2128
2129 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2130 }
2131
2132 template<typename DATATYPE>
2133 int AMPI_Mrecv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, AMPI_Message* message, AMPI_Status* status,
2134 RecvAdjCall reverse_send = RecvAdjCall::Send) {
2135 int rStatus;
2136 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2137
2138 if(!adType->isActiveType()) {
2139 // call the regular function if the type is not active
2140 rStatus = MPI_Mrecv(buf, count, datatype->getMpiType(), &message->message, status);
2141 } else {
2142
2143 // the type is an AD type so handle the buffers
2145 typename DATATYPE::ModifiedType* bufMod = nullptr;
2146 int bufElements = 0;
2147
2148 // compute the total size of the buffer
2149 bufElements = count;
2150
2151 if(datatype->isModifiedBufferRequired() ) {
2152 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2153 } else {
2154 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2155 }
2156
2157 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2158 if(adType->isHandleRequired()) {
2160 }
2161 adType->startAssembly(h);
2162
2163 if(nullptr != h) {
2164 // gather the information for the reverse sweep
2165
2166 // create the index buffers
2167 h->bufCount = datatype->computeActiveElements(count);
2168 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2169 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2170
2171
2172 // extract the old primal values from the recv buffer if the AD tool
2173 // needs the primal values reset
2174 if(adType->isOldPrimalsRequired()) {
2175 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
2176 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
2177 }
2178
2179
2180
2181 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
2182
2183 // pack all the variables in the handle
2187 h->count = count;
2188 h->datatype = datatype;
2189 h->message = *message;
2190 h->status = status;
2191 h->reverse_send = reverse_send;
2192 }
2193
2194 if(!datatype->isModifiedBufferRequired()) {
2195 datatype->clearIndices(buf, 0, count);
2196 }
2197
2198 rStatus = MPI_Mrecv(bufMod, count, datatype->getModifiedMpiType(), &message->message, status);
2199 adType->addToolAction(h);
2200
2201 if(datatype->isModifiedBufferRequired()) {
2202 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
2203 }
2204
2205 if(nullptr != h) {
2206 // handle the recv buffers
2207 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
2208 }
2209
2210 adType->stopAssembly(h);
2211
2212 if(datatype->isModifiedBufferRequired() ) {
2213 datatype->deleteModifiedTypeBuffer(bufMod);
2214 }
2215
2216 // handle is deleted by the AD tool
2217 }
2218
2219 return rStatus;
2220 }
2221
2222#endif
2223#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
2224 template<typename DATATYPE>
2227 typename DATATYPE::IndexType* bufIndices;
2228 typename DATATYPE::PrimalType* bufPrimals;
2229 typename DATATYPE::PrimalType* bufOldPrimals;
2230 /* required for async */ void* bufAdjoints;
2234 DATATYPE* datatype;
2236 int tag;
2239
2241 if(nullptr != bufIndices) {
2242 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
2243 bufIndices = nullptr;
2244 }
2245 if(nullptr != bufPrimals) {
2246 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
2247 bufPrimals = nullptr;
2248 }
2249 if(nullptr != bufOldPrimals) {
2250 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
2251 bufOldPrimals = nullptr;
2252 }
2253 }
2254 };
2255
2256
2257 template<typename DATATYPE>
2258 void AMPI_Recv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
2260 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2261 (void)adType;
2262
2263 MPI_Status status;
2264 h->bufAdjoints = nullptr;
2265 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2266 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
2267
2268 AMPI_Recv_pri<DATATYPE>(h->bufPrimals, h->bufCountVec, h->count, h->datatype, h->source, h->tag, h->comm, &status,
2269 h->reverse_send);
2270
2271 if(adType->isOldPrimalsRequired()) {
2272 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2273 }
2274 // Primal buffers are always linear in space so we can accesses them in one sweep
2275 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
2276 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
2277 }
2278
2279 template<typename DATATYPE>
2280 void AMPI_Recv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
2282 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2283 (void)adType;
2284
2285 MPI_Status status;
2286 h->bufAdjoints = nullptr;
2287 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2288 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2289
2290 AMPI_Recv_fwd<DATATYPE>(h->bufAdjoints, h->bufCountVec, h->count, h->datatype, h->source, h->tag, h->comm, &status,
2291 h->reverse_send);
2292
2293 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2294 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2295 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2296 }
2297
2298 template<typename DATATYPE>
2299 void AMPI_Recv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
2301 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2302 (void)adType;
2303
2304 MPI_Status status;
2305 h->bufAdjoints = nullptr;
2306 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2307 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2308 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2309 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2310
2311 if(adType->isOldPrimalsRequired()) {
2312 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2313 }
2314
2315 AMPI_Recv_adj<DATATYPE>(h->bufAdjoints, h->bufCountVec, h->count, h->datatype, h->source, h->tag, h->comm, &status,
2316 h->reverse_send);
2317
2318 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2319 }
2320
2321 template<typename DATATYPE>
2322 int AMPI_Recv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int source, int tag, AMPI_Comm comm,
2323 AMPI_Status* status, RecvAdjCall reverse_send = RecvAdjCall::Send) {
2324 int rStatus;
2325 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2326
2327 if(!adType->isActiveType()) {
2328 // call the regular function if the type is not active
2329 rStatus = MPI_Recv(buf, count, datatype->getMpiType(), source, tag, comm, status);
2330 } else {
2331
2332 // the type is an AD type so handle the buffers
2334 typename DATATYPE::ModifiedType* bufMod = nullptr;
2335 int bufElements = 0;
2336
2337 // compute the total size of the buffer
2338 bufElements = count;
2339
2340 if(datatype->isModifiedBufferRequired() ) {
2341 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2342 } else {
2343 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2344 }
2345
2346 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2347 if(adType->isHandleRequired()) {
2349 }
2350 adType->startAssembly(h);
2351
2352 if(nullptr != h) {
2353 // gather the information for the reverse sweep
2354
2355 // create the index buffers
2356 h->bufCount = datatype->computeActiveElements(count);
2357 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2358 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2359
2360
2361 // extract the old primal values from the recv buffer if the AD tool
2362 // needs the primal values reset
2363 if(adType->isOldPrimalsRequired()) {
2364 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
2365 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
2366 }
2367
2368
2369
2370 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
2371
2372 // pack all the variables in the handle
2376 h->count = count;
2377 h->datatype = datatype;
2378 h->source = source;
2379 h->tag = tag;
2380 h->comm = comm;
2381 h->reverse_send = reverse_send;
2382 }
2383
2384 if(!datatype->isModifiedBufferRequired()) {
2385 datatype->clearIndices(buf, 0, count);
2386 }
2387
2388 rStatus = MPI_Recv(bufMod, count, datatype->getModifiedMpiType(), source, tag, comm, status);
2389 adType->addToolAction(h);
2390
2391 if(datatype->isModifiedBufferRequired()) {
2392 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
2393 }
2394
2395 if(nullptr != h) {
2396 // handle the recv buffers
2397 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
2398 }
2399
2400 adType->stopAssembly(h);
2401
2402 if(datatype->isModifiedBufferRequired() ) {
2403 datatype->deleteModifiedTypeBuffer(bufMod);
2404 }
2405
2406 // handle is deleted by the AD tool
2407 }
2408
2409 return rStatus;
2410 }
2411
2412#endif
2413#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
2414
2415 template<typename DATATYPE>
2417 typename DATATYPE::Type* buf;
2418 typename DATATYPE::ModifiedType* bufMod;
2420 DATATYPE* datatype;
2422 int tag;
2426 };
2427
2428
2429 template<typename DATATYPE>
2431 template<typename DATATYPE>
2432 int AMPI_Recv_init_finish(HandleBase* handle);
2433 template<typename DATATYPE>
2435 template<typename DATATYPE>
2436 int AMPI_Recv_init(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int source, int tag, AMPI_Comm comm,
2437 AMPI_Request* request, IrecvAdjCall reverse_send = IrecvAdjCall::Isend) {
2438 int rStatus;
2439 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2440
2441 if(!adType->isActiveType()) {
2442 // call the regular function if the type is not active
2443 rStatus = MPI_Recv_init(buf, count, datatype->getMpiType(), source, tag, comm, &request->request);
2444 } else {
2445
2446 // the type is an AD type so handle the buffers
2448 typename DATATYPE::ModifiedType* bufMod = nullptr;
2449 int bufElements = 0;
2450
2451 // compute the total size of the buffer
2452 bufElements = count;
2453
2454 if(datatype->isModifiedBufferRequired() ) {
2455 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2456 } else {
2457 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2458 }
2459
2460 rStatus = MPI_Recv_init(bufMod, count, datatype->getModifiedMpiType(), source, tag, comm, &request->request);
2461
2463 asyncHandle->buf = buf;
2464 asyncHandle->bufMod = bufMod;
2465 asyncHandle->count = count;
2466 asyncHandle->datatype = datatype;
2467 asyncHandle->source = source;
2468 asyncHandle->tag = tag;
2469 asyncHandle->comm = comm;
2470 asyncHandle->reverse_send = reverse_send;
2471 asyncHandle->toolHandle = h;
2472 request->handle = asyncHandle;
2476 }
2477
2478 return rStatus;
2479 }
2480
2481 template<typename DATATYPE>
2483 int rStatus = 0;
2484
2486 typename DATATYPE::Type* buf = asyncHandle->buf;
2487 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2488 int count = asyncHandle->count;
2489 DATATYPE* datatype = asyncHandle->datatype;
2490 int source = asyncHandle->source;
2491 int tag = asyncHandle->tag;
2492 AMPI_Comm comm = asyncHandle->comm;
2493 AMPI_Request* request = asyncHandle->request;
2494 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
2496 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2497 MEDI_UNUSED(h); // Unused generated to ignore warnings
2498 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2499 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2500 MEDI_UNUSED(count); // Unused generated to ignore warnings
2501 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2502 MEDI_UNUSED(source); // Unused generated to ignore warnings
2503 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2504 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2505 MEDI_UNUSED(request); // Unused generated to ignore warnings
2506 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
2507
2508
2509 if(adType->isActiveType()) {
2510
2511 int bufElements = 0;
2512
2513 // recompute the total size of the buffer
2514 bufElements = count;
2515 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2516 if(adType->isHandleRequired()) {
2518 }
2519 adType->startAssembly(h);
2520
2521 if(nullptr != h) {
2522 // gather the information for the reverse sweep
2523
2524 // create the index buffers
2525 h->bufCount = datatype->computeActiveElements(count);
2526 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2527 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2528
2529
2530 // extract the old primal values from the recv buffer if the AD tool
2531 // needs the primal values reset
2532 if(adType->isOldPrimalsRequired()) {
2533 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
2534 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
2535 }
2536
2537
2538
2539 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
2540
2541 // pack all the variables in the handle
2545 h->count = count;
2546 h->datatype = datatype;
2547 h->source = source;
2548 h->tag = tag;
2549 h->comm = comm;
2550 h->reverse_send = reverse_send;
2551 }
2552
2553 if(!datatype->isModifiedBufferRequired()) {
2554 datatype->clearIndices(buf, 0, count);
2555 }
2556
2557 asyncHandle->toolHandle = h;
2558
2559 // create adjoint wait
2560 if(nullptr != h) {
2563 adType->addToolAction(waitH);
2564 }
2565 }
2566
2567 return rStatus;
2568 }
2569
2570 template<typename DATATYPE>
2572 int rStatus = 0;
2573
2575 typename DATATYPE::Type* buf = asyncHandle->buf;
2576 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2577 int count = asyncHandle->count;
2578 DATATYPE* datatype = asyncHandle->datatype;
2579 int source = asyncHandle->source;
2580 int tag = asyncHandle->tag;
2581 AMPI_Comm comm = asyncHandle->comm;
2582 AMPI_Request* request = asyncHandle->request;
2583 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
2585 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2586 MEDI_UNUSED(h); // Unused generated to ignore warnings
2587 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2588 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2589 MEDI_UNUSED(count); // Unused generated to ignore warnings
2590 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2591 MEDI_UNUSED(source); // Unused generated to ignore warnings
2592 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2593 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2594 MEDI_UNUSED(request); // Unused generated to ignore warnings
2595 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
2596
2597
2598 if(adType->isActiveType()) {
2599
2600 adType->addToolAction(h);
2601
2602 if(datatype->isModifiedBufferRequired()) {
2603 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
2604 }
2605
2606 if(nullptr != h) {
2607 // handle the recv buffers
2608 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
2609 }
2610
2611 adType->stopAssembly(h);
2612 }
2613
2614 return rStatus;
2615 }
2616
2617 template<typename DATATYPE>
2619 int rStatus = 0;
2620
2622 typename DATATYPE::Type* buf = asyncHandle->buf;
2623 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2624 int count = asyncHandle->count;
2625 DATATYPE* datatype = asyncHandle->datatype;
2626 int source = asyncHandle->source;
2627 int tag = asyncHandle->tag;
2628 AMPI_Comm comm = asyncHandle->comm;
2629 AMPI_Request* request = asyncHandle->request;
2630 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
2632 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2633 MEDI_UNUSED(h); // Unused generated to ignore warnings
2634 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2635 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2636 MEDI_UNUSED(count); // Unused generated to ignore warnings
2637 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2638 MEDI_UNUSED(source); // Unused generated to ignore warnings
2639 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2640 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2641 MEDI_UNUSED(request); // Unused generated to ignore warnings
2642 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
2643
2644 delete asyncHandle;
2645
2646 if(adType->isActiveType()) {
2647
2648
2649 if(datatype->isModifiedBufferRequired() ) {
2650 datatype->deleteModifiedTypeBuffer(bufMod);
2651 }
2652
2653 // handle is deleted by the AD tool
2654 }
2655
2656 return rStatus;
2657 }
2658
2659#endif
2660#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
2661 template<typename DATATYPE>
2664 typename DATATYPE::IndexType* bufIndices;
2665 typename DATATYPE::PrimalType* bufPrimals;
2666 /* required for async */ void* bufAdjoints;
2670 DATATYPE* datatype;
2671 int dest;
2672 int tag;
2674
2676 if(nullptr != bufIndices) {
2677 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
2678 bufIndices = nullptr;
2679 }
2680 if(nullptr != bufPrimals) {
2681 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
2682 bufPrimals = nullptr;
2683 }
2684 }
2685 };
2686
2687
2688 template<typename DATATYPE>
2689 void AMPI_Rsend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
2691 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2692 (void)adType;
2693
2694 h->bufAdjoints = nullptr;
2695 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2696 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
2697 // Primal buffers are always linear in space so we can accesses them in one sweep
2698 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
2699
2700
2702
2703 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
2704 }
2705
2706 template<typename DATATYPE>
2707 void AMPI_Rsend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
2709 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2710 (void)adType;
2711
2712 h->bufAdjoints = nullptr;
2713 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2714 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2715 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2716 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2717
2718
2720
2721 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2722 }
2723
2724 template<typename DATATYPE>
2725 void AMPI_Rsend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
2727 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2728 (void)adType;
2729
2730 h->bufAdjoints = nullptr;
2731 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2732 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2733
2735
2736 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2737 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2738 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2739 }
2740
2741 template<typename DATATYPE>
2742 int AMPI_Rsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
2743 AMPI_Comm comm) {
2744 int rStatus;
2745 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2746
2747 if(!adType->isActiveType()) {
2748 // call the regular function if the type is not active
2749 rStatus = MPI_Rsend(buf, count, datatype->getMpiType(), dest, tag, comm);
2750 } else {
2751
2752 // the type is an AD type so handle the buffers
2754 typename DATATYPE::ModifiedType* bufMod = nullptr;
2755 int bufElements = 0;
2756
2757 // compute the total size of the buffer
2758 bufElements = count;
2759
2760 if(datatype->isModifiedBufferRequired() ) {
2761 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2762 } else {
2763 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2764 }
2765
2766 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2767 if(adType->isHandleRequired()) {
2769 }
2770 adType->startAssembly(h);
2771 if(datatype->isModifiedBufferRequired()) {
2772 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
2773 }
2774
2775 if(nullptr != h) {
2776 // gather the information for the reverse sweep
2777
2778 // create the index buffers
2779 h->bufCount = datatype->computeActiveElements(count);
2780 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2781 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2782
2783
2784
2785
2786 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
2787
2788
2789 // pack all the variables in the handle
2793 h->count = count;
2794 h->datatype = datatype;
2795 h->dest = dest;
2796 h->tag = tag;
2797 h->comm = comm;
2798 }
2799
2800
2801 rStatus = MPI_Rsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
2802 adType->addToolAction(h);
2803
2804
2805 if(nullptr != h) {
2806 // handle the recv buffers
2807 }
2808
2809 adType->stopAssembly(h);
2810
2811 if(datatype->isModifiedBufferRequired() ) {
2812 datatype->deleteModifiedTypeBuffer(bufMod);
2813 }
2814
2815 // handle is deleted by the AD tool
2816 }
2817
2818 return rStatus;
2819 }
2820
2821#endif
2822#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
2823
2824 template<typename DATATYPE>
2826 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
2827 typename DATATYPE::ModifiedType* bufMod;
2829 DATATYPE* datatype;
2830 int dest;
2831 int tag;
2834 };
2835
2836
2837 template<typename DATATYPE>
2839 template<typename DATATYPE>
2841 template<typename DATATYPE>
2843 template<typename DATATYPE>
2844 int AMPI_Rsend_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
2845 AMPI_Comm comm, AMPI_Request* request) {
2846 int rStatus;
2847 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2848
2849 if(!adType->isActiveType()) {
2850 // call the regular function if the type is not active
2851 rStatus = MPI_Rsend_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
2852 } else {
2853
2854 // the type is an AD type so handle the buffers
2856 typename DATATYPE::ModifiedType* bufMod = nullptr;
2857 int bufElements = 0;
2858
2859 // compute the total size of the buffer
2860 bufElements = count;
2861
2862 if(datatype->isModifiedBufferRequired() ) {
2863 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2864 } else {
2865 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2866 }
2867
2868 rStatus = MPI_Rsend_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
2869
2871 asyncHandle->buf = buf;
2872 asyncHandle->bufMod = bufMod;
2873 asyncHandle->count = count;
2874 asyncHandle->datatype = datatype;
2875 asyncHandle->dest = dest;
2876 asyncHandle->tag = tag;
2877 asyncHandle->comm = comm;
2878 asyncHandle->toolHandle = h;
2879 request->handle = asyncHandle;
2883 }
2884
2885 return rStatus;
2886 }
2887
2888 template<typename DATATYPE>
2890 int rStatus = 0;
2891
2893 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
2894 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2895 int count = asyncHandle->count;
2896 DATATYPE* datatype = asyncHandle->datatype;
2897 int dest = asyncHandle->dest;
2898 int tag = asyncHandle->tag;
2899 AMPI_Comm comm = asyncHandle->comm;
2900 AMPI_Request* request = asyncHandle->request;
2902 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2903 MEDI_UNUSED(h); // Unused generated to ignore warnings
2904 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2905 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2906 MEDI_UNUSED(count); // Unused generated to ignore warnings
2907 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2908 MEDI_UNUSED(dest); // Unused generated to ignore warnings
2909 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2910 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2911 MEDI_UNUSED(request); // Unused generated to ignore warnings
2912
2913
2914 if(adType->isActiveType()) {
2915
2916 int bufElements = 0;
2917
2918 // recompute the total size of the buffer
2919 bufElements = count;
2920 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2921 if(adType->isHandleRequired()) {
2923 }
2924 adType->startAssembly(h);
2925 if(datatype->isModifiedBufferRequired()) {
2926 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
2927 }
2928
2929 if(nullptr != h) {
2930 // gather the information for the reverse sweep
2931
2932 // create the index buffers
2933 h->bufCount = datatype->computeActiveElements(count);
2934 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2935 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2936
2937
2938
2939
2940 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
2941
2942
2943 // pack all the variables in the handle
2947 h->count = count;
2948 h->datatype = datatype;
2949 h->dest = dest;
2950 h->tag = tag;
2951 h->comm = comm;
2952 }
2953
2954
2955 asyncHandle->toolHandle = h;
2956
2957 // create adjoint wait
2958 if(nullptr != h) {
2961 adType->addToolAction(waitH);
2962 }
2963 }
2964
2965 return rStatus;
2966 }
2967
2968 template<typename DATATYPE>
2970 int rStatus = 0;
2971
2973 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
2974 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2975 int count = asyncHandle->count;
2976 DATATYPE* datatype = asyncHandle->datatype;
2977 int dest = asyncHandle->dest;
2978 int tag = asyncHandle->tag;
2979 AMPI_Comm comm = asyncHandle->comm;
2980 AMPI_Request* request = asyncHandle->request;
2982 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2983 MEDI_UNUSED(h); // Unused generated to ignore warnings
2984 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2985 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2986 MEDI_UNUSED(count); // Unused generated to ignore warnings
2987 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2988 MEDI_UNUSED(dest); // Unused generated to ignore warnings
2989 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2990 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2991 MEDI_UNUSED(request); // Unused generated to ignore warnings
2992
2993
2994 if(adType->isActiveType()) {
2995
2996 adType->addToolAction(h);
2997
2998
2999 if(nullptr != h) {
3000 // handle the recv buffers
3001 }
3002
3003 adType->stopAssembly(h);
3004 }
3005
3006 return rStatus;
3007 }
3008
3009 template<typename DATATYPE>
3011 int rStatus = 0;
3012
3014 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3015 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3016 int count = asyncHandle->count;
3017 DATATYPE* datatype = asyncHandle->datatype;
3018 int dest = asyncHandle->dest;
3019 int tag = asyncHandle->tag;
3020 AMPI_Comm comm = asyncHandle->comm;
3021 AMPI_Request* request = asyncHandle->request;
3023 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3024 MEDI_UNUSED(h); // Unused generated to ignore warnings
3025 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3026 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3027 MEDI_UNUSED(count); // Unused generated to ignore warnings
3028 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3029 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3030 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3031 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3032 MEDI_UNUSED(request); // Unused generated to ignore warnings
3033
3034 delete asyncHandle;
3035
3036 if(adType->isActiveType()) {
3037
3038
3039 if(datatype->isModifiedBufferRequired() ) {
3040 datatype->deleteModifiedTypeBuffer(bufMod);
3041 }
3042
3043 // handle is deleted by the AD tool
3044 }
3045
3046 return rStatus;
3047 }
3048
3049#endif
3050#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3051 template<typename DATATYPE>
3054 typename DATATYPE::IndexType* bufIndices;
3055 typename DATATYPE::PrimalType* bufPrimals;
3056 /* required for async */ void* bufAdjoints;
3060 DATATYPE* datatype;
3061 int dest;
3062 int tag;
3064
3066 if(nullptr != bufIndices) {
3067 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
3068 bufIndices = nullptr;
3069 }
3070 if(nullptr != bufPrimals) {
3071 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
3072 bufPrimals = nullptr;
3073 }
3074 }
3075 };
3076
3077
3078 template<typename DATATYPE>
3079 void AMPI_Send_p(HandleBase* handle, AdjointInterface* adjointInterface) {
3081 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3082 (void)adType;
3083
3084 h->bufAdjoints = nullptr;
3085 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3086 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
3087 // Primal buffers are always linear in space so we can accesses them in one sweep
3088 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
3089
3090
3092
3093 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
3094 }
3095
3096 template<typename DATATYPE>
3097 void AMPI_Send_d(HandleBase* handle, AdjointInterface* adjointInterface) {
3099 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3100 (void)adType;
3101
3102 h->bufAdjoints = nullptr;
3103 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3104 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
3105 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3106 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
3107
3108
3110
3111 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
3112 }
3113
3114 template<typename DATATYPE>
3115 void AMPI_Send_b(HandleBase* handle, AdjointInterface* adjointInterface) {
3117 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3118 (void)adType;
3119
3120 h->bufAdjoints = nullptr;
3121 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3122 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
3123
3125
3126 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3127 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
3128 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
3129 }
3130
3131 template<typename DATATYPE>
3132 int AMPI_Send(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
3133 AMPI_Comm comm) {
3134 int rStatus;
3135 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3136
3137 if(!adType->isActiveType()) {
3138 // call the regular function if the type is not active
3139 rStatus = MPI_Send(buf, count, datatype->getMpiType(), dest, tag, comm);
3140 } else {
3141
3142 // the type is an AD type so handle the buffers
3144 typename DATATYPE::ModifiedType* bufMod = nullptr;
3145 int bufElements = 0;
3146
3147 // compute the total size of the buffer
3148 bufElements = count;
3149
3150 if(datatype->isModifiedBufferRequired() ) {
3151 datatype->createModifiedTypeBuffer(bufMod, bufElements);
3152 } else {
3153 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
3154 }
3155
3156 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3157 if(adType->isHandleRequired()) {
3159 }
3160 adType->startAssembly(h);
3161 if(datatype->isModifiedBufferRequired()) {
3162 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
3163 }
3164
3165 if(nullptr != h) {
3166 // gather the information for the reverse sweep
3167
3168 // create the index buffers
3169 h->bufCount = datatype->computeActiveElements(count);
3170 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3171 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3172
3173
3174
3175
3176 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3177
3178
3179 // pack all the variables in the handle
3183 h->count = count;
3184 h->datatype = datatype;
3185 h->dest = dest;
3186 h->tag = tag;
3187 h->comm = comm;
3188 }
3189
3190
3191 rStatus = MPI_Send(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
3192 adType->addToolAction(h);
3193
3194
3195 if(nullptr != h) {
3196 // handle the recv buffers
3197 }
3198
3199 adType->stopAssembly(h);
3200
3201 if(datatype->isModifiedBufferRequired() ) {
3202 datatype->deleteModifiedTypeBuffer(bufMod);
3203 }
3204
3205 // handle is deleted by the AD tool
3206 }
3207
3208 return rStatus;
3209 }
3210
3211#endif
3212#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3213
3214 template<typename DATATYPE>
3216 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
3217 typename DATATYPE::ModifiedType* bufMod;
3219 DATATYPE* datatype;
3220 int dest;
3221 int tag;
3224 };
3225
3226
3227 template<typename DATATYPE>
3229 template<typename DATATYPE>
3230 int AMPI_Send_init_finish(HandleBase* handle);
3231 template<typename DATATYPE>
3233 template<typename DATATYPE>
3234 int AMPI_Send_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
3235 AMPI_Comm comm, AMPI_Request* request) {
3236 int rStatus;
3237 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3238
3239 if(!adType->isActiveType()) {
3240 // call the regular function if the type is not active
3241 rStatus = MPI_Send_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
3242 } else {
3243
3244 // the type is an AD type so handle the buffers
3246 typename DATATYPE::ModifiedType* bufMod = nullptr;
3247 int bufElements = 0;
3248
3249 // compute the total size of the buffer
3250 bufElements = count;
3251
3252 if(datatype->isModifiedBufferRequired() ) {
3253 datatype->createModifiedTypeBuffer(bufMod, bufElements);
3254 } else {
3255 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
3256 }
3257
3258 rStatus = MPI_Send_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
3259
3261 asyncHandle->buf = buf;
3262 asyncHandle->bufMod = bufMod;
3263 asyncHandle->count = count;
3264 asyncHandle->datatype = datatype;
3265 asyncHandle->dest = dest;
3266 asyncHandle->tag = tag;
3267 asyncHandle->comm = comm;
3268 asyncHandle->toolHandle = h;
3269 request->handle = asyncHandle;
3273 }
3274
3275 return rStatus;
3276 }
3277
3278 template<typename DATATYPE>
3280 int rStatus = 0;
3281
3283 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3284 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3285 int count = asyncHandle->count;
3286 DATATYPE* datatype = asyncHandle->datatype;
3287 int dest = asyncHandle->dest;
3288 int tag = asyncHandle->tag;
3289 AMPI_Comm comm = asyncHandle->comm;
3290 AMPI_Request* request = asyncHandle->request;
3292 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3293 MEDI_UNUSED(h); // Unused generated to ignore warnings
3294 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3295 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3296 MEDI_UNUSED(count); // Unused generated to ignore warnings
3297 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3298 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3299 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3300 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3301 MEDI_UNUSED(request); // Unused generated to ignore warnings
3302
3303
3304 if(adType->isActiveType()) {
3305
3306 int bufElements = 0;
3307
3308 // recompute the total size of the buffer
3309 bufElements = count;
3310 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3311 if(adType->isHandleRequired()) {
3313 }
3314 adType->startAssembly(h);
3315 if(datatype->isModifiedBufferRequired()) {
3316 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
3317 }
3318
3319 if(nullptr != h) {
3320 // gather the information for the reverse sweep
3321
3322 // create the index buffers
3323 h->bufCount = datatype->computeActiveElements(count);
3324 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3325 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3326
3327
3328
3329
3330 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3331
3332
3333 // pack all the variables in the handle
3337 h->count = count;
3338 h->datatype = datatype;
3339 h->dest = dest;
3340 h->tag = tag;
3341 h->comm = comm;
3342 }
3343
3344
3345 asyncHandle->toolHandle = h;
3346
3347 // create adjoint wait
3348 if(nullptr != h) {
3351 adType->addToolAction(waitH);
3352 }
3353 }
3354
3355 return rStatus;
3356 }
3357
3358 template<typename DATATYPE>
3360 int rStatus = 0;
3361
3363 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3364 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3365 int count = asyncHandle->count;
3366 DATATYPE* datatype = asyncHandle->datatype;
3367 int dest = asyncHandle->dest;
3368 int tag = asyncHandle->tag;
3369 AMPI_Comm comm = asyncHandle->comm;
3370 AMPI_Request* request = asyncHandle->request;
3372 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3373 MEDI_UNUSED(h); // Unused generated to ignore warnings
3374 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3375 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3376 MEDI_UNUSED(count); // Unused generated to ignore warnings
3377 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3378 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3379 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3380 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3381 MEDI_UNUSED(request); // Unused generated to ignore warnings
3382
3383
3384 if(adType->isActiveType()) {
3385
3386 adType->addToolAction(h);
3387
3388
3389 if(nullptr != h) {
3390 // handle the recv buffers
3391 }
3392
3393 adType->stopAssembly(h);
3394 }
3395
3396 return rStatus;
3397 }
3398
3399 template<typename DATATYPE>
3401 int rStatus = 0;
3402
3404 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3405 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3406 int count = asyncHandle->count;
3407 DATATYPE* datatype = asyncHandle->datatype;
3408 int dest = asyncHandle->dest;
3409 int tag = asyncHandle->tag;
3410 AMPI_Comm comm = asyncHandle->comm;
3411 AMPI_Request* request = asyncHandle->request;
3413 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3414 MEDI_UNUSED(h); // Unused generated to ignore warnings
3415 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3416 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3417 MEDI_UNUSED(count); // Unused generated to ignore warnings
3418 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3419 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3420 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3421 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3422 MEDI_UNUSED(request); // Unused generated to ignore warnings
3423
3424 delete asyncHandle;
3425
3426 if(adType->isActiveType()) {
3427
3428
3429 if(datatype->isModifiedBufferRequired() ) {
3430 datatype->deleteModifiedTypeBuffer(bufMod);
3431 }
3432
3433 // handle is deleted by the AD tool
3434 }
3435
3436 return rStatus;
3437 }
3438
3439#endif
3440#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3441 template<typename SENDTYPE, typename RECVTYPE>
3444 typename SENDTYPE::IndexType* sendbufIndices;
3445 typename SENDTYPE::PrimalType* sendbufPrimals;
3446 /* required for async */ void* sendbufAdjoints;
3450 SENDTYPE* sendtype;
3451 int dest;
3454 typename RECVTYPE::IndexType* recvbufIndices;
3455 typename RECVTYPE::PrimalType* recvbufPrimals;
3456 typename RECVTYPE::PrimalType* recvbufOldPrimals;
3457 /* required for async */ void* recvbufAdjoints;
3461 RECVTYPE* recvtype;
3465
3467 if(nullptr != sendbufIndices) {
3468 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
3469 sendbufIndices = nullptr;
3470 }
3471 if(nullptr != sendbufPrimals) {
3472 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
3473 sendbufPrimals = nullptr;
3474 }
3475 if(nullptr != recvbufIndices) {
3476 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
3477 recvbufIndices = nullptr;
3478 }
3479 if(nullptr != recvbufPrimals) {
3480 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
3481 recvbufPrimals = nullptr;
3482 }
3483 if(nullptr != recvbufOldPrimals) {
3484 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
3485 recvbufOldPrimals = nullptr;
3486 }
3487 }
3488 };
3489
3490
3491 template<typename SENDTYPE, typename RECVTYPE>
3492 void AMPI_Sendrecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
3494 (handle);
3495 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3496 (void)adType;
3497
3498 MPI_Status status;
3499 h->recvbufAdjoints = nullptr;
3500 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
3501 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
3502 h->sendbufAdjoints = nullptr;
3503 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
3504 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
3505 // Primal buffers are always linear in space so we can accesses them in one sweep
3506 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
3507
3508
3510 h->sendtag, h->recvbufPrimals, h->recvbufCountVec, h->recvcount, h->recvtype, h->source, h->recvtag, h->comm, &status);
3511
3512 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
3513 if(adType->isOldPrimalsRequired()) {
3514 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
3515 }
3516 // Primal buffers are always linear in space so we can accesses them in one sweep
3517 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
3518 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
3519 }
3520
3521 template<typename SENDTYPE, typename RECVTYPE>
3522 void AMPI_Sendrecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
3524 (handle);
3525 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3526 (void)adType;
3527
3528 MPI_Status status;
3529 h->recvbufAdjoints = nullptr;
3530 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
3531 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
3532 h->sendbufAdjoints = nullptr;
3533 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
3534 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
3535 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3536 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
3537
3538
3540 h->sendtag, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->source, h->recvtag, h->comm, &status);
3541
3542 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
3543 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3544 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
3545 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
3546 }
3547
3548 template<typename SENDTYPE, typename RECVTYPE>
3549 void AMPI_Sendrecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
3551 (handle);
3552 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3553 (void)adType;
3554
3555 MPI_Status status;
3556 h->recvbufAdjoints = nullptr;
3557 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
3558 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
3559 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3560 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
3561
3562 if(adType->isOldPrimalsRequired()) {
3563 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
3564 }
3565 h->sendbufAdjoints = nullptr;
3566 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
3567 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
3568
3570 h->sendtag, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->source, h->recvtag, h->comm, &status);
3571
3572 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3573 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
3574 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
3575 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
3576 }
3577
3578 template<typename SENDTYPE, typename RECVTYPE>
3579 int AMPI_Sendrecv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype, int dest,
3580 int sendtag, typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int source, int recvtag,
3581 AMPI_Comm comm, AMPI_Status* status) {
3582 int rStatus;
3583 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
3584
3585 if(!adType->isActiveType()) {
3586 // call the regular function if the type is not active
3587 rStatus = MPI_Sendrecv(sendbuf, sendcount, sendtype->getMpiType(), dest, sendtag, recvbuf, recvcount,
3588 recvtype->getMpiType(), source, recvtag, comm, status);
3589 } else {
3590
3591 // the type is an AD type so handle the buffers
3593 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
3594 int sendbufElements = 0;
3595
3596 // compute the total size of the buffer
3597 sendbufElements = sendcount;
3598
3599 if(sendtype->isModifiedBufferRequired() ) {
3600 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
3601 } else {
3602 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
3603 }
3604 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
3605 int recvbufElements = 0;
3606
3607 // compute the total size of the buffer
3608 recvbufElements = recvcount;
3609
3610 if(recvtype->isModifiedBufferRequired() ) {
3611 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
3612 } else {
3613 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
3614 }
3615
3616 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3617 if(adType->isHandleRequired()) {
3619 }
3620 adType->startAssembly(h);
3621 if(sendtype->isModifiedBufferRequired()) {
3622 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
3623 }
3624
3625 if(nullptr != h) {
3626 // gather the information for the reverse sweep
3627
3628 // create the index buffers
3629 h->sendbufCount = sendtype->computeActiveElements(sendcount);
3630 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
3631 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
3632 h->recvbufCount = recvtype->computeActiveElements(recvcount);
3633 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
3634 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
3635
3636
3637 // extract the old primal values from the recv buffer if the AD tool
3638 // needs the primal values reset
3639 if(adType->isOldPrimalsRequired()) {
3640 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
3641 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
3642 }
3643
3644
3645 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
3646
3647 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
3648
3649 // pack all the variables in the handle
3653 h->sendcount = sendcount;
3654 h->sendtype = sendtype;
3655 h->dest = dest;
3656 h->sendtag = sendtag;
3657 h->recvcount = recvcount;
3658 h->recvtype = recvtype;
3659 h->source = source;
3660 h->recvtag = recvtag;
3661 h->comm = comm;
3662 }
3663
3664 if(!recvtype->isModifiedBufferRequired()) {
3665 recvtype->clearIndices(recvbuf, 0, recvcount);
3666 }
3667
3668 rStatus = MPI_Sendrecv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), dest, sendtag, recvbufMod, recvcount,
3669 recvtype->getModifiedMpiType(), source, recvtag, comm, status);
3670 adType->addToolAction(h);
3671
3672 if(recvtype->isModifiedBufferRequired()) {
3673 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
3674 }
3675
3676 if(nullptr != h) {
3677 // handle the recv buffers
3678 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
3679 }
3680
3681 adType->stopAssembly(h);
3682
3683 if(sendtype->isModifiedBufferRequired() ) {
3684 sendtype->deleteModifiedTypeBuffer(sendbufMod);
3685 }
3686 if(recvtype->isModifiedBufferRequired() ) {
3687 recvtype->deleteModifiedTypeBuffer(recvbufMod);
3688 }
3689
3690 // handle is deleted by the AD tool
3691 }
3692
3693 return rStatus;
3694 }
3695
3696#endif
3697#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3698 template<typename DATATYPE>
3701 typename DATATYPE::IndexType* bufIndices;
3702 typename DATATYPE::PrimalType* bufPrimals;
3703 /* required for async */ void* bufAdjoints;
3707 DATATYPE* datatype;
3708 int dest;
3709 int tag;
3711
3713 if(nullptr != bufIndices) {
3714 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
3715 bufIndices = nullptr;
3716 }
3717 if(nullptr != bufPrimals) {
3718 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
3719 bufPrimals = nullptr;
3720 }
3721 }
3722 };
3723
3724
3725 template<typename DATATYPE>
3726 void AMPI_Ssend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
3728 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3729 (void)adType;
3730
3731 h->bufAdjoints = nullptr;
3732 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3733 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
3734 // Primal buffers are always linear in space so we can accesses them in one sweep
3735 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
3736
3737
3739
3740 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
3741 }
3742
3743 template<typename DATATYPE>
3744 void AMPI_Ssend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
3746 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3747 (void)adType;
3748
3749 h->bufAdjoints = nullptr;
3750 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3751 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
3752 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3753 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
3754
3755
3757
3758 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
3759 }
3760
3761 template<typename DATATYPE>
3762 void AMPI_Ssend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
3764 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3765 (void)adType;
3766
3767 h->bufAdjoints = nullptr;
3768 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3769 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
3770
3772
3773 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3774 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
3775 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
3776 }
3777
3778 template<typename DATATYPE>
3779 int AMPI_Ssend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
3780 AMPI_Comm comm) {
3781 int rStatus;
3782 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3783
3784 if(!adType->isActiveType()) {
3785 // call the regular function if the type is not active
3786 rStatus = MPI_Ssend(buf, count, datatype->getMpiType(), dest, tag, comm);
3787 } else {
3788
3789 // the type is an AD type so handle the buffers
3791 typename DATATYPE::ModifiedType* bufMod = nullptr;
3792 int bufElements = 0;
3793
3794 // compute the total size of the buffer
3795 bufElements = count;
3796
3797 if(datatype->isModifiedBufferRequired() ) {
3798 datatype->createModifiedTypeBuffer(bufMod, bufElements);
3799 } else {
3800 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
3801 }
3802
3803 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3804 if(adType->isHandleRequired()) {
3806 }
3807 adType->startAssembly(h);
3808 if(datatype->isModifiedBufferRequired()) {
3809 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
3810 }
3811
3812 if(nullptr != h) {
3813 // gather the information for the reverse sweep
3814
3815 // create the index buffers
3816 h->bufCount = datatype->computeActiveElements(count);
3817 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3818 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3819
3820
3821
3822
3823 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3824
3825
3826 // pack all the variables in the handle
3830 h->count = count;
3831 h->datatype = datatype;
3832 h->dest = dest;
3833 h->tag = tag;
3834 h->comm = comm;
3835 }
3836
3837
3838 rStatus = MPI_Ssend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
3839 adType->addToolAction(h);
3840
3841
3842 if(nullptr != h) {
3843 // handle the recv buffers
3844 }
3845
3846 adType->stopAssembly(h);
3847
3848 if(datatype->isModifiedBufferRequired() ) {
3849 datatype->deleteModifiedTypeBuffer(bufMod);
3850 }
3851
3852 // handle is deleted by the AD tool
3853 }
3854
3855 return rStatus;
3856 }
3857
3858#endif
3859#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3860
3861 template<typename DATATYPE>
3863 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
3864 typename DATATYPE::ModifiedType* bufMod;
3866 DATATYPE* datatype;
3867 int dest;
3868 int tag;
3871 };
3872
3873
3874 template<typename DATATYPE>
3876 template<typename DATATYPE>
3878 template<typename DATATYPE>
3880 template<typename DATATYPE>
3881 int AMPI_Ssend_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
3882 AMPI_Comm comm, AMPI_Request* request) {
3883 int rStatus;
3884 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3885
3886 if(!adType->isActiveType()) {
3887 // call the regular function if the type is not active
3888 rStatus = MPI_Ssend_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
3889 } else {
3890
3891 // the type is an AD type so handle the buffers
3893 typename DATATYPE::ModifiedType* bufMod = nullptr;
3894 int bufElements = 0;
3895
3896 // compute the total size of the buffer
3897 bufElements = count;
3898
3899 if(datatype->isModifiedBufferRequired() ) {
3900 datatype->createModifiedTypeBuffer(bufMod, bufElements);
3901 } else {
3902 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
3903 }
3904
3905 rStatus = MPI_Ssend_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
3906
3908 asyncHandle->buf = buf;
3909 asyncHandle->bufMod = bufMod;
3910 asyncHandle->count = count;
3911 asyncHandle->datatype = datatype;
3912 asyncHandle->dest = dest;
3913 asyncHandle->tag = tag;
3914 asyncHandle->comm = comm;
3915 asyncHandle->toolHandle = h;
3916 request->handle = asyncHandle;
3920 }
3921
3922 return rStatus;
3923 }
3924
3925 template<typename DATATYPE>
3927 int rStatus = 0;
3928
3930 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3931 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3932 int count = asyncHandle->count;
3933 DATATYPE* datatype = asyncHandle->datatype;
3934 int dest = asyncHandle->dest;
3935 int tag = asyncHandle->tag;
3936 AMPI_Comm comm = asyncHandle->comm;
3937 AMPI_Request* request = asyncHandle->request;
3939 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3940 MEDI_UNUSED(h); // Unused generated to ignore warnings
3941 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3942 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3943 MEDI_UNUSED(count); // Unused generated to ignore warnings
3944 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3945 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3946 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3947 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3948 MEDI_UNUSED(request); // Unused generated to ignore warnings
3949
3950
3951 if(adType->isActiveType()) {
3952
3953 int bufElements = 0;
3954
3955 // recompute the total size of the buffer
3956 bufElements = count;
3957 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3958 if(adType->isHandleRequired()) {
3960 }
3961 adType->startAssembly(h);
3962 if(datatype->isModifiedBufferRequired()) {
3963 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
3964 }
3965
3966 if(nullptr != h) {
3967 // gather the information for the reverse sweep
3968
3969 // create the index buffers
3970 h->bufCount = datatype->computeActiveElements(count);
3971 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3972 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3973
3974
3975
3976
3977 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3978
3979
3980 // pack all the variables in the handle
3984 h->count = count;
3985 h->datatype = datatype;
3986 h->dest = dest;
3987 h->tag = tag;
3988 h->comm = comm;
3989 }
3990
3991
3992 asyncHandle->toolHandle = h;
3993
3994 // create adjoint wait
3995 if(nullptr != h) {
3998 adType->addToolAction(waitH);
3999 }
4000 }
4001
4002 return rStatus;
4003 }
4004
4005 template<typename DATATYPE>
4007 int rStatus = 0;
4008
4010 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
4011 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
4012 int count = asyncHandle->count;
4013 DATATYPE* datatype = asyncHandle->datatype;
4014 int dest = asyncHandle->dest;
4015 int tag = asyncHandle->tag;
4016 AMPI_Comm comm = asyncHandle->comm;
4017 AMPI_Request* request = asyncHandle->request;
4019 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4020 MEDI_UNUSED(h); // Unused generated to ignore warnings
4021 MEDI_UNUSED(buf); // Unused generated to ignore warnings
4022 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
4023 MEDI_UNUSED(count); // Unused generated to ignore warnings
4024 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
4025 MEDI_UNUSED(dest); // Unused generated to ignore warnings
4026 MEDI_UNUSED(tag); // Unused generated to ignore warnings
4027 MEDI_UNUSED(comm); // Unused generated to ignore warnings
4028 MEDI_UNUSED(request); // Unused generated to ignore warnings
4029
4030
4031 if(adType->isActiveType()) {
4032
4033 adType->addToolAction(h);
4034
4035
4036 if(nullptr != h) {
4037 // handle the recv buffers
4038 }
4039
4040 adType->stopAssembly(h);
4041 }
4042
4043 return rStatus;
4044 }
4045
4046 template<typename DATATYPE>
4048 int rStatus = 0;
4049
4051 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
4052 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
4053 int count = asyncHandle->count;
4054 DATATYPE* datatype = asyncHandle->datatype;
4055 int dest = asyncHandle->dest;
4056 int tag = asyncHandle->tag;
4057 AMPI_Comm comm = asyncHandle->comm;
4058 AMPI_Request* request = asyncHandle->request;
4060 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4061 MEDI_UNUSED(h); // Unused generated to ignore warnings
4062 MEDI_UNUSED(buf); // Unused generated to ignore warnings
4063 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
4064 MEDI_UNUSED(count); // Unused generated to ignore warnings
4065 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
4066 MEDI_UNUSED(dest); // Unused generated to ignore warnings
4067 MEDI_UNUSED(tag); // Unused generated to ignore warnings
4068 MEDI_UNUSED(comm); // Unused generated to ignore warnings
4069 MEDI_UNUSED(request); // Unused generated to ignore warnings
4070
4071 delete asyncHandle;
4072
4073 if(adType->isActiveType()) {
4074
4075
4076 if(datatype->isModifiedBufferRequired() ) {
4077 datatype->deleteModifiedTypeBuffer(bufMod);
4078 }
4079
4080 // handle is deleted by the AD tool
4081 }
4082
4083 return rStatus;
4084 }
4085
4086#endif
4087#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4088 template<typename SENDTYPE, typename RECVTYPE>
4091 typename SENDTYPE::IndexType* sendbufIndices;
4092 typename SENDTYPE::PrimalType* sendbufPrimals;
4093 /* required for async */ void* sendbufAdjoints;
4097 SENDTYPE* sendtype;
4099 typename RECVTYPE::IndexType* recvbufIndices;
4100 typename RECVTYPE::PrimalType* recvbufPrimals;
4101 typename RECVTYPE::PrimalType* recvbufOldPrimals;
4102 /* required for async */ void* recvbufAdjoints;
4106 RECVTYPE* recvtype;
4108
4110 if(nullptr != sendbufIndices) {
4111 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
4112 sendbufIndices = nullptr;
4113 }
4114 if(nullptr != sendbufPrimals) {
4115 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
4116 sendbufPrimals = nullptr;
4117 }
4118 if(nullptr != recvbufIndices) {
4119 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
4120 recvbufIndices = nullptr;
4121 }
4122 if(nullptr != recvbufPrimals) {
4123 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
4124 recvbufPrimals = nullptr;
4125 }
4126 if(nullptr != recvbufOldPrimals) {
4127 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
4128 recvbufOldPrimals = nullptr;
4129 }
4130 }
4131 };
4132
4133
4134 template<typename SENDTYPE, typename RECVTYPE>
4135 void AMPI_Allgather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
4137 (handle);
4138 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4139 (void)adType;
4140
4141 h->recvbufAdjoints = nullptr;
4142 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4143 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
4144 h->sendbufAdjoints = nullptr;
4145 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4146 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
4147 // Primal buffers are always linear in space so we can accesses them in one sweep
4148 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
4149
4150
4153
4154 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
4155 if(adType->isOldPrimalsRequired()) {
4156 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4157 }
4158 // Primal buffers are always linear in space so we can accesses them in one sweep
4159 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
4160 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
4161 }
4162
4163 template<typename SENDTYPE, typename RECVTYPE>
4164 void AMPI_Allgather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
4166 (handle);
4167 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4168 (void)adType;
4169
4170 h->recvbufAdjoints = nullptr;
4171 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4172 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4173 h->sendbufAdjoints = nullptr;
4174 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4175 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
4176 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4177 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4178
4179
4182
4183 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4184 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4185 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4186 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4187 }
4188
4189 template<typename SENDTYPE, typename RECVTYPE>
4190 void AMPI_Allgather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
4192 (handle);
4193 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4194 (void)adType;
4195
4196 h->recvbufAdjoints = nullptr;
4197 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4198 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4199 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4200 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4201
4202 if(adType->isOldPrimalsRequired()) {
4203 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4204 }
4205 h->sendbufAdjoints = nullptr;
4206 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4208
4211
4212 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
4213 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4214 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4215 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4216 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4217 }
4218
4219 template<typename SENDTYPE, typename RECVTYPE>
4220 int AMPI_Allgather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
4221 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm) {
4222 int rStatus;
4223 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
4224
4225 if(!adType->isActiveType()) {
4226 // call the regular function if the type is not active
4227 rStatus = MPI_Allgather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm);
4228 } else {
4229
4230 // the type is an AD type so handle the buffers
4232 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
4233 int sendbufElements = 0;
4234
4235 // compute the total size of the buffer
4236 if(AMPI_IN_PLACE != sendbuf) {
4237 sendbufElements = sendcount;
4238 } else {
4239 sendbufElements = recvcount;
4240 }
4241
4242 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4243 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
4244 } else {
4245 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
4246 }
4247 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
4248 int recvbufElements = 0;
4249
4250 // compute the total size of the buffer
4251 recvbufElements = recvcount * getCommSize(comm);
4252
4253 if(recvtype->isModifiedBufferRequired() ) {
4254 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
4255 } else {
4256 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
4257 }
4258
4259 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
4260 if(adType->isHandleRequired()) {
4262 }
4263 adType->startAssembly(h);
4264 if(sendtype->isModifiedBufferRequired()) {
4265 if(AMPI_IN_PLACE != sendbuf) {
4266 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
4267 } else {
4268 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
4269 recvcount);
4270 }
4271 }
4272
4273 if(nullptr != h) {
4274 // gather the information for the reverse sweep
4275
4276 // create the index buffers
4277 if(AMPI_IN_PLACE != sendbuf) {
4278 h->sendbufCount = sendtype->computeActiveElements(sendcount);
4279 } else {
4280 h->sendbufCount = recvtype->computeActiveElements(recvcount);
4281 }
4282 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
4283 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
4284 h->recvbufCount = recvtype->computeActiveElements(recvcount);
4285 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
4286 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
4287
4288
4289 // extract the old primal values from the recv buffer if the AD tool
4290 // needs the primal values reset
4291 if(adType->isOldPrimalsRequired()) {
4292 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
4293 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
4294 }
4295
4296
4297 if(AMPI_IN_PLACE != sendbuf) {
4298 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
4299 } else {
4300 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
4301 }
4302
4303 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
4304
4305 // pack all the variables in the handle
4309 h->sendcount = sendcount;
4310 h->sendtype = sendtype;
4311 h->recvcount = recvcount;
4312 h->recvtype = recvtype;
4313 h->comm = comm;
4314 }
4315
4316 if(!recvtype->isModifiedBufferRequired()) {
4317 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
4318 }
4319
4320 rStatus = MPI_Allgather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
4321 recvtype->getModifiedMpiType(), comm);
4322 adType->addToolAction(h);
4323
4324 if(recvtype->isModifiedBufferRequired()) {
4325 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
4326 }
4327
4328 if(nullptr != h) {
4329 // handle the recv buffers
4330 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
4331 }
4332
4333 adType->stopAssembly(h);
4334
4335 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4336 sendtype->deleteModifiedTypeBuffer(sendbufMod);
4337 }
4338 if(recvtype->isModifiedBufferRequired() ) {
4339 recvtype->deleteModifiedTypeBuffer(recvbufMod);
4340 }
4341
4342 // handle is deleted by the AD tool
4343 }
4344
4345 return rStatus;
4346 }
4347
4348#endif
4349#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4350 template<typename SENDTYPE, typename RECVTYPE>
4353 typename SENDTYPE::IndexType* sendbufIndices;
4354 typename SENDTYPE::PrimalType* sendbufPrimals;
4355 /* required for async */ void* sendbufAdjoints;
4359 SENDTYPE* sendtype;
4361 typename RECVTYPE::IndexType* recvbufIndices;
4362 typename RECVTYPE::PrimalType* recvbufPrimals;
4363 typename RECVTYPE::PrimalType* recvbufOldPrimals;
4364 /* required for async */ void* recvbufAdjoints;
4366 /* required for async */ int* recvbufCountVec;
4367 /* required for async */ int* recvbufDisplsVec;
4370 RECVTYPE* recvtype;
4372
4374 if(nullptr != sendbufIndices) {
4375 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
4376 sendbufIndices = nullptr;
4377 }
4378 if(nullptr != sendbufPrimals) {
4379 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
4380 sendbufPrimals = nullptr;
4381 }
4382 if(nullptr != recvbufIndices) {
4383 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
4384 recvbufIndices = nullptr;
4385 }
4386 if(nullptr != recvbufPrimals) {
4387 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
4388 recvbufPrimals = nullptr;
4389 }
4390 if(nullptr != recvbufOldPrimals) {
4391 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
4392 recvbufOldPrimals = nullptr;
4393 }
4394 if(nullptr != recvbufCount) {
4395 delete [] recvbufCount;
4396 recvbufCount = nullptr;
4397 }
4398 }
4399 };
4400
4401
4402 template<typename SENDTYPE, typename RECVTYPE>
4403 void AMPI_Allgatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
4405 (handle);
4406 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4407 (void)adType;
4408
4409 h->recvbufAdjoints = nullptr;
4411 adjointInterface->getVectorSize());
4412 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
4413 h->sendbufAdjoints = nullptr;
4414 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4415 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
4416 // Primal buffers are always linear in space so we can accesses them in one sweep
4417 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
4418
4419
4422
4423 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
4424 if(adType->isOldPrimalsRequired()) {
4425 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4426 }
4427 // Primal buffers are always linear in space so we can accesses them in one sweep
4428 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
4429 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
4430 delete [] h->recvbufCountVec;
4431 delete [] h->recvbufDisplsVec;
4432 }
4433
4434 template<typename SENDTYPE, typename RECVTYPE>
4435 void AMPI_Allgatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
4437 (handle);
4438 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4439 (void)adType;
4440
4441 h->recvbufAdjoints = nullptr;
4443 adjointInterface->getVectorSize());
4444 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4445 h->sendbufAdjoints = nullptr;
4446 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4447 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
4448 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4449 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4450
4451
4454
4455 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4456 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4457 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4458 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4459 delete [] h->recvbufCountVec;
4460 delete [] h->recvbufDisplsVec;
4461 }
4462
4463 template<typename SENDTYPE, typename RECVTYPE>
4464 void AMPI_Allgatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
4466 (handle);
4467 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4468 (void)adType;
4469
4470 h->recvbufAdjoints = nullptr;
4472 adjointInterface->getVectorSize());
4473 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4474 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4475 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4476
4477 if(adType->isOldPrimalsRequired()) {
4478 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4479 }
4480 h->sendbufAdjoints = nullptr;
4481 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4483
4486
4487 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
4488 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4489 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4490 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4491 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4492 delete [] h->recvbufCountVec;
4493 delete [] h->recvbufDisplsVec;
4494 }
4495
4496 template<typename SENDTYPE, typename RECVTYPE>
4497 int AMPI_Allgatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
4498 typename RECVTYPE::Type* recvbuf, MEDI_OPTIONAL_CONST int* recvcounts, MEDI_OPTIONAL_CONST int* displs,
4499 RECVTYPE* recvtype, AMPI_Comm comm) {
4500 int rStatus;
4501 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
4502
4503 if(!adType->isActiveType()) {
4504 // call the regular function if the type is not active
4505 rStatus = MPI_Allgatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs,
4506 recvtype->getMpiType(), comm);
4507 } else {
4508
4509 // the type is an AD type so handle the buffers
4511 MEDI_OPTIONAL_CONST int* displsMod = displs;
4512 int displsTotalSize = 0;
4513 if(nullptr != displs) {
4514 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
4515 if(recvtype->isModifiedBufferRequired()) {
4516 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
4517 }
4518 }
4519 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
4520 int sendbufElements = 0;
4521
4522 // compute the total size of the buffer
4523 if(AMPI_IN_PLACE != sendbuf) {
4524 sendbufElements = sendcount;
4525 } else {
4526 sendbufElements = recvcounts[getCommRank(comm)];
4527 }
4528
4529 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4530 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
4531 } else {
4532 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
4533 }
4534 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
4535 int recvbufElements = 0;
4536
4537 // compute the total size of the buffer
4538 recvbufElements = displsTotalSize;
4539
4540 if(recvtype->isModifiedBufferRequired() ) {
4541 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
4542 } else {
4543 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
4544 }
4545
4546 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
4547 if(adType->isHandleRequired()) {
4549 }
4550 adType->startAssembly(h);
4551 if(sendtype->isModifiedBufferRequired()) {
4552 if(AMPI_IN_PLACE != sendbuf) {
4553 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
4554 } else {
4555 {
4556 const int rank = getCommRank(comm);
4557 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
4558 }
4559 }
4560 }
4561
4562 if(nullptr != h) {
4563 // gather the information for the reverse sweep
4564
4565 // create the index buffers
4566 if(AMPI_IN_PLACE != sendbuf) {
4567 h->sendbufCount = sendtype->computeActiveElements(sendcount);
4568 } else {
4569 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
4570 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
4571 }
4572 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
4573 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
4574 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
4575 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
4576 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
4577
4578
4579 // extract the old primal values from the recv buffer if the AD tool
4580 // needs the primal values reset
4581 if(adType->isOldPrimalsRequired()) {
4582 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
4583 for(int i = 0; i < getCommSize(comm); ++i) {
4584 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
4585 }
4586 }
4587
4588
4589 if(AMPI_IN_PLACE != sendbuf) {
4590 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
4591 } else {
4592 {
4593 const int rank = getCommRank(comm);
4594 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
4595 }
4596 }
4597
4598 for(int i = 0; i < getCommSize(comm); ++i) {
4599 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
4600 }
4601
4602 // pack all the variables in the handle
4606 h->sendcount = sendcount;
4607 h->sendtype = sendtype;
4608 h->recvcounts = recvcounts;
4609 h->displs = displs;
4610 h->recvtype = recvtype;
4611 h->comm = comm;
4612 }
4613
4614 if(!recvtype->isModifiedBufferRequired()) {
4615 for(int i = 0; i < getCommSize(comm); ++i) {
4616 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
4617 }
4618 }
4619
4620 rStatus = MPI_Allgatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
4621 recvtype->getModifiedMpiType(), comm);
4622 adType->addToolAction(h);
4623
4624 if(recvtype->isModifiedBufferRequired()) {
4625 for(int i = 0; i < getCommSize(comm); ++i) {
4626 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
4627 }
4628 }
4629
4630 if(nullptr != h) {
4631 // handle the recv buffers
4632 for(int i = 0; i < getCommSize(comm); ++i) {
4633 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
4634 }
4635 }
4636
4637 adType->stopAssembly(h);
4638 if(recvtype->isModifiedBufferRequired()) {
4639 delete [] displsMod;
4640 }
4641
4642 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4643 sendtype->deleteModifiedTypeBuffer(sendbufMod);
4644 }
4645 if(recvtype->isModifiedBufferRequired() ) {
4646 recvtype->deleteModifiedTypeBuffer(recvbufMod);
4647 }
4648
4649 // handle is deleted by the AD tool
4650 }
4651
4652 return rStatus;
4653 }
4654
4655#endif
4656#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4657 template<typename DATATYPE>
4660 typename DATATYPE::IndexType* sendbufIndices;
4661 typename DATATYPE::PrimalType* sendbufPrimals;
4662 /* required for async */ void* sendbufAdjoints;
4666 typename DATATYPE::IndexType* recvbufIndices;
4667 typename DATATYPE::PrimalType* recvbufPrimals;
4668 typename DATATYPE::PrimalType* recvbufOldPrimals;
4669 /* required for async */ void* recvbufAdjoints;
4673 DATATYPE* datatype;
4676
4678 if(nullptr != sendbufIndices) {
4679 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
4680 sendbufIndices = nullptr;
4681 }
4682 if(nullptr != sendbufPrimals) {
4683 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
4684 sendbufPrimals = nullptr;
4685 }
4686 if(nullptr != recvbufIndices) {
4687 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
4688 recvbufIndices = nullptr;
4689 }
4690 if(nullptr != recvbufPrimals) {
4691 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
4692 recvbufPrimals = nullptr;
4693 }
4694 if(nullptr != recvbufOldPrimals) {
4695 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
4696 recvbufOldPrimals = nullptr;
4697 }
4698 }
4699 };
4700
4701
4702 template<typename DATATYPE>
4703 void AMPI_Allreduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
4705 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4706 (void)adType;
4707
4708 AMPI_Op convOp = adType->convertOperator(h->op);
4709 (void)convOp;
4710 h->recvbufAdjoints = nullptr;
4711 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4712 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
4713 h->sendbufAdjoints = nullptr;
4714 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4715 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
4716 // Primal buffers are always linear in space so we can accesses them in one sweep
4717 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
4718
4719
4721 h->count, h->datatype, h->op, h->comm);
4722
4723 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
4724 if(adType->isOldPrimalsRequired()) {
4725 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4726 }
4727 // Primal buffers are always linear in space so we can accesses them in one sweep
4728 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
4729 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
4730 }
4731
4732 template<typename DATATYPE>
4733 void AMPI_Allreduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
4735 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4736 (void)adType;
4737
4738 AMPI_Op convOp = adType->convertOperator(h->op);
4739 (void)convOp;
4740 h->recvbufAdjoints = nullptr;
4741 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4742 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4743 h->sendbufAdjoints = nullptr;
4744 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4745 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
4746 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4747 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4748
4749
4751 h->count, h->datatype, h->op, h->comm);
4752
4753 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4754 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4755 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4756 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4757 }
4758
4759 template<typename DATATYPE>
4760 void AMPI_Allreduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
4762 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4763 (void)adType;
4764
4765 AMPI_Op convOp = adType->convertOperator(h->op);
4766 (void)convOp;
4767 h->recvbufAdjoints = nullptr;
4768 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4769 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4770 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4771 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4772
4773 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
4774 if(adType->isOldPrimalsRequired()) {
4775 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4776 }
4777 h->sendbufAdjoints = nullptr;
4778 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4780
4782 h->count, h->datatype, h->op, h->comm);
4783
4784 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
4785 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
4786 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
4788 adjointInterface->getVectorSize());
4789 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4790 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4791 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4792 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4793 }
4794
4795 template<typename DATATYPE>
4796 int AMPI_Allreduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
4797 int count, DATATYPE* datatype, AMPI_Op op, AMPI_Comm comm) {
4798 int rStatus;
4799 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4800 AMPI_Op convOp = adType->convertOperator(op);
4801 (void)convOp;
4802
4803 if(!adType->isActiveType()) {
4804 // call the regular function if the type is not active
4805 rStatus = MPI_Allreduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, comm);
4806 } else {
4807
4808 // the type is an AD type so handle the buffers
4810 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
4811 int sendbufElements = 0;
4812
4813 // compute the total size of the buffer
4814 if(AMPI_IN_PLACE != sendbuf) {
4815 sendbufElements = count;
4816 } else {
4817 sendbufElements = count;
4818 }
4819
4820 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4821 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
4822 } else {
4823 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
4824 }
4825 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
4826 int recvbufElements = 0;
4827
4828 // compute the total size of the buffer
4829 recvbufElements = count;
4830
4831 if(datatype->isModifiedBufferRequired() ) {
4832 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
4833 } else {
4834 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
4835 }
4836
4837 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
4838 if(adType->isHandleRequired()) {
4840 }
4841 adType->startAssembly(h);
4842 if(datatype->isModifiedBufferRequired()) {
4843 if(AMPI_IN_PLACE != sendbuf) {
4844 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
4845 } else {
4846 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
4847 }
4848 }
4849
4850 if(nullptr != h) {
4851 // gather the information for the reverse sweep
4852
4853 // create the index buffers
4854 if(AMPI_IN_PLACE != sendbuf) {
4855 h->sendbufCount = datatype->computeActiveElements(count);
4856 } else {
4857 h->sendbufCount = datatype->computeActiveElements(count);
4858 }
4859 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
4860 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
4861 h->recvbufCount = datatype->computeActiveElements(count);
4862 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
4863 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
4864
4865 // extract the primal values for the operator if required
4866 if(convOp.requiresPrimal) {
4867 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
4868 if(AMPI_IN_PLACE != sendbuf) {
4869 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
4870 } else {
4871 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
4872 }
4873 }
4874
4875 // extract the old primal values from the recv buffer if the AD tool
4876 // needs the primal values reset
4877 if(adType->isOldPrimalsRequired()) {
4878 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
4879 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
4880 }
4881
4882
4883 if(AMPI_IN_PLACE != sendbuf) {
4884 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
4885 } else {
4886 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
4887 }
4888
4889 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
4890
4891 // pack all the variables in the handle
4895 h->count = count;
4896 h->datatype = datatype;
4897 h->op = op;
4898 h->comm = comm;
4899 }
4900
4901 if(!datatype->isModifiedBufferRequired()) {
4902 datatype->clearIndices(recvbuf, 0, count);
4903 }
4904
4905 rStatus = MPI_Allreduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction,
4906 comm);
4907 adType->addToolAction(h);
4908
4909 if(datatype->isModifiedBufferRequired()) {
4910 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
4911 }
4912
4913 if(nullptr != h) {
4914 // handle the recv buffers
4915 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
4916 }
4917 // extract the primal values for the operator if required
4918 if(nullptr != h && convOp.requiresPrimal) {
4919 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
4920 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
4921 }
4922
4923 adType->stopAssembly(h);
4924
4925 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4926 datatype->deleteModifiedTypeBuffer(sendbufMod);
4927 }
4928 if(datatype->isModifiedBufferRequired() ) {
4929 datatype->deleteModifiedTypeBuffer(recvbufMod);
4930 }
4931
4932 // handle is deleted by the AD tool
4933 }
4934
4935 return rStatus;
4936 }
4937
4938#endif
4939#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4940 template<typename SENDTYPE, typename RECVTYPE>
4943 typename SENDTYPE::IndexType* sendbufIndices;
4944 typename SENDTYPE::PrimalType* sendbufPrimals;
4945 /* required for async */ void* sendbufAdjoints;
4949 SENDTYPE* sendtype;
4951 typename RECVTYPE::IndexType* recvbufIndices;
4952 typename RECVTYPE::PrimalType* recvbufPrimals;
4953 typename RECVTYPE::PrimalType* recvbufOldPrimals;
4954 /* required for async */ void* recvbufAdjoints;
4958 RECVTYPE* recvtype;
4960
4962 if(nullptr != sendbufIndices) {
4963 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
4964 sendbufIndices = nullptr;
4965 }
4966 if(nullptr != sendbufPrimals) {
4967 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
4968 sendbufPrimals = nullptr;
4969 }
4970 if(nullptr != recvbufIndices) {
4971 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
4972 recvbufIndices = nullptr;
4973 }
4974 if(nullptr != recvbufPrimals) {
4975 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
4976 recvbufPrimals = nullptr;
4977 }
4978 if(nullptr != recvbufOldPrimals) {
4979 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
4980 recvbufOldPrimals = nullptr;
4981 }
4982 }
4983 };
4984
4985
4986 template<typename SENDTYPE, typename RECVTYPE>
4987 void AMPI_Alltoall_p(HandleBase* handle, AdjointInterface* adjointInterface) {
4989 (handle);
4990 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4991 (void)adType;
4992
4993 h->recvbufAdjoints = nullptr;
4994 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4995 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
4996 h->sendbufAdjoints = nullptr;
4997 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4998 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
4999 // Primal buffers are always linear in space so we can accesses them in one sweep
5000 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
5001
5002
5005
5006 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
5007 if(adType->isOldPrimalsRequired()) {
5008 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5009 }
5010 // Primal buffers are always linear in space so we can accesses them in one sweep
5011 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
5012 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
5013 }
5014
5015 template<typename SENDTYPE, typename RECVTYPE>
5016 void AMPI_Alltoall_d(HandleBase* handle, AdjointInterface* adjointInterface) {
5018 (handle);
5019 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5020 (void)adType;
5021
5022 h->recvbufAdjoints = nullptr;
5023 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5024 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5025 h->sendbufAdjoints = nullptr;
5026 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5027 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5028 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5029 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5030
5031
5034
5035 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5036 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5037 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5038 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5039 }
5040
5041 template<typename SENDTYPE, typename RECVTYPE>
5042 void AMPI_Alltoall_b(HandleBase* handle, AdjointInterface* adjointInterface) {
5044 (handle);
5045 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5046 (void)adType;
5047
5048 h->recvbufAdjoints = nullptr;
5049 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5050 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5051 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5052 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5053
5054 if(adType->isOldPrimalsRequired()) {
5055 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5056 }
5057 h->sendbufAdjoints = nullptr;
5058 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5059 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5060
5063
5064 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5065 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5066 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5067 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5068 }
5069
5070 template<typename SENDTYPE, typename RECVTYPE>
5071 int AMPI_Alltoall(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
5072 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm) {
5073 int rStatus;
5074 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
5075
5076 if(!adType->isActiveType()) {
5077 // call the regular function if the type is not active
5078 rStatus = MPI_Alltoall(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm);
5079 } else {
5080
5081 // the type is an AD type so handle the buffers
5083 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
5084 int sendbufElements = 0;
5085
5086 // compute the total size of the buffer
5087 if(AMPI_IN_PLACE != sendbuf) {
5088 sendbufElements = sendcount * getCommSize(comm);
5089 } else {
5090 sendbufElements = recvcount * getCommSize(comm);
5091 }
5092
5093 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5094 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
5095 } else {
5096 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
5097 }
5098 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
5099 int recvbufElements = 0;
5100
5101 // compute the total size of the buffer
5102 recvbufElements = recvcount * getCommSize(comm);
5103
5104 if(recvtype->isModifiedBufferRequired() ) {
5105 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
5106 } else {
5107 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
5108 }
5109
5110 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
5111 if(adType->isHandleRequired()) {
5113 }
5114 adType->startAssembly(h);
5115 if(sendtype->isModifiedBufferRequired()) {
5116 if(AMPI_IN_PLACE != sendbuf) {
5117 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
5118 } else {
5119 recvtype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
5120 }
5121 }
5122
5123 if(nullptr != h) {
5124 // gather the information for the reverse sweep
5125
5126 // create the index buffers
5127 if(AMPI_IN_PLACE != sendbuf) {
5128 h->sendbufCount = sendtype->computeActiveElements(sendcount);
5129 } else {
5130 h->sendbufCount = recvtype->computeActiveElements(recvcount);
5131 }
5132 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
5133 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
5134 h->recvbufCount = recvtype->computeActiveElements(recvcount);
5135 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
5136 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
5137
5138
5139 // extract the old primal values from the recv buffer if the AD tool
5140 // needs the primal values reset
5141 if(adType->isOldPrimalsRequired()) {
5142 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
5143 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
5144 }
5145
5146
5147 if(AMPI_IN_PLACE != sendbuf) {
5148 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
5149 } else {
5150 recvtype->getIndices(recvbuf, 0, h->sendbufIndices, 0, recvcount * getCommSize(comm));
5151 }
5152
5153 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
5154
5155 // pack all the variables in the handle
5159 h->sendcount = sendcount;
5160 h->sendtype = sendtype;
5161 h->recvcount = recvcount;
5162 h->recvtype = recvtype;
5163 h->comm = comm;
5164 }
5165
5166 if(!recvtype->isModifiedBufferRequired()) {
5167 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
5168 }
5169
5170 rStatus = MPI_Alltoall(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
5171 recvtype->getModifiedMpiType(), comm);
5172 adType->addToolAction(h);
5173
5174 if(recvtype->isModifiedBufferRequired()) {
5175 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
5176 }
5177
5178 if(nullptr != h) {
5179 // handle the recv buffers
5180 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
5181 }
5182
5183 adType->stopAssembly(h);
5184
5185 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5186 sendtype->deleteModifiedTypeBuffer(sendbufMod);
5187 }
5188 if(recvtype->isModifiedBufferRequired() ) {
5189 recvtype->deleteModifiedTypeBuffer(recvbufMod);
5190 }
5191
5192 // handle is deleted by the AD tool
5193 }
5194
5195 return rStatus;
5196 }
5197
5198#endif
5199#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
5200 template<typename SENDTYPE, typename RECVTYPE>
5203 typename SENDTYPE::IndexType* sendbufIndices;
5204 typename SENDTYPE::PrimalType* sendbufPrimals;
5205 /* required for async */ void* sendbufAdjoints;
5207 /* required for async */ int* sendbufCountVec;
5208 /* required for async */ int* sendbufDisplsVec;
5211 SENDTYPE* sendtype;
5213 typename RECVTYPE::IndexType* recvbufIndices;
5214 typename RECVTYPE::PrimalType* recvbufPrimals;
5215 typename RECVTYPE::PrimalType* recvbufOldPrimals;
5216 /* required for async */ void* recvbufAdjoints;
5218 /* required for async */ int* recvbufCountVec;
5219 /* required for async */ int* recvbufDisplsVec;
5222 RECVTYPE* recvtype;
5224
5226 if(nullptr != sendbufIndices) {
5227 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
5228 sendbufIndices = nullptr;
5229 }
5230 if(nullptr != sendbufPrimals) {
5231 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
5232 sendbufPrimals = nullptr;
5233 }
5234 if(nullptr != sendbufCount) {
5235 delete [] sendbufCount;
5236 sendbufCount = nullptr;
5237 }
5238 if(nullptr != recvbufIndices) {
5239 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
5240 recvbufIndices = nullptr;
5241 }
5242 if(nullptr != recvbufPrimals) {
5243 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
5244 recvbufPrimals = nullptr;
5245 }
5246 if(nullptr != recvbufOldPrimals) {
5247 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
5248 recvbufOldPrimals = nullptr;
5249 }
5250 if(nullptr != recvbufCount) {
5251 delete [] recvbufCount;
5252 recvbufCount = nullptr;
5253 }
5254 }
5255 };
5256
5257
5258 template<typename SENDTYPE, typename RECVTYPE>
5259 void AMPI_Alltoallv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
5261 (handle);
5262 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5263 (void)adType;
5264
5265 h->recvbufAdjoints = nullptr;
5267 adjointInterface->getVectorSize());
5268 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
5269 h->sendbufAdjoints = nullptr;
5271 adjointInterface->getVectorSize());
5272 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
5273 // Primal buffers are always linear in space so we can accesses them in one sweep
5274 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
5275
5276
5279 h->recvtype, h->comm);
5280
5281 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
5282 delete [] h->sendbufCountVec;
5283 delete [] h->sendbufDisplsVec;
5284 if(adType->isOldPrimalsRequired()) {
5285 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5286 }
5287 // Primal buffers are always linear in space so we can accesses them in one sweep
5288 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
5289 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
5290 delete [] h->recvbufCountVec;
5291 delete [] h->recvbufDisplsVec;
5292 }
5293
5294 template<typename SENDTYPE, typename RECVTYPE>
5295 void AMPI_Alltoallv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
5297 (handle);
5298 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5299 (void)adType;
5300
5301 h->recvbufAdjoints = nullptr;
5303 adjointInterface->getVectorSize());
5304 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5305 h->sendbufAdjoints = nullptr;
5307 adjointInterface->getVectorSize());
5308 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5309 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5310 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5311
5312
5315 h->recvtype, h->comm);
5316
5317 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5318 delete [] h->sendbufCountVec;
5319 delete [] h->sendbufDisplsVec;
5320 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5321 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5322 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5323 delete [] h->recvbufCountVec;
5324 delete [] h->recvbufDisplsVec;
5325 }
5326
5327 template<typename SENDTYPE, typename RECVTYPE>
5328 void AMPI_Alltoallv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
5330 (handle);
5331 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5332 (void)adType;
5333
5334 h->recvbufAdjoints = nullptr;
5336 adjointInterface->getVectorSize());
5337 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5338 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5339 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5340
5341 if(adType->isOldPrimalsRequired()) {
5342 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5343 }
5344 h->sendbufAdjoints = nullptr;
5346 adjointInterface->getVectorSize());
5347 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5348
5351 h->recvtype, h->comm);
5352
5353 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5354 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5355 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5356 delete [] h->sendbufCountVec;
5357 delete [] h->sendbufDisplsVec;
5358 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5359 delete [] h->recvbufCountVec;
5360 delete [] h->recvbufDisplsVec;
5361 }
5362
5363 template<typename SENDTYPE, typename RECVTYPE>
5364 int AMPI_Alltoallv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, MEDI_OPTIONAL_CONST int* sendcounts,
5365 MEDI_OPTIONAL_CONST int* sdispls, SENDTYPE* sendtype, typename RECVTYPE::Type* recvbuf,
5366 MEDI_OPTIONAL_CONST int* recvcounts, MEDI_OPTIONAL_CONST int* rdispls, RECVTYPE* recvtype, AMPI_Comm comm) {
5367 int rStatus;
5368 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
5369
5370 if(!adType->isActiveType()) {
5371 // call the regular function if the type is not active
5372 rStatus = MPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype->getMpiType(), recvbuf, recvcounts, rdispls,
5373 recvtype->getMpiType(), comm);
5374 } else {
5375
5376 // the type is an AD type so handle the buffers
5378 MEDI_OPTIONAL_CONST int* sdisplsMod = sdispls;
5379 int sdisplsTotalSize = 0;
5380 if(nullptr != sdispls) {
5381 sdisplsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
5382 if(recvtype->isModifiedBufferRequired()) {
5383 sdisplsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
5384 }
5385 }
5386 MEDI_OPTIONAL_CONST int* rdisplsMod = rdispls;
5387 int rdisplsTotalSize = 0;
5388 if(nullptr != rdispls) {
5389 rdisplsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
5390 if(recvtype->isModifiedBufferRequired()) {
5391 rdisplsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
5392 }
5393 }
5394 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
5395 int sendbufElements = 0;
5396
5397 // compute the total size of the buffer
5398 if(AMPI_IN_PLACE != sendbuf) {
5399 sendbufElements = sdisplsTotalSize;
5400 } else {
5401 sendbufElements = rdisplsTotalSize;
5402 }
5403
5404 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5405 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
5406 } else {
5407 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
5408 }
5409 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
5410 int recvbufElements = 0;
5411
5412 // compute the total size of the buffer
5413 recvbufElements = rdisplsTotalSize;
5414
5415 if(recvtype->isModifiedBufferRequired() ) {
5416 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
5417 } else {
5418 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
5419 }
5420
5421 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
5422 if(adType->isHandleRequired()) {
5424 }
5425 adType->startAssembly(h);
5426 if(sendtype->isModifiedBufferRequired()) {
5427 if(AMPI_IN_PLACE != sendbuf) {
5428 for(int i = 0; i < getCommSize(comm); ++i) {
5429 sendtype->copyIntoModifiedBuffer(sendbuf, sdispls[i], sendbufMod, sdisplsMod[i], sendcounts[i]);
5430 }
5431 } else {
5432 for(int i = 0; i < getCommSize(comm); ++i) {
5433 recvtype->copyIntoModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
5434 }
5435 }
5436 }
5437
5438 if(nullptr != h) {
5439 // gather the information for the reverse sweep
5440
5441 // create the index buffers
5442 if(AMPI_IN_PLACE != sendbuf) {
5443 createLinearIndexCounts(h->sendbufCount, sendcounts, sdispls, getCommSize(comm), sendtype);
5444 } else {
5445 createLinearIndexCounts(h->sendbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
5446 }
5447 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
5448 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
5449 createLinearIndexCounts(h->recvbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
5450 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
5451 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
5452
5453
5454 // extract the old primal values from the recv buffer if the AD tool
5455 // needs the primal values reset
5456 if(adType->isOldPrimalsRequired()) {
5457 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
5458 for(int i = 0; i < getCommSize(comm); ++i) {
5459 recvtype->getValues(recvbuf, rdispls[i], h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
5460 }
5461 }
5462
5463
5464 if(AMPI_IN_PLACE != sendbuf) {
5465 for(int i = 0; i < getCommSize(comm); ++i) {
5466 sendtype->getIndices(sendbuf, sdispls[i], h->sendbufIndices, sdisplsMod[i], sendcounts[i]);
5467 }
5468 } else {
5469 for(int i = 0; i < getCommSize(comm); ++i) {
5470 recvtype->getIndices(recvbuf, rdispls[i], h->sendbufIndices, rdisplsMod[i], recvcounts[i]);
5471 }
5472 }
5473
5474 for(int i = 0; i < getCommSize(comm); ++i) {
5475 recvtype->createIndices(recvbuf, rdispls[i], h->recvbufIndices, rdisplsMod[i], recvcounts[i]);
5476 }
5477
5478 // pack all the variables in the handle
5482 h->sendcounts = sendcounts;
5483 h->sdispls = sdispls;
5484 h->sendtype = sendtype;
5485 h->recvcounts = recvcounts;
5486 h->rdispls = rdispls;
5487 h->recvtype = recvtype;
5488 h->comm = comm;
5489 }
5490
5491 if(!recvtype->isModifiedBufferRequired()) {
5492 for(int i = 0; i < getCommSize(comm); ++i) {
5493 recvtype->clearIndices(recvbuf, rdispls[i], recvcounts[i]);
5494 }
5495 }
5496
5497 rStatus = MPI_Alltoallv(sendbufMod, sendcounts, sdisplsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcounts,
5498 rdisplsMod, recvtype->getModifiedMpiType(), comm);
5499 adType->addToolAction(h);
5500
5501 if(recvtype->isModifiedBufferRequired()) {
5502 for(int i = 0; i < getCommSize(comm); ++i) {
5503 recvtype->copyFromModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
5504 }
5505 }
5506
5507 if(nullptr != h) {
5508 // handle the recv buffers
5509 for(int i = 0; i < getCommSize(comm); ++i) {
5510 recvtype->registerValue(recvbuf, rdispls[i], h->recvbufIndices, h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
5511 }
5512 }
5513
5514 adType->stopAssembly(h);
5515 if(recvtype->isModifiedBufferRequired()) {
5516 delete [] sdisplsMod;
5517 }
5518 if(recvtype->isModifiedBufferRequired()) {
5519 delete [] rdisplsMod;
5520 }
5521
5522 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5523 sendtype->deleteModifiedTypeBuffer(sendbufMod);
5524 }
5525 if(recvtype->isModifiedBufferRequired() ) {
5526 recvtype->deleteModifiedTypeBuffer(recvbufMod);
5527 }
5528
5529 // handle is deleted by the AD tool
5530 }
5531
5532 return rStatus;
5533 }
5534
5535#endif
5536#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
5537 template<typename DATATYPE>
5540 typename DATATYPE::IndexType* bufferSendIndices;
5541 typename DATATYPE::PrimalType* bufferSendPrimals;
5542 /* required for async */ void* bufferSendAdjoints;
5546 typename DATATYPE::IndexType* bufferRecvIndices;
5547 typename DATATYPE::PrimalType* bufferRecvPrimals;
5548 typename DATATYPE::PrimalType* bufferRecvOldPrimals;
5549 /* required for async */ void* bufferRecvAdjoints;
5553 DATATYPE* datatype;
5554 int root;
5556
5558 if(nullptr != bufferSendIndices) {
5559 datatype->getADTool().deleteIndexTypeBuffer(bufferSendIndices);
5560 bufferSendIndices = nullptr;
5561 }
5562 if(nullptr != bufferSendPrimals) {
5563 datatype->getADTool().deletePrimalTypeBuffer(bufferSendPrimals);
5564 bufferSendPrimals = nullptr;
5565 }
5566 if(nullptr != bufferRecvIndices) {
5567 datatype->getADTool().deleteIndexTypeBuffer(bufferRecvIndices);
5568 bufferRecvIndices = nullptr;
5569 }
5570 if(nullptr != bufferRecvPrimals) {
5571 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvPrimals);
5572 bufferRecvPrimals = nullptr;
5573 }
5574 if(nullptr != bufferRecvOldPrimals) {
5575 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvOldPrimals);
5576 bufferRecvOldPrimals = nullptr;
5577 }
5578 }
5579 };
5580
5581
5582 template<typename DATATYPE>
5583 void AMPI_Bcast_wrap_p(HandleBase* handle, AdjointInterface* adjointInterface) {
5585 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5586 (void)adType;
5587
5588 h->bufferRecvAdjoints = nullptr;
5589 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
5590 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferRecvPrimals, h->bufferRecvTotalSize );
5591 h->bufferSendAdjoints = nullptr;
5592 if(h->root == getCommRank(h->comm)) {
5593 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
5594 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferSendPrimals, h->bufferSendTotalSize );
5595 // Primal buffers are always linear in space so we can accesses them in one sweep
5597
5598 }
5599
5601 h->count, h->datatype, h->root, h->comm);
5602
5603 if(h->root == getCommRank(h->comm)) {
5604 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferSendPrimals);
5605 }
5606 if(adType->isOldPrimalsRequired()) {
5608 }
5609 // Primal buffers are always linear in space so we can accesses them in one sweep
5611 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferRecvPrimals);
5612 }
5613
5614 template<typename DATATYPE>
5615 void AMPI_Bcast_wrap_d(HandleBase* handle, AdjointInterface* adjointInterface) {
5617 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5618 (void)adType;
5619
5620 h->bufferRecvAdjoints = nullptr;
5621 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
5623 h->bufferSendAdjoints = nullptr;
5624 if(h->root == getCommRank(h->comm)) {
5625 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
5627 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5629
5630 }
5631
5633 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm);
5634
5635 if(h->root == getCommRank(h->comm)) {
5636 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
5637 }
5638 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5640 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
5641 }
5642
5643 template<typename DATATYPE>
5644 void AMPI_Bcast_wrap_b(HandleBase* handle, AdjointInterface* adjointInterface) {
5646 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5647 (void)adType;
5648
5649 h->bufferRecvAdjoints = nullptr;
5650 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
5652 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5654
5655 if(adType->isOldPrimalsRequired()) {
5657 }
5658 h->bufferSendAdjoints = nullptr;
5659 if(h->root == getCommRank(h->comm)) {
5660 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
5662 }
5663
5665 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm);
5666
5667 if(h->root == getCommRank(h->comm)) {
5669 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5671 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
5672 }
5673 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
5674 }
5675
5676 template<typename DATATYPE>
5677 int AMPI_Bcast_wrap(typename DATATYPE::Type* bufferSend, typename DATATYPE::Type* bufferRecv, int count,
5678 DATATYPE* datatype, int root, AMPI_Comm comm) {
5679 int rStatus;
5680 ADToolInterface const* adType = selectADTool(datatype->getADTool());
5681
5682 if(!adType->isActiveType()) {
5683 // call the regular function if the type is not active
5684 rStatus = MPI_Bcast_wrap(bufferSend, bufferRecv, count, datatype->getMpiType(), root, comm);
5685 } else {
5686
5687 // the type is an AD type so handle the buffers
5689 typename DATATYPE::ModifiedType* bufferSendMod = nullptr;
5690 int bufferSendElements = 0;
5691
5692 if(root == getCommRank(comm)) {
5693 // compute the total size of the buffer
5694 if(AMPI_IN_PLACE != bufferSend) {
5695 bufferSendElements = count;
5696 } else {
5697 bufferSendElements = count;
5698 }
5699
5700 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
5701 datatype->createModifiedTypeBuffer(bufferSendMod, bufferSendElements);
5702 } else {
5703 bufferSendMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferSend));
5704 }
5705 }
5706 typename DATATYPE::ModifiedType* bufferRecvMod = nullptr;
5707 int bufferRecvElements = 0;
5708
5709 // compute the total size of the buffer
5710 bufferRecvElements = count;
5711
5712 if(datatype->isModifiedBufferRequired() ) {
5713 datatype->createModifiedTypeBuffer(bufferRecvMod, bufferRecvElements);
5714 } else {
5715 bufferRecvMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferRecv));
5716 }
5717
5718 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
5719 if(adType->isHandleRequired()) {
5721 }
5722 adType->startAssembly(h);
5723 if(root == getCommRank(comm)) {
5724 if(datatype->isModifiedBufferRequired()) {
5725 if(AMPI_IN_PLACE != bufferSend) {
5726 datatype->copyIntoModifiedBuffer(bufferSend, 0, bufferSendMod, 0, count);
5727 } else {
5728 datatype->copyIntoModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
5729 }
5730 }
5731 }
5732
5733 if(nullptr != h) {
5734 // gather the information for the reverse sweep
5735
5736 // create the index buffers
5737 if(root == getCommRank(comm)) {
5738 if(AMPI_IN_PLACE != bufferSend) {
5739 h->bufferSendCount = datatype->computeActiveElements(count);
5740 } else {
5741 h->bufferSendCount = datatype->computeActiveElements(count);
5742 }
5743 h->bufferSendTotalSize = datatype->computeActiveElements(bufferSendElements);
5744 datatype->getADTool().createIndexTypeBuffer(h->bufferSendIndices, h->bufferSendTotalSize);
5745 }
5746 h->bufferRecvCount = datatype->computeActiveElements(count);
5747 h->bufferRecvTotalSize = datatype->computeActiveElements(bufferRecvElements);
5748 datatype->getADTool().createIndexTypeBuffer(h->bufferRecvIndices, h->bufferRecvTotalSize);
5749
5750
5751 // extract the old primal values from the recv buffer if the AD tool
5752 // needs the primal values reset
5753 if(adType->isOldPrimalsRequired()) {
5754 datatype->getADTool().createPrimalTypeBuffer(h->bufferRecvOldPrimals, h->bufferRecvTotalSize);
5755 datatype->getValues(bufferRecv, 0, h->bufferRecvOldPrimals, 0, count);
5756 }
5757
5758
5759 if(root == getCommRank(comm)) {
5760 if(AMPI_IN_PLACE != bufferSend) {
5761 datatype->getIndices(bufferSend, 0, h->bufferSendIndices, 0, count);
5762 } else {
5763 datatype->getIndices(bufferRecv, 0, h->bufferSendIndices, 0, count);
5764 }
5765 }
5766
5767 datatype->createIndices(bufferRecv, 0, h->bufferRecvIndices, 0, count);
5768
5769 // pack all the variables in the handle
5773 h->count = count;
5774 h->datatype = datatype;
5775 h->root = root;
5776 h->comm = comm;
5777 }
5778
5779 if(!datatype->isModifiedBufferRequired()) {
5780 datatype->clearIndices(bufferRecv, 0, count);
5781 }
5782
5783 rStatus = MPI_Bcast_wrap(bufferSendMod, bufferRecvMod, count, datatype->getModifiedMpiType(), root, comm);
5784 adType->addToolAction(h);
5785
5786 if(datatype->isModifiedBufferRequired()) {
5787 datatype->copyFromModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
5788 }
5789
5790 if(nullptr != h) {
5791 // handle the recv buffers
5792 datatype->registerValue(bufferRecv, 0, h->bufferRecvIndices, h->bufferRecvOldPrimals, 0, count);
5793 }
5794
5795 adType->stopAssembly(h);
5796
5797 if(root == getCommRank(comm)) {
5798 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
5799 datatype->deleteModifiedTypeBuffer(bufferSendMod);
5800 }
5801 }
5802 if(datatype->isModifiedBufferRequired() ) {
5803 datatype->deleteModifiedTypeBuffer(bufferRecvMod);
5804 }
5805
5806 // handle is deleted by the AD tool
5807 }
5808
5809 return rStatus;
5810 }
5811
5812#endif
5813#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
5814 template<typename SENDTYPE, typename RECVTYPE>
5817 typename SENDTYPE::IndexType* sendbufIndices;
5818 typename SENDTYPE::PrimalType* sendbufPrimals;
5819 /* required for async */ void* sendbufAdjoints;
5823 SENDTYPE* sendtype;
5825 typename RECVTYPE::IndexType* recvbufIndices;
5826 typename RECVTYPE::PrimalType* recvbufPrimals;
5827 typename RECVTYPE::PrimalType* recvbufOldPrimals;
5828 /* required for async */ void* recvbufAdjoints;
5832 RECVTYPE* recvtype;
5833 int root;
5835
5837 if(nullptr != sendbufIndices) {
5838 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
5839 sendbufIndices = nullptr;
5840 }
5841 if(nullptr != sendbufPrimals) {
5842 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
5843 sendbufPrimals = nullptr;
5844 }
5845 if(nullptr != recvbufIndices) {
5846 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
5847 recvbufIndices = nullptr;
5848 }
5849 if(nullptr != recvbufPrimals) {
5850 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
5851 recvbufPrimals = nullptr;
5852 }
5853 if(nullptr != recvbufOldPrimals) {
5854 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
5855 recvbufOldPrimals = nullptr;
5856 }
5857 }
5858 };
5859
5860
5861 template<typename SENDTYPE, typename RECVTYPE>
5862 void AMPI_Gather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
5864 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5865 (void)adType;
5866
5867 h->recvbufAdjoints = nullptr;
5868 if(h->root == getCommRank(h->comm)) {
5869 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5870 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
5871 }
5872 h->sendbufAdjoints = nullptr;
5873 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5874 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
5875 // Primal buffers are always linear in space so we can accesses them in one sweep
5876 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
5877
5878
5880 h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
5881
5882 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
5883 if(adType->isOldPrimalsRequired()) {
5884 if(h->root == getCommRank(h->comm)) {
5885 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5886 }
5887 }
5888 if(h->root == getCommRank(h->comm)) {
5889 // Primal buffers are always linear in space so we can accesses them in one sweep
5890 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
5891 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
5892 }
5893 }
5894
5895 template<typename SENDTYPE, typename RECVTYPE>
5896 void AMPI_Gather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
5898 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5899 (void)adType;
5900
5901 h->recvbufAdjoints = nullptr;
5902 if(h->root == getCommRank(h->comm)) {
5903 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5904 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5905 }
5906 h->sendbufAdjoints = nullptr;
5907 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5908 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5909 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5910 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5911
5912
5915
5916 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5917 if(h->root == getCommRank(h->comm)) {
5918 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5919 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5920 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5921 }
5922 }
5923
5924 template<typename SENDTYPE, typename RECVTYPE>
5925 void AMPI_Gather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
5927 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5928 (void)adType;
5929
5930 h->recvbufAdjoints = nullptr;
5931 if(h->root == getCommRank(h->comm)) {
5932 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5933 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5934 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5935 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5936
5937 }
5938 if(adType->isOldPrimalsRequired()) {
5939 if(h->root == getCommRank(h->comm)) {
5940 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5941 }
5942 }
5943 h->sendbufAdjoints = nullptr;
5944 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5945 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5946
5949
5950 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5951 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5952 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5953 if(h->root == getCommRank(h->comm)) {
5954 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5955 }
5956 }
5957
5958 template<typename SENDTYPE, typename RECVTYPE>
5959 int AMPI_Gather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
5960 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm) {
5961 int rStatus;
5962 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
5963
5964 if(!adType->isActiveType()) {
5965 // call the regular function if the type is not active
5966 rStatus = MPI_Gather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
5967 comm);
5968 } else {
5969
5970 // the type is an AD type so handle the buffers
5972 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
5973 int sendbufElements = 0;
5974
5975 // compute the total size of the buffer
5976 if(AMPI_IN_PLACE != sendbuf) {
5977 sendbufElements = sendcount;
5978 } else {
5979 sendbufElements = recvcount;
5980 }
5981
5982 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5983 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
5984 } else {
5985 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
5986 }
5987 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
5988 int recvbufElements = 0;
5989
5990 if(root == getCommRank(comm)) {
5991 // compute the total size of the buffer
5992 recvbufElements = recvcount * getCommSize(comm);
5993
5994 if(recvtype->isModifiedBufferRequired() ) {
5995 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
5996 } else {
5997 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
5998 }
5999 }
6000
6001 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
6002 if(adType->isHandleRequired()) {
6004 }
6005 adType->startAssembly(h);
6006 if(sendtype->isModifiedBufferRequired()) {
6007 if(AMPI_IN_PLACE != sendbuf) {
6008 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
6009 } else {
6010 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
6011 recvcount);
6012 }
6013 }
6014
6015 if(nullptr != h) {
6016 // gather the information for the reverse sweep
6017
6018 // create the index buffers
6019 if(AMPI_IN_PLACE != sendbuf) {
6020 h->sendbufCount = sendtype->computeActiveElements(sendcount);
6021 } else {
6022 h->sendbufCount = recvtype->computeActiveElements(recvcount);
6023 }
6024 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
6025 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
6026 if(root == getCommRank(comm)) {
6027 h->recvbufCount = recvtype->computeActiveElements(recvcount);
6028 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
6029 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
6030 }
6031
6032
6033 // extract the old primal values from the recv buffer if the AD tool
6034 // needs the primal values reset
6035 if(adType->isOldPrimalsRequired()) {
6036 if(root == getCommRank(comm)) {
6037 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
6038 if(root == getCommRank(comm)) {
6039 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
6040 }
6041 }
6042 }
6043
6044
6045 if(AMPI_IN_PLACE != sendbuf) {
6046 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
6047 } else {
6048 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
6049 }
6050
6051 if(root == getCommRank(comm)) {
6052 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
6053 }
6054
6055 // pack all the variables in the handle
6059 h->sendcount = sendcount;
6060 h->sendtype = sendtype;
6061 h->recvcount = recvcount;
6062 h->recvtype = recvtype;
6063 h->root = root;
6064 h->comm = comm;
6065 }
6066
6067 if(root == getCommRank(comm)) {
6068 if(!recvtype->isModifiedBufferRequired()) {
6069 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
6070 }
6071 }
6072
6073 rStatus = MPI_Gather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
6074 recvtype->getModifiedMpiType(), root, comm);
6075 adType->addToolAction(h);
6076
6077 if(root == getCommRank(comm)) {
6078 if(recvtype->isModifiedBufferRequired()) {
6079 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
6080 }
6081 }
6082
6083 if(nullptr != h) {
6084 // handle the recv buffers
6085 if(root == getCommRank(comm)) {
6086 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
6087 }
6088 }
6089
6090 adType->stopAssembly(h);
6091
6092 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6093 sendtype->deleteModifiedTypeBuffer(sendbufMod);
6094 }
6095 if(root == getCommRank(comm)) {
6096 if(recvtype->isModifiedBufferRequired() ) {
6097 recvtype->deleteModifiedTypeBuffer(recvbufMod);
6098 }
6099 }
6100
6101 // handle is deleted by the AD tool
6102 }
6103
6104 return rStatus;
6105 }
6106
6107#endif
6108#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
6109 template<typename SENDTYPE, typename RECVTYPE>
6112 typename SENDTYPE::IndexType* sendbufIndices;
6113 typename SENDTYPE::PrimalType* sendbufPrimals;
6114 /* required for async */ void* sendbufAdjoints;
6118 SENDTYPE* sendtype;
6120 typename RECVTYPE::IndexType* recvbufIndices;
6121 typename RECVTYPE::PrimalType* recvbufPrimals;
6122 typename RECVTYPE::PrimalType* recvbufOldPrimals;
6123 /* required for async */ void* recvbufAdjoints;
6125 /* required for async */ int* recvbufCountVec;
6126 /* required for async */ int* recvbufDisplsVec;
6127 const int* recvcounts;
6128 const int* displs;
6129 RECVTYPE* recvtype;
6130 int root;
6132
6134 if(nullptr != sendbufIndices) {
6135 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
6136 sendbufIndices = nullptr;
6137 }
6138 if(nullptr != sendbufPrimals) {
6139 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
6140 sendbufPrimals = nullptr;
6141 }
6142 if(nullptr != recvbufIndices) {
6143 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
6144 recvbufIndices = nullptr;
6145 }
6146 if(nullptr != recvbufPrimals) {
6147 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
6148 recvbufPrimals = nullptr;
6149 }
6150 if(nullptr != recvbufOldPrimals) {
6151 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
6152 recvbufOldPrimals = nullptr;
6153 }
6154 if(nullptr != recvbufCount) {
6155 delete [] recvbufCount;
6156 recvbufCount = nullptr;
6157 }
6158 }
6159 };
6160
6161
6162 template<typename SENDTYPE, typename RECVTYPE>
6163 void AMPI_Gatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
6165 (handle);
6166 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6167 (void)adType;
6168
6169 h->recvbufAdjoints = nullptr;
6170 if(h->root == getCommRank(h->comm)) {
6172 adjointInterface->getVectorSize());
6173 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
6174 }
6175 h->sendbufAdjoints = nullptr;
6176 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6177 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
6178 // Primal buffers are always linear in space so we can accesses them in one sweep
6179 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
6180
6181
6184
6185 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
6186 if(adType->isOldPrimalsRequired()) {
6187 if(h->root == getCommRank(h->comm)) {
6188 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6189 }
6190 }
6191 if(h->root == getCommRank(h->comm)) {
6192 // Primal buffers are always linear in space so we can accesses them in one sweep
6193 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
6194 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
6195 delete [] h->recvbufCountVec;
6196 delete [] h->recvbufDisplsVec;
6197 }
6198 }
6199
6200 template<typename SENDTYPE, typename RECVTYPE>
6201 void AMPI_Gatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
6203 (handle);
6204 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6205 (void)adType;
6206
6207 h->recvbufAdjoints = nullptr;
6208 if(h->root == getCommRank(h->comm)) {
6210 adjointInterface->getVectorSize());
6211 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6212 }
6213 h->sendbufAdjoints = nullptr;
6214 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6215 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6216 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6217 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6218
6219
6222
6223 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6224 if(h->root == getCommRank(h->comm)) {
6225 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6226 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6227 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6228 delete [] h->recvbufCountVec;
6229 delete [] h->recvbufDisplsVec;
6230 }
6231 }
6232
6233 template<typename SENDTYPE, typename RECVTYPE>
6234 void AMPI_Gatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
6236 (handle);
6237 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6238 (void)adType;
6239
6240 h->recvbufAdjoints = nullptr;
6241 if(h->root == getCommRank(h->comm)) {
6243 adjointInterface->getVectorSize());
6244 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6245 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6246 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6247
6248 }
6249 if(adType->isOldPrimalsRequired()) {
6250 if(h->root == getCommRank(h->comm)) {
6251 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6252 }
6253 }
6254 h->sendbufAdjoints = nullptr;
6255 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6256 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6257
6260
6261 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6262 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6263 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6264 if(h->root == getCommRank(h->comm)) {
6265 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6266 delete [] h->recvbufCountVec;
6267 delete [] h->recvbufDisplsVec;
6268 }
6269 }
6270
6271 template<typename SENDTYPE, typename RECVTYPE>
6272 int AMPI_Gatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
6273 typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* displs, RECVTYPE* recvtype, int root,
6274 AMPI_Comm comm) {
6275 int rStatus;
6276 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
6277
6278 if(!adType->isActiveType()) {
6279 // call the regular function if the type is not active
6280 rStatus = MPI_Gatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs, recvtype->getMpiType(),
6281 root, comm);
6282 } else {
6283
6284 // the type is an AD type so handle the buffers
6286 MEDI_OPTIONAL_CONST int* displsMod = displs;
6287 int displsTotalSize = 0;
6288 if(nullptr != displs) {
6289 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
6290 if(recvtype->isModifiedBufferRequired()) {
6291 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
6292 }
6293 }
6294 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
6295 int sendbufElements = 0;
6296
6297 // compute the total size of the buffer
6298 if(AMPI_IN_PLACE != sendbuf) {
6299 sendbufElements = sendcount;
6300 } else {
6301 sendbufElements = recvcounts[getCommRank(comm)];
6302 }
6303
6304 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6305 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
6306 } else {
6307 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
6308 }
6309 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
6310 int recvbufElements = 0;
6311
6312 if(root == getCommRank(comm)) {
6313 // compute the total size of the buffer
6314 recvbufElements = displsTotalSize;
6315
6316 if(recvtype->isModifiedBufferRequired() ) {
6317 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
6318 } else {
6319 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
6320 }
6321 }
6322
6323 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
6324 if(adType->isHandleRequired()) {
6326 }
6327 adType->startAssembly(h);
6328 if(sendtype->isModifiedBufferRequired()) {
6329 if(AMPI_IN_PLACE != sendbuf) {
6330 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
6331 } else {
6332 {
6333 const int rank = getCommRank(comm);
6334 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
6335 }
6336 }
6337 }
6338
6339 if(nullptr != h) {
6340 // gather the information for the reverse sweep
6341
6342 // create the index buffers
6343 if(AMPI_IN_PLACE != sendbuf) {
6344 h->sendbufCount = sendtype->computeActiveElements(sendcount);
6345 } else {
6346 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
6347 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
6348 }
6349 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
6350 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
6351 if(root == getCommRank(comm)) {
6352 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
6353 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
6354 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
6355 }
6356
6357
6358 // extract the old primal values from the recv buffer if the AD tool
6359 // needs the primal values reset
6360 if(adType->isOldPrimalsRequired()) {
6361 if(root == getCommRank(comm)) {
6362 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
6363 if(root == getCommRank(comm)) {
6364 for(int i = 0; i < getCommSize(comm); ++i) {
6365 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
6366 }
6367 }
6368 }
6369 }
6370
6371
6372 if(AMPI_IN_PLACE != sendbuf) {
6373 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
6374 } else {
6375 {
6376 const int rank = getCommRank(comm);
6377 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
6378 }
6379 }
6380
6381 if(root == getCommRank(comm)) {
6382 for(int i = 0; i < getCommSize(comm); ++i) {
6383 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
6384 }
6385 }
6386
6387 // pack all the variables in the handle
6391 h->sendcount = sendcount;
6392 h->sendtype = sendtype;
6393 h->recvcounts = recvcounts;
6394 h->displs = displs;
6395 h->recvtype = recvtype;
6396 h->root = root;
6397 h->comm = comm;
6398 }
6399
6400 if(root == getCommRank(comm)) {
6401 if(!recvtype->isModifiedBufferRequired()) {
6402 for(int i = 0; i < getCommSize(comm); ++i) {
6403 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
6404 }
6405 }
6406 }
6407
6408 rStatus = MPI_Gatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
6409 recvtype->getModifiedMpiType(), root, comm);
6410 adType->addToolAction(h);
6411
6412 if(root == getCommRank(comm)) {
6413 if(recvtype->isModifiedBufferRequired()) {
6414 for(int i = 0; i < getCommSize(comm); ++i) {
6415 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
6416 }
6417 }
6418 }
6419
6420 if(nullptr != h) {
6421 // handle the recv buffers
6422 if(root == getCommRank(comm)) {
6423 for(int i = 0; i < getCommSize(comm); ++i) {
6424 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
6425 }
6426 }
6427 }
6428
6429 adType->stopAssembly(h);
6430 if(recvtype->isModifiedBufferRequired()) {
6431 delete [] displsMod;
6432 }
6433
6434 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6435 sendtype->deleteModifiedTypeBuffer(sendbufMod);
6436 }
6437 if(root == getCommRank(comm)) {
6438 if(recvtype->isModifiedBufferRequired() ) {
6439 recvtype->deleteModifiedTypeBuffer(recvbufMod);
6440 }
6441 }
6442
6443 // handle is deleted by the AD tool
6444 }
6445
6446 return rStatus;
6447 }
6448
6449#endif
6450#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
6451 template<typename SENDTYPE, typename RECVTYPE>
6454 typename SENDTYPE::IndexType* sendbufIndices;
6455 typename SENDTYPE::PrimalType* sendbufPrimals;
6456 /* required for async */ void* sendbufAdjoints;
6460 SENDTYPE* sendtype;
6462 typename RECVTYPE::IndexType* recvbufIndices;
6463 typename RECVTYPE::PrimalType* recvbufPrimals;
6464 typename RECVTYPE::PrimalType* recvbufOldPrimals;
6465 /* required for async */ void* recvbufAdjoints;
6469 RECVTYPE* recvtype;
6471
6473 if(nullptr != sendbufIndices) {
6474 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
6475 sendbufIndices = nullptr;
6476 }
6477 if(nullptr != sendbufPrimals) {
6478 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
6479 sendbufPrimals = nullptr;
6480 }
6481 if(nullptr != recvbufIndices) {
6482 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
6483 recvbufIndices = nullptr;
6484 }
6485 if(nullptr != recvbufPrimals) {
6486 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
6487 recvbufPrimals = nullptr;
6488 }
6489 if(nullptr != recvbufOldPrimals) {
6490 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
6491 recvbufOldPrimals = nullptr;
6492 }
6493 }
6494 };
6495
6496 template<typename SENDTYPE, typename RECVTYPE>
6498 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
6499 typename SENDTYPE::ModifiedType* sendbufMod;
6501 SENDTYPE* sendtype;
6502 typename RECVTYPE::Type* recvbuf;
6503 typename RECVTYPE::ModifiedType* recvbufMod;
6505 RECVTYPE* recvtype;
6508 };
6509
6510 template<typename SENDTYPE, typename RECVTYPE>
6511 void AMPI_Iallgather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
6513 (handle);
6514 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6515 (void)adType;
6516
6517 h->recvbufAdjoints = nullptr;
6518 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
6519 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
6520 h->sendbufAdjoints = nullptr;
6521 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6522 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
6523 // Primal buffers are always linear in space so we can accesses them in one sweep
6524 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
6525
6526
6529
6530 }
6531
6532 template<typename SENDTYPE, typename RECVTYPE>
6533 void AMPI_Iallgather_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
6534
6536 (handle);
6537 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6538 (void)adType;
6539 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
6540
6541 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
6542 if(adType->isOldPrimalsRequired()) {
6543 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6544 }
6545 // Primal buffers are always linear in space so we can accesses them in one sweep
6546 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
6547 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
6548 }
6549
6550 template<typename SENDTYPE, typename RECVTYPE>
6551 void AMPI_Iallgather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
6553 (handle);
6554 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6555 (void)adType;
6556
6557 h->recvbufAdjoints = nullptr;
6558 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
6559 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6560 h->sendbufAdjoints = nullptr;
6561 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6562 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6563 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6564 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6565
6566
6569
6570 }
6571
6572 template<typename SENDTYPE, typename RECVTYPE>
6573 void AMPI_Iallgather_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
6574
6576 (handle);
6577 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6578 (void)adType;
6579 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
6580
6581 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6582 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6583 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6584 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6585 }
6586
6587 template<typename SENDTYPE, typename RECVTYPE>
6588 void AMPI_Iallgather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
6590 (handle);
6591 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6592 (void)adType;
6593
6594 h->recvbufAdjoints = nullptr;
6595 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
6596 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6597 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6598 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6599
6600 if(adType->isOldPrimalsRequired()) {
6601 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6602 }
6603 h->sendbufAdjoints = nullptr;
6604 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6606
6609
6610 }
6611
6612 template<typename SENDTYPE, typename RECVTYPE>
6613 void AMPI_Iallgather_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
6614
6616 (handle);
6617 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6618 (void)adType;
6619 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
6620
6621 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
6622 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6623 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6624 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6625 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6626 }
6627
6628 template<typename SENDTYPE, typename RECVTYPE>
6629 int AMPI_Iallgather_finish(HandleBase* handle);
6630 template<typename SENDTYPE, typename RECVTYPE>
6631 int AMPI_Iallgather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
6632 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm, AMPI_Request* request) {
6633 int rStatus;
6634 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
6635
6636 if(!adType->isActiveType()) {
6637 // call the regular function if the type is not active
6638 rStatus = MPI_Iallgather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm,
6639 &request->request);
6640 } else {
6641
6642 // the type is an AD type so handle the buffers
6644 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
6645 int sendbufElements = 0;
6646
6647 // compute the total size of the buffer
6648 if(AMPI_IN_PLACE != sendbuf) {
6649 sendbufElements = sendcount;
6650 } else {
6651 sendbufElements = recvcount;
6652 }
6653
6654 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6655 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
6656 } else {
6657 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
6658 }
6659 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
6660 int recvbufElements = 0;
6661
6662 // compute the total size of the buffer
6663 recvbufElements = recvcount * getCommSize(comm);
6664
6665 if(recvtype->isModifiedBufferRequired() ) {
6666 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
6667 } else {
6668 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
6669 }
6670
6671 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
6672 if(adType->isHandleRequired()) {
6674 }
6675 adType->startAssembly(h);
6676 if(sendtype->isModifiedBufferRequired()) {
6677 if(AMPI_IN_PLACE != sendbuf) {
6678 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
6679 } else {
6680 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
6681 recvcount);
6682 }
6683 }
6684
6685 if(nullptr != h) {
6686 // gather the information for the reverse sweep
6687
6688 // create the index buffers
6689 if(AMPI_IN_PLACE != sendbuf) {
6690 h->sendbufCount = sendtype->computeActiveElements(sendcount);
6691 } else {
6692 h->sendbufCount = recvtype->computeActiveElements(recvcount);
6693 }
6694 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
6695 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
6696 h->recvbufCount = recvtype->computeActiveElements(recvcount);
6697 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
6698 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
6699
6700
6701 // extract the old primal values from the recv buffer if the AD tool
6702 // needs the primal values reset
6703 if(adType->isOldPrimalsRequired()) {
6704 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
6705 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
6706 }
6707
6708
6709 if(AMPI_IN_PLACE != sendbuf) {
6710 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
6711 } else {
6712 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
6713 }
6714
6715 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
6716
6717 // pack all the variables in the handle
6721 h->sendcount = sendcount;
6722 h->sendtype = sendtype;
6723 h->recvcount = recvcount;
6724 h->recvtype = recvtype;
6725 h->comm = comm;
6726 }
6727
6728 if(!recvtype->isModifiedBufferRequired()) {
6729 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
6730 }
6731
6732 rStatus = MPI_Iallgather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
6733 recvtype->getModifiedMpiType(), comm, &request->request);
6734
6736 asyncHandle->sendbuf = sendbuf;
6737 asyncHandle->sendbufMod = sendbufMod;
6738 asyncHandle->sendcount = sendcount;
6739 asyncHandle->sendtype = sendtype;
6740 asyncHandle->recvbuf = recvbuf;
6741 asyncHandle->recvbufMod = recvbufMod;
6742 asyncHandle->recvcount = recvcount;
6743 asyncHandle->recvtype = recvtype;
6744 asyncHandle->comm = comm;
6745 asyncHandle->toolHandle = h;
6746 request->handle = asyncHandle;
6748
6749 // create adjoint wait
6750 if(nullptr != h) {
6753 adType->addToolAction(waitH);
6754 }
6755 }
6756
6757 return rStatus;
6758 }
6759
6760 template<typename SENDTYPE, typename RECVTYPE>
6762 int rStatus = 0;
6763
6766 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
6767 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
6768 int sendcount = asyncHandle->sendcount;
6769 SENDTYPE* sendtype = asyncHandle->sendtype;
6770 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
6771 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
6772 int recvcount = asyncHandle->recvcount;
6773 RECVTYPE* recvtype = asyncHandle->recvtype;
6774 AMPI_Comm comm = asyncHandle->comm;
6775 AMPI_Request* request = asyncHandle->request;
6777 (asyncHandle->toolHandle);
6778 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
6779 MEDI_UNUSED(h); // Unused generated to ignore warnings
6780 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
6781 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
6782 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
6783 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
6784 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
6785 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
6786 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
6787 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
6788 MEDI_UNUSED(comm); // Unused generated to ignore warnings
6789 MEDI_UNUSED(request); // Unused generated to ignore warnings
6790
6791 delete asyncHandle;
6792
6793 if(adType->isActiveType()) {
6794
6795 adType->addToolAction(h);
6796
6797 if(recvtype->isModifiedBufferRequired()) {
6798 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
6799 }
6800
6801 if(nullptr != h) {
6802 // handle the recv buffers
6803 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
6804 }
6805
6806 adType->stopAssembly(h);
6807
6808 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6809 sendtype->deleteModifiedTypeBuffer(sendbufMod);
6810 }
6811 if(recvtype->isModifiedBufferRequired() ) {
6812 recvtype->deleteModifiedTypeBuffer(recvbufMod);
6813 }
6814
6815 // handle is deleted by the AD tool
6816 }
6817
6818 return rStatus;
6819 }
6820
6821#endif
6822#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
6823 template<typename SENDTYPE, typename RECVTYPE>
6826 typename SENDTYPE::IndexType* sendbufIndices;
6827 typename SENDTYPE::PrimalType* sendbufPrimals;
6828 /* required for async */ void* sendbufAdjoints;
6832 SENDTYPE* sendtype;
6834 typename RECVTYPE::IndexType* recvbufIndices;
6835 typename RECVTYPE::PrimalType* recvbufPrimals;
6836 typename RECVTYPE::PrimalType* recvbufOldPrimals;
6837 /* required for async */ void* recvbufAdjoints;
6839 /* required for async */ int* recvbufCountVec;
6840 /* required for async */ int* recvbufDisplsVec;
6841 const int* recvcounts;
6842 const int* displs;
6843 RECVTYPE* recvtype;
6845
6847 if(nullptr != sendbufIndices) {
6848 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
6849 sendbufIndices = nullptr;
6850 }
6851 if(nullptr != sendbufPrimals) {
6852 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
6853 sendbufPrimals = nullptr;
6854 }
6855 if(nullptr != recvbufIndices) {
6856 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
6857 recvbufIndices = nullptr;
6858 }
6859 if(nullptr != recvbufPrimals) {
6860 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
6861 recvbufPrimals = nullptr;
6862 }
6863 if(nullptr != recvbufOldPrimals) {
6864 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
6865 recvbufOldPrimals = nullptr;
6866 }
6867 if(nullptr != recvbufCount) {
6868 delete [] recvbufCount;
6869 recvbufCount = nullptr;
6870 }
6871 }
6872 };
6873
6874 template<typename SENDTYPE, typename RECVTYPE>
6876 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
6877 typename SENDTYPE::ModifiedType* sendbufMod;
6879 SENDTYPE* sendtype;
6880 typename RECVTYPE::Type* recvbuf;
6881 typename RECVTYPE::ModifiedType* recvbufMod;
6882 const int* displsMod;
6883 const int* recvcounts;
6884 const int* displs;
6885 RECVTYPE* recvtype;
6888 };
6889
6890 template<typename SENDTYPE, typename RECVTYPE>
6891 void AMPI_Iallgatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
6894 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6895 (void)adType;
6896
6897 h->recvbufAdjoints = nullptr;
6899 adjointInterface->getVectorSize());
6900 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
6901 h->sendbufAdjoints = nullptr;
6902 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6903 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
6904 // Primal buffers are always linear in space so we can accesses them in one sweep
6905 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
6906
6907
6910 &h->requestReverse);
6911
6912 }
6913
6914 template<typename SENDTYPE, typename RECVTYPE>
6915 void AMPI_Iallgatherv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
6916
6919 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6920 (void)adType;
6921 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
6922
6923 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
6924 if(adType->isOldPrimalsRequired()) {
6925 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6926 }
6927 // Primal buffers are always linear in space so we can accesses them in one sweep
6928 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
6929 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
6930 delete [] h->recvbufCountVec;
6931 delete [] h->recvbufDisplsVec;
6932 }
6933
6934 template<typename SENDTYPE, typename RECVTYPE>
6935 void AMPI_Iallgatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
6938 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6939 (void)adType;
6940
6941 h->recvbufAdjoints = nullptr;
6943 adjointInterface->getVectorSize());
6944 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6945 h->sendbufAdjoints = nullptr;
6946 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6947 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6948 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6949 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6950
6951
6954 &h->requestReverse);
6955
6956 }
6957
6958 template<typename SENDTYPE, typename RECVTYPE>
6959 void AMPI_Iallgatherv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
6960
6963 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6964 (void)adType;
6965 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
6966
6967 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6968 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6969 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6970 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6971 delete [] h->recvbufCountVec;
6972 delete [] h->recvbufDisplsVec;
6973 }
6974
6975 template<typename SENDTYPE, typename RECVTYPE>
6976 void AMPI_Iallgatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
6979 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6980 (void)adType;
6981
6982 h->recvbufAdjoints = nullptr;
6984 adjointInterface->getVectorSize());
6985 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6986 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6987 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6988
6989 if(adType->isOldPrimalsRequired()) {
6990 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6991 }
6992 h->sendbufAdjoints = nullptr;
6993 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6995
6998 &h->requestReverse);
6999
7000 }
7001
7002 template<typename SENDTYPE, typename RECVTYPE>
7003 void AMPI_Iallgatherv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7004
7007 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7008 (void)adType;
7009 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7010
7011 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
7012 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7013 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7014 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7015 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7016 delete [] h->recvbufCountVec;
7017 delete [] h->recvbufDisplsVec;
7018 }
7019
7020 template<typename SENDTYPE, typename RECVTYPE>
7021 int AMPI_Iallgatherv_finish(HandleBase* handle);
7022 template<typename SENDTYPE, typename RECVTYPE>
7023 int AMPI_Iallgatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
7024 typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* displs, RECVTYPE* recvtype, AMPI_Comm comm,
7025 AMPI_Request* request) {
7026 int rStatus;
7027 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7028
7029 if(!adType->isActiveType()) {
7030 // call the regular function if the type is not active
7031 rStatus = MPI_Iallgatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs,
7032 recvtype->getMpiType(), comm, &request->request);
7033 } else {
7034
7035 // the type is an AD type so handle the buffers
7037 MEDI_OPTIONAL_CONST int* displsMod = displs;
7038 int displsTotalSize = 0;
7039 if(nullptr != displs) {
7040 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
7041 if(recvtype->isModifiedBufferRequired()) {
7042 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
7043 }
7044 }
7045 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
7046 int sendbufElements = 0;
7047
7048 // compute the total size of the buffer
7049 if(AMPI_IN_PLACE != sendbuf) {
7050 sendbufElements = sendcount;
7051 } else {
7052 sendbufElements = recvcounts[getCommRank(comm)];
7053 }
7054
7055 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7056 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
7057 } else {
7058 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
7059 }
7060 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
7061 int recvbufElements = 0;
7062
7063 // compute the total size of the buffer
7064 recvbufElements = displsTotalSize;
7065
7066 if(recvtype->isModifiedBufferRequired() ) {
7067 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
7068 } else {
7069 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
7070 }
7071
7072 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
7073 if(adType->isHandleRequired()) {
7075 }
7076 adType->startAssembly(h);
7077 if(sendtype->isModifiedBufferRequired()) {
7078 if(AMPI_IN_PLACE != sendbuf) {
7079 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
7080 } else {
7081 {
7082 const int rank = getCommRank(comm);
7083 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
7084 }
7085 }
7086 }
7087
7088 if(nullptr != h) {
7089 // gather the information for the reverse sweep
7090
7091 // create the index buffers
7092 if(AMPI_IN_PLACE != sendbuf) {
7093 h->sendbufCount = sendtype->computeActiveElements(sendcount);
7094 } else {
7095 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
7096 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
7097 }
7098 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
7099 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
7100 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
7101 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
7102 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
7103
7104
7105 // extract the old primal values from the recv buffer if the AD tool
7106 // needs the primal values reset
7107 if(adType->isOldPrimalsRequired()) {
7108 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
7109 for(int i = 0; i < getCommSize(comm); ++i) {
7110 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
7111 }
7112 }
7113
7114
7115 if(AMPI_IN_PLACE != sendbuf) {
7116 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
7117 } else {
7118 {
7119 const int rank = getCommRank(comm);
7120 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
7121 }
7122 }
7123
7124 for(int i = 0; i < getCommSize(comm); ++i) {
7125 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
7126 }
7127
7128 // pack all the variables in the handle
7132 h->sendcount = sendcount;
7133 h->sendtype = sendtype;
7134 h->recvcounts = recvcounts;
7135 h->displs = displs;
7136 h->recvtype = recvtype;
7137 h->comm = comm;
7138 }
7139
7140 if(!recvtype->isModifiedBufferRequired()) {
7141 for(int i = 0; i < getCommSize(comm); ++i) {
7142 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
7143 }
7144 }
7145
7146 rStatus = MPI_Iallgatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
7147 recvtype->getModifiedMpiType(), comm, &request->request);
7148
7150 asyncHandle->sendbuf = sendbuf;
7151 asyncHandle->sendbufMod = sendbufMod;
7152 asyncHandle->sendcount = sendcount;
7153 asyncHandle->sendtype = sendtype;
7154 asyncHandle->recvbuf = recvbuf;
7155 asyncHandle->recvbufMod = recvbufMod;
7156 asyncHandle->displsMod = displsMod;
7157 asyncHandle->recvcounts = recvcounts;
7158 asyncHandle->displs = displs;
7159 asyncHandle->recvtype = recvtype;
7160 asyncHandle->comm = comm;
7161 asyncHandle->toolHandle = h;
7162 request->handle = asyncHandle;
7164
7165 // create adjoint wait
7166 if(nullptr != h) {
7169 adType->addToolAction(waitH);
7170 }
7171 }
7172
7173 return rStatus;
7174 }
7175
7176 template<typename SENDTYPE, typename RECVTYPE>
7178 int rStatus = 0;
7179
7182 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
7183 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
7184 int sendcount = asyncHandle->sendcount;
7185 SENDTYPE* sendtype = asyncHandle->sendtype;
7186 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
7187 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
7188 const int* displsMod = asyncHandle->displsMod;
7189 const int* recvcounts = asyncHandle->recvcounts;
7190 const int* displs = asyncHandle->displs;
7191 RECVTYPE* recvtype = asyncHandle->recvtype;
7192 AMPI_Comm comm = asyncHandle->comm;
7193 AMPI_Request* request = asyncHandle->request;
7196 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7197 MEDI_UNUSED(h); // Unused generated to ignore warnings
7198 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
7199 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
7200 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
7201 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
7202 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
7203 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
7204 MEDI_UNUSED(displsMod); // Unused generated to ignore warnings
7205 MEDI_UNUSED(recvcounts); // Unused generated to ignore warnings
7206 MEDI_UNUSED(displs); // Unused generated to ignore warnings
7207 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
7208 MEDI_UNUSED(comm); // Unused generated to ignore warnings
7209 MEDI_UNUSED(request); // Unused generated to ignore warnings
7210
7211 delete asyncHandle;
7212
7213 if(adType->isActiveType()) {
7214
7215 adType->addToolAction(h);
7216
7217 if(recvtype->isModifiedBufferRequired()) {
7218 for(int i = 0; i < getCommSize(comm); ++i) {
7219 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
7220 }
7221 }
7222
7223 if(nullptr != h) {
7224 // handle the recv buffers
7225 for(int i = 0; i < getCommSize(comm); ++i) {
7226 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
7227 }
7228 }
7229
7230 adType->stopAssembly(h);
7231 if(recvtype->isModifiedBufferRequired()) {
7232 delete [] displsMod;
7233 }
7234
7235 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7236 sendtype->deleteModifiedTypeBuffer(sendbufMod);
7237 }
7238 if(recvtype->isModifiedBufferRequired() ) {
7239 recvtype->deleteModifiedTypeBuffer(recvbufMod);
7240 }
7241
7242 // handle is deleted by the AD tool
7243 }
7244
7245 return rStatus;
7246 }
7247
7248#endif
7249#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
7250 template<typename DATATYPE>
7253 typename DATATYPE::IndexType* sendbufIndices;
7254 typename DATATYPE::PrimalType* sendbufPrimals;
7255 /* required for async */ void* sendbufAdjoints;
7259 typename DATATYPE::IndexType* recvbufIndices;
7260 typename DATATYPE::PrimalType* recvbufPrimals;
7261 typename DATATYPE::PrimalType* recvbufOldPrimals;
7262 /* required for async */ void* recvbufAdjoints;
7266 DATATYPE* datatype;
7269
7271 if(nullptr != sendbufIndices) {
7272 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
7273 sendbufIndices = nullptr;
7274 }
7275 if(nullptr != sendbufPrimals) {
7276 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
7277 sendbufPrimals = nullptr;
7278 }
7279 if(nullptr != recvbufIndices) {
7280 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
7281 recvbufIndices = nullptr;
7282 }
7283 if(nullptr != recvbufPrimals) {
7284 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
7285 recvbufPrimals = nullptr;
7286 }
7287 if(nullptr != recvbufOldPrimals) {
7288 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
7289 recvbufOldPrimals = nullptr;
7290 }
7291 }
7292 };
7293
7294 template<typename DATATYPE>
7296 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf;
7297 typename DATATYPE::ModifiedType* sendbufMod;
7298 typename DATATYPE::Type* recvbuf;
7299 typename DATATYPE::ModifiedType* recvbufMod;
7301 DATATYPE* datatype;
7305 };
7306
7307 template<typename DATATYPE>
7308 void AMPI_Iallreduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
7310 (handle);
7311 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7312 (void)adType;
7313
7314 AMPI_Op convOp = adType->convertOperator(h->op);
7315 (void)convOp;
7316 h->recvbufAdjoints = nullptr;
7317 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7318 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
7319 h->sendbufAdjoints = nullptr;
7320 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7321 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
7322 // Primal buffers are always linear in space so we can accesses them in one sweep
7323 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
7324
7325
7327 h->count, h->datatype, h->op, h->comm, &h->requestReverse);
7328
7329 }
7330
7331 template<typename DATATYPE>
7333
7335 (handle);
7336 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7337 (void)adType;
7338 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7339
7340 AMPI_Op convOp = adType->convertOperator(h->op);
7341 (void)convOp;
7342 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
7343 if(adType->isOldPrimalsRequired()) {
7344 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7345 }
7346 // Primal buffers are always linear in space so we can accesses them in one sweep
7347 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
7348 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
7349 }
7350
7351 template<typename DATATYPE>
7352 void AMPI_Iallreduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
7354 (handle);
7355 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7356 (void)adType;
7357
7358 AMPI_Op convOp = adType->convertOperator(h->op);
7359 (void)convOp;
7360 h->recvbufAdjoints = nullptr;
7361 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7362 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7363 h->sendbufAdjoints = nullptr;
7364 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7365 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
7366 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7367 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7368
7369
7371 h->count, h->datatype, h->op, h->comm, &h->requestReverse);
7372
7373 }
7374
7375 template<typename DATATYPE>
7377
7379 (handle);
7380 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7381 (void)adType;
7382 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7383
7384 AMPI_Op convOp = adType->convertOperator(h->op);
7385 (void)convOp;
7386 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7387 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7388 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7389 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7390 }
7391
7392 template<typename DATATYPE>
7393 void AMPI_Iallreduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
7395 (handle);
7396 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7397 (void)adType;
7398
7399 AMPI_Op convOp = adType->convertOperator(h->op);
7400 (void)convOp;
7401 h->recvbufAdjoints = nullptr;
7402 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7403 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7404 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7405 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7406
7407 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
7408 if(adType->isOldPrimalsRequired()) {
7409 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7410 }
7411 h->sendbufAdjoints = nullptr;
7412 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7414
7416 h->count, h->datatype, h->op, h->comm, &h->requestReverse);
7417
7418 }
7419
7420 template<typename DATATYPE>
7422
7424 (handle);
7425 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7426 (void)adType;
7427 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7428
7429 AMPI_Op convOp = adType->convertOperator(h->op);
7430 (void)convOp;
7431 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
7432 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
7433 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
7435 adjointInterface->getVectorSize());
7436 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7437 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7438 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7439 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7440 }
7441
7442 template<typename DATATYPE>
7443 int AMPI_Iallreduce_global_finish(HandleBase* handle);
7444 template<typename DATATYPE>
7445 int AMPI_Iallreduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
7446 int count, DATATYPE* datatype, AMPI_Op op, AMPI_Comm comm, AMPI_Request* request) {
7447 int rStatus;
7448 ADToolInterface const* adType = selectADTool(datatype->getADTool());
7449 AMPI_Op convOp = adType->convertOperator(op);
7450 (void)convOp;
7451
7452 if(!adType->isActiveType()) {
7453 // call the regular function if the type is not active
7454 rStatus = MPI_Iallreduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, comm,
7455 &request->request);
7456 } else {
7457
7458 // the type is an AD type so handle the buffers
7460 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
7461 int sendbufElements = 0;
7462
7463 // compute the total size of the buffer
7464 if(AMPI_IN_PLACE != sendbuf) {
7465 sendbufElements = count;
7466 } else {
7467 sendbufElements = count;
7468 }
7469
7470 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7471 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
7472 } else {
7473 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
7474 }
7475 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
7476 int recvbufElements = 0;
7477
7478 // compute the total size of the buffer
7479 recvbufElements = count;
7480
7481 if(datatype->isModifiedBufferRequired() ) {
7482 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
7483 } else {
7484 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
7485 }
7486
7487 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
7488 if(adType->isHandleRequired()) {
7490 }
7491 adType->startAssembly(h);
7492 if(datatype->isModifiedBufferRequired()) {
7493 if(AMPI_IN_PLACE != sendbuf) {
7494 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
7495 } else {
7496 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
7497 }
7498 }
7499
7500 if(nullptr != h) {
7501 // gather the information for the reverse sweep
7502
7503 // create the index buffers
7504 if(AMPI_IN_PLACE != sendbuf) {
7505 h->sendbufCount = datatype->computeActiveElements(count);
7506 } else {
7507 h->sendbufCount = datatype->computeActiveElements(count);
7508 }
7509 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
7510 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
7511 h->recvbufCount = datatype->computeActiveElements(count);
7512 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
7513 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
7514
7515 // extract the primal values for the operator if required
7516 if(convOp.requiresPrimal) {
7517 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
7518 if(AMPI_IN_PLACE != sendbuf) {
7519 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
7520 } else {
7521 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
7522 }
7523 }
7524
7525 // extract the old primal values from the recv buffer if the AD tool
7526 // needs the primal values reset
7527 if(adType->isOldPrimalsRequired()) {
7528 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
7529 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
7530 }
7531
7532
7533 if(AMPI_IN_PLACE != sendbuf) {
7534 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
7535 } else {
7536 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
7537 }
7538
7539 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
7540
7541 // pack all the variables in the handle
7545 h->count = count;
7546 h->datatype = datatype;
7547 h->op = op;
7548 h->comm = comm;
7549 }
7550
7551 if(!datatype->isModifiedBufferRequired()) {
7552 datatype->clearIndices(recvbuf, 0, count);
7553 }
7554
7555 rStatus = MPI_Iallreduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction,
7556 comm, &request->request);
7557
7559 asyncHandle->sendbuf = sendbuf;
7560 asyncHandle->sendbufMod = sendbufMod;
7561 asyncHandle->recvbuf = recvbuf;
7562 asyncHandle->recvbufMod = recvbufMod;
7563 asyncHandle->count = count;
7564 asyncHandle->datatype = datatype;
7565 asyncHandle->op = op;
7566 asyncHandle->comm = comm;
7567 asyncHandle->toolHandle = h;
7568 request->handle = asyncHandle;
7570
7571 // create adjoint wait
7572 if(nullptr != h) {
7575 adType->addToolAction(waitH);
7576 }
7577 }
7578
7579 return rStatus;
7580 }
7581
7582 template<typename DATATYPE>
7584 int rStatus = 0;
7585
7587 (handle);
7588 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf = asyncHandle->sendbuf;
7589 typename DATATYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
7590 typename DATATYPE::Type* recvbuf = asyncHandle->recvbuf;
7591 typename DATATYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
7592 int count = asyncHandle->count;
7593 DATATYPE* datatype = asyncHandle->datatype;
7594 AMPI_Op op = asyncHandle->op;
7595 AMPI_Comm comm = asyncHandle->comm;
7596 AMPI_Request* request = asyncHandle->request;
7598 (asyncHandle->toolHandle);
7599 ADToolInterface const* adType = selectADTool(datatype->getADTool());
7600 MEDI_UNUSED(h); // Unused generated to ignore warnings
7601 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
7602 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
7603 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
7604 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
7605 MEDI_UNUSED(count); // Unused generated to ignore warnings
7606 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
7607 MEDI_UNUSED(op); // Unused generated to ignore warnings
7608 MEDI_UNUSED(comm); // Unused generated to ignore warnings
7609 MEDI_UNUSED(request); // Unused generated to ignore warnings
7610
7611 delete asyncHandle;
7612
7613 if(adType->isActiveType()) {
7614
7615 AMPI_Op convOp = adType->convertOperator(op);
7616 (void)convOp;
7617 adType->addToolAction(h);
7618
7619 if(datatype->isModifiedBufferRequired()) {
7620 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
7621 }
7622
7623 if(nullptr != h) {
7624 // handle the recv buffers
7625 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
7626 }
7627 // extract the primal values for the operator if required
7628 if(nullptr != h && convOp.requiresPrimal) {
7629 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
7630 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
7631 }
7632
7633 adType->stopAssembly(h);
7634
7635 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7636 datatype->deleteModifiedTypeBuffer(sendbufMod);
7637 }
7638 if(datatype->isModifiedBufferRequired() ) {
7639 datatype->deleteModifiedTypeBuffer(recvbufMod);
7640 }
7641
7642 // handle is deleted by the AD tool
7643 }
7644
7645 return rStatus;
7646 }
7647
7648#endif
7649#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
7650 template<typename SENDTYPE, typename RECVTYPE>
7653 typename SENDTYPE::IndexType* sendbufIndices;
7654 typename SENDTYPE::PrimalType* sendbufPrimals;
7655 /* required for async */ void* sendbufAdjoints;
7659 SENDTYPE* sendtype;
7661 typename RECVTYPE::IndexType* recvbufIndices;
7662 typename RECVTYPE::PrimalType* recvbufPrimals;
7663 typename RECVTYPE::PrimalType* recvbufOldPrimals;
7664 /* required for async */ void* recvbufAdjoints;
7668 RECVTYPE* recvtype;
7670
7672 if(nullptr != sendbufIndices) {
7673 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
7674 sendbufIndices = nullptr;
7675 }
7676 if(nullptr != sendbufPrimals) {
7677 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
7678 sendbufPrimals = nullptr;
7679 }
7680 if(nullptr != recvbufIndices) {
7681 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
7682 recvbufIndices = nullptr;
7683 }
7684 if(nullptr != recvbufPrimals) {
7685 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
7686 recvbufPrimals = nullptr;
7687 }
7688 if(nullptr != recvbufOldPrimals) {
7689 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
7690 recvbufOldPrimals = nullptr;
7691 }
7692 }
7693 };
7694
7695 template<typename SENDTYPE, typename RECVTYPE>
7697 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
7698 typename SENDTYPE::ModifiedType* sendbufMod;
7700 SENDTYPE* sendtype;
7701 typename RECVTYPE::Type* recvbuf;
7702 typename RECVTYPE::ModifiedType* recvbufMod;
7704 RECVTYPE* recvtype;
7707 };
7708
7709 template<typename SENDTYPE, typename RECVTYPE>
7710 void AMPI_Ialltoall_p(HandleBase* handle, AdjointInterface* adjointInterface) {
7712 (handle);
7713 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7714 (void)adType;
7715
7716 h->recvbufAdjoints = nullptr;
7717 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7718 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
7719 h->sendbufAdjoints = nullptr;
7720 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7721 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
7722 // Primal buffers are always linear in space so we can accesses them in one sweep
7723 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
7724
7725
7728
7729 }
7730
7731 template<typename SENDTYPE, typename RECVTYPE>
7732 void AMPI_Ialltoall_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7733
7735 (handle);
7736 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7737 (void)adType;
7738 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7739
7740 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
7741 if(adType->isOldPrimalsRequired()) {
7742 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7743 }
7744 // Primal buffers are always linear in space so we can accesses them in one sweep
7745 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
7746 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
7747 }
7748
7749 template<typename SENDTYPE, typename RECVTYPE>
7750 void AMPI_Ialltoall_d(HandleBase* handle, AdjointInterface* adjointInterface) {
7752 (handle);
7753 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7754 (void)adType;
7755
7756 h->recvbufAdjoints = nullptr;
7757 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7758 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7759 h->sendbufAdjoints = nullptr;
7760 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7761 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
7762 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7763 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7764
7765
7768
7769 }
7770
7771 template<typename SENDTYPE, typename RECVTYPE>
7772 void AMPI_Ialltoall_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7773
7775 (handle);
7776 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7777 (void)adType;
7778 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7779
7780 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7781 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7782 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7783 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7784 }
7785
7786 template<typename SENDTYPE, typename RECVTYPE>
7787 void AMPI_Ialltoall_b(HandleBase* handle, AdjointInterface* adjointInterface) {
7789 (handle);
7790 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7791 (void)adType;
7792
7793 h->recvbufAdjoints = nullptr;
7794 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7795 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7796 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7797 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7798
7799 if(adType->isOldPrimalsRequired()) {
7800 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7801 }
7802 h->sendbufAdjoints = nullptr;
7803 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7804 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
7805
7808
7809 }
7810
7811 template<typename SENDTYPE, typename RECVTYPE>
7812 void AMPI_Ialltoall_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7813
7815 (handle);
7816 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7817 (void)adType;
7818 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7819
7820 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7821 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7822 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7823 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7824 }
7825
7826 template<typename SENDTYPE, typename RECVTYPE>
7827 int AMPI_Ialltoall_finish(HandleBase* handle);
7828 template<typename SENDTYPE, typename RECVTYPE>
7829 int AMPI_Ialltoall(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
7830 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm, AMPI_Request* request) {
7831 int rStatus;
7832 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7833
7834 if(!adType->isActiveType()) {
7835 // call the regular function if the type is not active
7836 rStatus = MPI_Ialltoall(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm,
7837 &request->request);
7838 } else {
7839
7840 // the type is an AD type so handle the buffers
7842 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
7843 int sendbufElements = 0;
7844
7845 // compute the total size of the buffer
7846 if(AMPI_IN_PLACE != sendbuf) {
7847 sendbufElements = sendcount * getCommSize(comm);
7848 } else {
7849 sendbufElements = recvcount * getCommSize(comm);
7850 }
7851
7852 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7853 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
7854 } else {
7855 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
7856 }
7857 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
7858 int recvbufElements = 0;
7859
7860 // compute the total size of the buffer
7861 recvbufElements = recvcount * getCommSize(comm);
7862
7863 if(recvtype->isModifiedBufferRequired() ) {
7864 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
7865 } else {
7866 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
7867 }
7868
7869 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
7870 if(adType->isHandleRequired()) {
7872 }
7873 adType->startAssembly(h);
7874 if(sendtype->isModifiedBufferRequired()) {
7875 if(AMPI_IN_PLACE != sendbuf) {
7876 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
7877 } else {
7878 recvtype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
7879 }
7880 }
7881
7882 if(nullptr != h) {
7883 // gather the information for the reverse sweep
7884
7885 // create the index buffers
7886 if(AMPI_IN_PLACE != sendbuf) {
7887 h->sendbufCount = sendtype->computeActiveElements(sendcount);
7888 } else {
7889 h->sendbufCount = recvtype->computeActiveElements(recvcount);
7890 }
7891 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
7892 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
7893 h->recvbufCount = recvtype->computeActiveElements(recvcount);
7894 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
7895 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
7896
7897
7898 // extract the old primal values from the recv buffer if the AD tool
7899 // needs the primal values reset
7900 if(adType->isOldPrimalsRequired()) {
7901 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
7902 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
7903 }
7904
7905
7906 if(AMPI_IN_PLACE != sendbuf) {
7907 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
7908 } else {
7909 recvtype->getIndices(recvbuf, 0, h->sendbufIndices, 0, recvcount * getCommSize(comm));
7910 }
7911
7912 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
7913
7914 // pack all the variables in the handle
7918 h->sendcount = sendcount;
7919 h->sendtype = sendtype;
7920 h->recvcount = recvcount;
7921 h->recvtype = recvtype;
7922 h->comm = comm;
7923 }
7924
7925 if(!recvtype->isModifiedBufferRequired()) {
7926 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
7927 }
7928
7929 rStatus = MPI_Ialltoall(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
7930 recvtype->getModifiedMpiType(), comm, &request->request);
7931
7933 asyncHandle->sendbuf = sendbuf;
7934 asyncHandle->sendbufMod = sendbufMod;
7935 asyncHandle->sendcount = sendcount;
7936 asyncHandle->sendtype = sendtype;
7937 asyncHandle->recvbuf = recvbuf;
7938 asyncHandle->recvbufMod = recvbufMod;
7939 asyncHandle->recvcount = recvcount;
7940 asyncHandle->recvtype = recvtype;
7941 asyncHandle->comm = comm;
7942 asyncHandle->toolHandle = h;
7943 request->handle = asyncHandle;
7945
7946 // create adjoint wait
7947 if(nullptr != h) {
7950 adType->addToolAction(waitH);
7951 }
7952 }
7953
7954 return rStatus;
7955 }
7956
7957 template<typename SENDTYPE, typename RECVTYPE>
7959 int rStatus = 0;
7960
7963 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
7964 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
7965 int sendcount = asyncHandle->sendcount;
7966 SENDTYPE* sendtype = asyncHandle->sendtype;
7967 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
7968 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
7969 int recvcount = asyncHandle->recvcount;
7970 RECVTYPE* recvtype = asyncHandle->recvtype;
7971 AMPI_Comm comm = asyncHandle->comm;
7972 AMPI_Request* request = asyncHandle->request;
7974 (asyncHandle->toolHandle);
7975 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7976 MEDI_UNUSED(h); // Unused generated to ignore warnings
7977 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
7978 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
7979 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
7980 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
7981 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
7982 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
7983 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
7984 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
7985 MEDI_UNUSED(comm); // Unused generated to ignore warnings
7986 MEDI_UNUSED(request); // Unused generated to ignore warnings
7987
7988 delete asyncHandle;
7989
7990 if(adType->isActiveType()) {
7991
7992 adType->addToolAction(h);
7993
7994 if(recvtype->isModifiedBufferRequired()) {
7995 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
7996 }
7997
7998 if(nullptr != h) {
7999 // handle the recv buffers
8000 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
8001 }
8002
8003 adType->stopAssembly(h);
8004
8005 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8006 sendtype->deleteModifiedTypeBuffer(sendbufMod);
8007 }
8008 if(recvtype->isModifiedBufferRequired() ) {
8009 recvtype->deleteModifiedTypeBuffer(recvbufMod);
8010 }
8011
8012 // handle is deleted by the AD tool
8013 }
8014
8015 return rStatus;
8016 }
8017
8018#endif
8019#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
8020 template<typename SENDTYPE, typename RECVTYPE>
8023 typename SENDTYPE::IndexType* sendbufIndices;
8024 typename SENDTYPE::PrimalType* sendbufPrimals;
8025 /* required for async */ void* sendbufAdjoints;
8027 /* required for async */ int* sendbufCountVec;
8028 /* required for async */ int* sendbufDisplsVec;
8029 const int* sendcounts;
8030 const int* sdispls;
8031 SENDTYPE* sendtype;
8033 typename RECVTYPE::IndexType* recvbufIndices;
8034 typename RECVTYPE::PrimalType* recvbufPrimals;
8035 typename RECVTYPE::PrimalType* recvbufOldPrimals;
8036 /* required for async */ void* recvbufAdjoints;
8038 /* required for async */ int* recvbufCountVec;
8039 /* required for async */ int* recvbufDisplsVec;
8040 const int* recvcounts;
8041 const int* rdispls;
8042 RECVTYPE* recvtype;
8044
8046 if(nullptr != sendbufIndices) {
8047 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
8048 sendbufIndices = nullptr;
8049 }
8050 if(nullptr != sendbufPrimals) {
8051 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
8052 sendbufPrimals = nullptr;
8053 }
8054 if(nullptr != sendbufCount) {
8055 delete [] sendbufCount;
8056 sendbufCount = nullptr;
8057 }
8058 if(nullptr != recvbufIndices) {
8059 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
8060 recvbufIndices = nullptr;
8061 }
8062 if(nullptr != recvbufPrimals) {
8063 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
8064 recvbufPrimals = nullptr;
8065 }
8066 if(nullptr != recvbufOldPrimals) {
8067 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
8068 recvbufOldPrimals = nullptr;
8069 }
8070 if(nullptr != recvbufCount) {
8071 delete [] recvbufCount;
8072 recvbufCount = nullptr;
8073 }
8074 }
8075 };
8076
8077 template<typename SENDTYPE, typename RECVTYPE>
8079 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
8080 typename SENDTYPE::ModifiedType* sendbufMod;
8081 const int* sdisplsMod;
8082 const int* sendcounts;
8083 const int* sdispls;
8084 SENDTYPE* sendtype;
8085 typename RECVTYPE::Type* recvbuf;
8086 typename RECVTYPE::ModifiedType* recvbufMod;
8087 const int* rdisplsMod;
8088 const int* recvcounts;
8089 const int* rdispls;
8090 RECVTYPE* recvtype;
8093 };
8094
8095 template<typename SENDTYPE, typename RECVTYPE>
8096 void AMPI_Ialltoallv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
8098 (handle);
8099 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8100 (void)adType;
8101
8102 h->recvbufAdjoints = nullptr;
8104 adjointInterface->getVectorSize());
8105 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
8106 h->sendbufAdjoints = nullptr;
8108 adjointInterface->getVectorSize());
8109 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
8110 // Primal buffers are always linear in space so we can accesses them in one sweep
8111 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
8112
8113
8116 h->recvtype, h->comm, &h->requestReverse);
8117
8118 }
8119
8120 template<typename SENDTYPE, typename RECVTYPE>
8121 void AMPI_Ialltoallv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8122
8124 (handle);
8125 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8126 (void)adType;
8127 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8128
8129 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
8130 delete [] h->sendbufCountVec;
8131 delete [] h->sendbufDisplsVec;
8132 if(adType->isOldPrimalsRequired()) {
8133 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
8134 }
8135 // Primal buffers are always linear in space so we can accesses them in one sweep
8136 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
8137 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
8138 delete [] h->recvbufCountVec;
8139 delete [] h->recvbufDisplsVec;
8140 }
8141
8142 template<typename SENDTYPE, typename RECVTYPE>
8143 void AMPI_Ialltoallv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
8145 (handle);
8146 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8147 (void)adType;
8148
8149 h->recvbufAdjoints = nullptr;
8151 adjointInterface->getVectorSize());
8152 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
8153 h->sendbufAdjoints = nullptr;
8155 adjointInterface->getVectorSize());
8156 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
8157 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8158 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8159
8160
8163 h->recvtype, h->comm, &h->requestReverse);
8164
8165 }
8166
8167 template<typename SENDTYPE, typename RECVTYPE>
8168 void AMPI_Ialltoallv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8169
8171 (handle);
8172 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8173 (void)adType;
8174 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8175
8176 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
8177 delete [] h->sendbufCountVec;
8178 delete [] h->sendbufDisplsVec;
8179 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8180 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
8181 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
8182 delete [] h->recvbufCountVec;
8183 delete [] h->recvbufDisplsVec;
8184 }
8185
8186 template<typename SENDTYPE, typename RECVTYPE>
8187 void AMPI_Ialltoallv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
8189 (handle);
8190 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8191 (void)adType;
8192
8193 h->recvbufAdjoints = nullptr;
8195 adjointInterface->getVectorSize());
8196 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
8197 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8198 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
8199
8200 if(adType->isOldPrimalsRequired()) {
8201 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
8202 }
8203 h->sendbufAdjoints = nullptr;
8205 adjointInterface->getVectorSize());
8206 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
8207
8210 h->recvtype, h->comm, &h->requestReverse);
8211
8212 }
8213
8214 template<typename SENDTYPE, typename RECVTYPE>
8215 void AMPI_Ialltoallv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8216
8218 (handle);
8219 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8220 (void)adType;
8221 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8222
8223 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8224 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8225 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
8226 delete [] h->sendbufCountVec;
8227 delete [] h->sendbufDisplsVec;
8228 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
8229 delete [] h->recvbufCountVec;
8230 delete [] h->recvbufDisplsVec;
8231 }
8232
8233 template<typename SENDTYPE, typename RECVTYPE>
8234 int AMPI_Ialltoallv_finish(HandleBase* handle);
8235 template<typename SENDTYPE, typename RECVTYPE>
8236 int AMPI_Ialltoallv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, const int* sendcounts, const int* sdispls,
8237 SENDTYPE* sendtype, typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* rdispls, RECVTYPE* recvtype,
8238 AMPI_Comm comm, AMPI_Request* request) {
8239 int rStatus;
8240 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
8241
8242 if(!adType->isActiveType()) {
8243 // call the regular function if the type is not active
8244 rStatus = MPI_Ialltoallv(sendbuf, sendcounts, sdispls, sendtype->getMpiType(), recvbuf, recvcounts, rdispls,
8245 recvtype->getMpiType(), comm, &request->request);
8246 } else {
8247
8248 // the type is an AD type so handle the buffers
8250 MEDI_OPTIONAL_CONST int* sdisplsMod = sdispls;
8251 int sdisplsTotalSize = 0;
8252 if(nullptr != sdispls) {
8253 sdisplsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
8254 if(recvtype->isModifiedBufferRequired()) {
8255 sdisplsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
8256 }
8257 }
8258 MEDI_OPTIONAL_CONST int* rdisplsMod = rdispls;
8259 int rdisplsTotalSize = 0;
8260 if(nullptr != rdispls) {
8261 rdisplsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
8262 if(recvtype->isModifiedBufferRequired()) {
8263 rdisplsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
8264 }
8265 }
8266 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
8267 int sendbufElements = 0;
8268
8269 // compute the total size of the buffer
8270 if(AMPI_IN_PLACE != sendbuf) {
8271 sendbufElements = sdisplsTotalSize;
8272 } else {
8273 sendbufElements = rdisplsTotalSize;
8274 }
8275
8276 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8277 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
8278 } else {
8279 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
8280 }
8281 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
8282 int recvbufElements = 0;
8283
8284 // compute the total size of the buffer
8285 recvbufElements = rdisplsTotalSize;
8286
8287 if(recvtype->isModifiedBufferRequired() ) {
8288 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
8289 } else {
8290 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
8291 }
8292
8293 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
8294 if(adType->isHandleRequired()) {
8296 }
8297 adType->startAssembly(h);
8298 if(sendtype->isModifiedBufferRequired()) {
8299 if(AMPI_IN_PLACE != sendbuf) {
8300 for(int i = 0; i < getCommSize(comm); ++i) {
8301 sendtype->copyIntoModifiedBuffer(sendbuf, sdispls[i], sendbufMod, sdisplsMod[i], sendcounts[i]);
8302 }
8303 } else {
8304 for(int i = 0; i < getCommSize(comm); ++i) {
8305 recvtype->copyIntoModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
8306 }
8307 }
8308 }
8309
8310 if(nullptr != h) {
8311 // gather the information for the reverse sweep
8312
8313 // create the index buffers
8314 if(AMPI_IN_PLACE != sendbuf) {
8315 createLinearIndexCounts(h->sendbufCount, sendcounts, sdispls, getCommSize(comm), sendtype);
8316 } else {
8317 createLinearIndexCounts(h->sendbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
8318 }
8319 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
8320 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
8321 createLinearIndexCounts(h->recvbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
8322 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
8323 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
8324
8325
8326 // extract the old primal values from the recv buffer if the AD tool
8327 // needs the primal values reset
8328 if(adType->isOldPrimalsRequired()) {
8329 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
8330 for(int i = 0; i < getCommSize(comm); ++i) {
8331 recvtype->getValues(recvbuf, rdispls[i], h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
8332 }
8333 }
8334
8335
8336 if(AMPI_IN_PLACE != sendbuf) {
8337 for(int i = 0; i < getCommSize(comm); ++i) {
8338 sendtype->getIndices(sendbuf, sdispls[i], h->sendbufIndices, sdisplsMod[i], sendcounts[i]);
8339 }
8340 } else {
8341 for(int i = 0; i < getCommSize(comm); ++i) {
8342 recvtype->getIndices(recvbuf, rdispls[i], h->sendbufIndices, rdisplsMod[i], recvcounts[i]);
8343 }
8344 }
8345
8346 for(int i = 0; i < getCommSize(comm); ++i) {
8347 recvtype->createIndices(recvbuf, rdispls[i], h->recvbufIndices, rdisplsMod[i], recvcounts[i]);
8348 }
8349
8350 // pack all the variables in the handle
8354 h->sendcounts = sendcounts;
8355 h->sdispls = sdispls;
8356 h->sendtype = sendtype;
8357 h->recvcounts = recvcounts;
8358 h->rdispls = rdispls;
8359 h->recvtype = recvtype;
8360 h->comm = comm;
8361 }
8362
8363 if(!recvtype->isModifiedBufferRequired()) {
8364 for(int i = 0; i < getCommSize(comm); ++i) {
8365 recvtype->clearIndices(recvbuf, rdispls[i], recvcounts[i]);
8366 }
8367 }
8368
8369 rStatus = MPI_Ialltoallv(sendbufMod, sendcounts, sdisplsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcounts,
8370 rdisplsMod, recvtype->getModifiedMpiType(), comm, &request->request);
8371
8373 asyncHandle->sendbuf = sendbuf;
8374 asyncHandle->sendbufMod = sendbufMod;
8375 asyncHandle->sdisplsMod = sdisplsMod;
8376 asyncHandle->sendcounts = sendcounts;
8377 asyncHandle->sdispls = sdispls;
8378 asyncHandle->sendtype = sendtype;
8379 asyncHandle->recvbuf = recvbuf;
8380 asyncHandle->recvbufMod = recvbufMod;
8381 asyncHandle->rdisplsMod = rdisplsMod;
8382 asyncHandle->recvcounts = recvcounts;
8383 asyncHandle->rdispls = rdispls;
8384 asyncHandle->recvtype = recvtype;
8385 asyncHandle->comm = comm;
8386 asyncHandle->toolHandle = h;
8387 request->handle = asyncHandle;
8389
8390 // create adjoint wait
8391 if(nullptr != h) {
8394 adType->addToolAction(waitH);
8395 }
8396 }
8397
8398 return rStatus;
8399 }
8400
8401 template<typename SENDTYPE, typename RECVTYPE>
8403 int rStatus = 0;
8404
8407 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
8408 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
8409 const int* sdisplsMod = asyncHandle->sdisplsMod;
8410 const int* sendcounts = asyncHandle->sendcounts;
8411 const int* sdispls = asyncHandle->sdispls;
8412 SENDTYPE* sendtype = asyncHandle->sendtype;
8413 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
8414 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
8415 const int* rdisplsMod = asyncHandle->rdisplsMod;
8416 const int* recvcounts = asyncHandle->recvcounts;
8417 const int* rdispls = asyncHandle->rdispls;
8418 RECVTYPE* recvtype = asyncHandle->recvtype;
8419 AMPI_Comm comm = asyncHandle->comm;
8420 AMPI_Request* request = asyncHandle->request;
8422 (asyncHandle->toolHandle);
8423 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
8424 MEDI_UNUSED(h); // Unused generated to ignore warnings
8425 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
8426 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
8427 MEDI_UNUSED(sdisplsMod); // Unused generated to ignore warnings
8428 MEDI_UNUSED(sendcounts); // Unused generated to ignore warnings
8429 MEDI_UNUSED(sdispls); // Unused generated to ignore warnings
8430 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
8431 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
8432 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
8433 MEDI_UNUSED(rdisplsMod); // Unused generated to ignore warnings
8434 MEDI_UNUSED(recvcounts); // Unused generated to ignore warnings
8435 MEDI_UNUSED(rdispls); // Unused generated to ignore warnings
8436 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
8437 MEDI_UNUSED(comm); // Unused generated to ignore warnings
8438 MEDI_UNUSED(request); // Unused generated to ignore warnings
8439
8440 delete asyncHandle;
8441
8442 if(adType->isActiveType()) {
8443
8444 adType->addToolAction(h);
8445
8446 if(recvtype->isModifiedBufferRequired()) {
8447 for(int i = 0; i < getCommSize(comm); ++i) {
8448 recvtype->copyFromModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
8449 }
8450 }
8451
8452 if(nullptr != h) {
8453 // handle the recv buffers
8454 for(int i = 0; i < getCommSize(comm); ++i) {
8455 recvtype->registerValue(recvbuf, rdispls[i], h->recvbufIndices, h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
8456 }
8457 }
8458
8459 adType->stopAssembly(h);
8460 if(recvtype->isModifiedBufferRequired()) {
8461 delete [] sdisplsMod;
8462 }
8463 if(recvtype->isModifiedBufferRequired()) {
8464 delete [] rdisplsMod;
8465 }
8466
8467 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8468 sendtype->deleteModifiedTypeBuffer(sendbufMod);
8469 }
8470 if(recvtype->isModifiedBufferRequired() ) {
8471 recvtype->deleteModifiedTypeBuffer(recvbufMod);
8472 }
8473
8474 // handle is deleted by the AD tool
8475 }
8476
8477 return rStatus;
8478 }
8479
8480#endif
8481#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
8482 template<typename DATATYPE>
8485 typename DATATYPE::IndexType* bufferSendIndices;
8486 typename DATATYPE::PrimalType* bufferSendPrimals;
8487 /* required for async */ void* bufferSendAdjoints;
8491 typename DATATYPE::IndexType* bufferRecvIndices;
8492 typename DATATYPE::PrimalType* bufferRecvPrimals;
8493 typename DATATYPE::PrimalType* bufferRecvOldPrimals;
8494 /* required for async */ void* bufferRecvAdjoints;
8498 DATATYPE* datatype;
8499 int root;
8501
8503 if(nullptr != bufferSendIndices) {
8504 datatype->getADTool().deleteIndexTypeBuffer(bufferSendIndices);
8505 bufferSendIndices = nullptr;
8506 }
8507 if(nullptr != bufferSendPrimals) {
8508 datatype->getADTool().deletePrimalTypeBuffer(bufferSendPrimals);
8509 bufferSendPrimals = nullptr;
8510 }
8511 if(nullptr != bufferRecvIndices) {
8512 datatype->getADTool().deleteIndexTypeBuffer(bufferRecvIndices);
8513 bufferRecvIndices = nullptr;
8514 }
8515 if(nullptr != bufferRecvPrimals) {
8516 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvPrimals);
8517 bufferRecvPrimals = nullptr;
8518 }
8519 if(nullptr != bufferRecvOldPrimals) {
8520 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvOldPrimals);
8521 bufferRecvOldPrimals = nullptr;
8522 }
8523 }
8524 };
8525
8526 template<typename DATATYPE>
8528 typename DATATYPE::Type* bufferSend;
8529 typename DATATYPE::ModifiedType* bufferSendMod;
8530 typename DATATYPE::Type* bufferRecv;
8531 typename DATATYPE::ModifiedType* bufferRecvMod;
8533 DATATYPE* datatype;
8534 int root;
8537 };
8538
8539 template<typename DATATYPE>
8540 void AMPI_Ibcast_wrap_p(HandleBase* handle, AdjointInterface* adjointInterface) {
8542 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8543 (void)adType;
8544
8545 h->bufferRecvAdjoints = nullptr;
8546 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
8547 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferRecvPrimals, h->bufferRecvTotalSize );
8548 h->bufferSendAdjoints = nullptr;
8549 if(h->root == getCommRank(h->comm)) {
8550 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
8551 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferSendPrimals, h->bufferSendTotalSize );
8552 // Primal buffers are always linear in space so we can accesses them in one sweep
8554
8555 }
8556
8558 h->count, h->datatype, h->root, h->comm, &h->requestReverse);
8559
8560 }
8561
8562 template<typename DATATYPE>
8563 void AMPI_Ibcast_wrap_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8564
8566 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8567 (void)adType;
8568 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8569
8570 if(h->root == getCommRank(h->comm)) {
8571 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferSendPrimals);
8572 }
8573 if(adType->isOldPrimalsRequired()) {
8575 }
8576 // Primal buffers are always linear in space so we can accesses them in one sweep
8578 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferRecvPrimals);
8579 }
8580
8581 template<typename DATATYPE>
8582 void AMPI_Ibcast_wrap_d(HandleBase* handle, AdjointInterface* adjointInterface) {
8584 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8585 (void)adType;
8586
8587 h->bufferRecvAdjoints = nullptr;
8588 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
8590 h->bufferSendAdjoints = nullptr;
8591 if(h->root == getCommRank(h->comm)) {
8592 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
8594 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8596
8597 }
8598
8600 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm, &h->requestReverse);
8601
8602 }
8603
8604 template<typename DATATYPE>
8605 void AMPI_Ibcast_wrap_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8606
8608 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8609 (void)adType;
8610 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8611
8612 if(h->root == getCommRank(h->comm)) {
8613 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
8614 }
8615 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8617 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
8618 }
8619
8620 template<typename DATATYPE>
8621 void AMPI_Ibcast_wrap_b(HandleBase* handle, AdjointInterface* adjointInterface) {
8623 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8624 (void)adType;
8625
8626 h->bufferRecvAdjoints = nullptr;
8627 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
8629 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8631
8632 if(adType->isOldPrimalsRequired()) {
8634 }
8635 h->bufferSendAdjoints = nullptr;
8636 if(h->root == getCommRank(h->comm)) {
8637 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
8639 }
8640
8642 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm, &h->requestReverse);
8643
8644 }
8645
8646 template<typename DATATYPE>
8647 void AMPI_Ibcast_wrap_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8648
8650 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8651 (void)adType;
8652 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8653
8654 if(h->root == getCommRank(h->comm)) {
8656 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8658 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
8659 }
8660 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
8661 }
8662
8663 template<typename DATATYPE>
8664 int AMPI_Ibcast_wrap_finish(HandleBase* handle);
8665 template<typename DATATYPE>
8666 int AMPI_Ibcast_wrap(typename DATATYPE::Type* bufferSend, typename DATATYPE::Type* bufferRecv, int count,
8667 DATATYPE* datatype, int root, AMPI_Comm comm, AMPI_Request* request) {
8668 int rStatus;
8669 ADToolInterface const* adType = selectADTool(datatype->getADTool());
8670
8671 if(!adType->isActiveType()) {
8672 // call the regular function if the type is not active
8673 rStatus = MPI_Ibcast_wrap(bufferSend, bufferRecv, count, datatype->getMpiType(), root, comm, &request->request);
8674 } else {
8675
8676 // the type is an AD type so handle the buffers
8678 typename DATATYPE::ModifiedType* bufferSendMod = nullptr;
8679 int bufferSendElements = 0;
8680
8681 if(root == getCommRank(comm)) {
8682 // compute the total size of the buffer
8683 if(AMPI_IN_PLACE != bufferSend) {
8684 bufferSendElements = count;
8685 } else {
8686 bufferSendElements = count;
8687 }
8688
8689 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
8690 datatype->createModifiedTypeBuffer(bufferSendMod, bufferSendElements);
8691 } else {
8692 bufferSendMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferSend));
8693 }
8694 }
8695 typename DATATYPE::ModifiedType* bufferRecvMod = nullptr;
8696 int bufferRecvElements = 0;
8697
8698 // compute the total size of the buffer
8699 bufferRecvElements = count;
8700
8701 if(datatype->isModifiedBufferRequired() ) {
8702 datatype->createModifiedTypeBuffer(bufferRecvMod, bufferRecvElements);
8703 } else {
8704 bufferRecvMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferRecv));
8705 }
8706
8707 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
8708 if(adType->isHandleRequired()) {
8710 }
8711 adType->startAssembly(h);
8712 if(root == getCommRank(comm)) {
8713 if(datatype->isModifiedBufferRequired()) {
8714 if(AMPI_IN_PLACE != bufferSend) {
8715 datatype->copyIntoModifiedBuffer(bufferSend, 0, bufferSendMod, 0, count);
8716 } else {
8717 datatype->copyIntoModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
8718 }
8719 }
8720 }
8721
8722 if(nullptr != h) {
8723 // gather the information for the reverse sweep
8724
8725 // create the index buffers
8726 if(root == getCommRank(comm)) {
8727 if(AMPI_IN_PLACE != bufferSend) {
8728 h->bufferSendCount = datatype->computeActiveElements(count);
8729 } else {
8730 h->bufferSendCount = datatype->computeActiveElements(count);
8731 }
8732 h->bufferSendTotalSize = datatype->computeActiveElements(bufferSendElements);
8733 datatype->getADTool().createIndexTypeBuffer(h->bufferSendIndices, h->bufferSendTotalSize);
8734 }
8735 h->bufferRecvCount = datatype->computeActiveElements(count);
8736 h->bufferRecvTotalSize = datatype->computeActiveElements(bufferRecvElements);
8737 datatype->getADTool().createIndexTypeBuffer(h->bufferRecvIndices, h->bufferRecvTotalSize);
8738
8739
8740 // extract the old primal values from the recv buffer if the AD tool
8741 // needs the primal values reset
8742 if(adType->isOldPrimalsRequired()) {
8743 datatype->getADTool().createPrimalTypeBuffer(h->bufferRecvOldPrimals, h->bufferRecvTotalSize);
8744 datatype->getValues(bufferRecv, 0, h->bufferRecvOldPrimals, 0, count);
8745 }
8746
8747
8748 if(root == getCommRank(comm)) {
8749 if(AMPI_IN_PLACE != bufferSend) {
8750 datatype->getIndices(bufferSend, 0, h->bufferSendIndices, 0, count);
8751 } else {
8752 datatype->getIndices(bufferRecv, 0, h->bufferSendIndices, 0, count);
8753 }
8754 }
8755
8756 datatype->createIndices(bufferRecv, 0, h->bufferRecvIndices, 0, count);
8757
8758 // pack all the variables in the handle
8762 h->count = count;
8763 h->datatype = datatype;
8764 h->root = root;
8765 h->comm = comm;
8766 }
8767
8768 if(!datatype->isModifiedBufferRequired()) {
8769 datatype->clearIndices(bufferRecv, 0, count);
8770 }
8771
8772 rStatus = MPI_Ibcast_wrap(bufferSendMod, bufferRecvMod, count, datatype->getModifiedMpiType(), root, comm,
8773 &request->request);
8774
8776 asyncHandle->bufferSend = bufferSend;
8777 asyncHandle->bufferSendMod = bufferSendMod;
8778 asyncHandle->bufferRecv = bufferRecv;
8779 asyncHandle->bufferRecvMod = bufferRecvMod;
8780 asyncHandle->count = count;
8781 asyncHandle->datatype = datatype;
8782 asyncHandle->root = root;
8783 asyncHandle->comm = comm;
8784 asyncHandle->toolHandle = h;
8785 request->handle = asyncHandle;
8787
8788 // create adjoint wait
8789 if(nullptr != h) {
8792 adType->addToolAction(waitH);
8793 }
8794 }
8795
8796 return rStatus;
8797 }
8798
8799 template<typename DATATYPE>
8801 int rStatus = 0;
8802
8804 typename DATATYPE::Type* bufferSend = asyncHandle->bufferSend;
8805 typename DATATYPE::ModifiedType* bufferSendMod = asyncHandle->bufferSendMod;
8806 typename DATATYPE::Type* bufferRecv = asyncHandle->bufferRecv;
8807 typename DATATYPE::ModifiedType* bufferRecvMod = asyncHandle->bufferRecvMod;
8808 int count = asyncHandle->count;
8809 DATATYPE* datatype = asyncHandle->datatype;
8810 int root = asyncHandle->root;
8811 AMPI_Comm comm = asyncHandle->comm;
8812 AMPI_Request* request = asyncHandle->request;
8814 (asyncHandle->toolHandle);
8815 ADToolInterface const* adType = selectADTool(datatype->getADTool());
8816 MEDI_UNUSED(h); // Unused generated to ignore warnings
8817 MEDI_UNUSED(bufferSend); // Unused generated to ignore warnings
8818 MEDI_UNUSED(bufferSendMod); // Unused generated to ignore warnings
8819 MEDI_UNUSED(bufferRecv); // Unused generated to ignore warnings
8820 MEDI_UNUSED(bufferRecvMod); // Unused generated to ignore warnings
8821 MEDI_UNUSED(count); // Unused generated to ignore warnings
8822 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
8823 MEDI_UNUSED(root); // Unused generated to ignore warnings
8824 MEDI_UNUSED(comm); // Unused generated to ignore warnings
8825 MEDI_UNUSED(request); // Unused generated to ignore warnings
8826
8827 delete asyncHandle;
8828
8829 if(adType->isActiveType()) {
8830
8831 adType->addToolAction(h);
8832
8833 if(datatype->isModifiedBufferRequired()) {
8834 datatype->copyFromModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
8835 }
8836
8837 if(nullptr != h) {
8838 // handle the recv buffers
8839 datatype->registerValue(bufferRecv, 0, h->bufferRecvIndices, h->bufferRecvOldPrimals, 0, count);
8840 }
8841
8842 adType->stopAssembly(h);
8843
8844 if(root == getCommRank(comm)) {
8845 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
8846 datatype->deleteModifiedTypeBuffer(bufferSendMod);
8847 }
8848 }
8849 if(datatype->isModifiedBufferRequired() ) {
8850 datatype->deleteModifiedTypeBuffer(bufferRecvMod);
8851 }
8852
8853 // handle is deleted by the AD tool
8854 }
8855
8856 return rStatus;
8857 }
8858
8859#endif
8860#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
8861 template<typename SENDTYPE, typename RECVTYPE>
8864 typename SENDTYPE::IndexType* sendbufIndices;
8865 typename SENDTYPE::PrimalType* sendbufPrimals;
8866 /* required for async */ void* sendbufAdjoints;
8870 SENDTYPE* sendtype;
8872 typename RECVTYPE::IndexType* recvbufIndices;
8873 typename RECVTYPE::PrimalType* recvbufPrimals;
8874 typename RECVTYPE::PrimalType* recvbufOldPrimals;
8875 /* required for async */ void* recvbufAdjoints;
8879 RECVTYPE* recvtype;
8880 int root;
8882
8884 if(nullptr != sendbufIndices) {
8885 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
8886 sendbufIndices = nullptr;
8887 }
8888 if(nullptr != sendbufPrimals) {
8889 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
8890 sendbufPrimals = nullptr;
8891 }
8892 if(nullptr != recvbufIndices) {
8893 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
8894 recvbufIndices = nullptr;
8895 }
8896 if(nullptr != recvbufPrimals) {
8897 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
8898 recvbufPrimals = nullptr;
8899 }
8900 if(nullptr != recvbufOldPrimals) {
8901 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
8902 recvbufOldPrimals = nullptr;
8903 }
8904 }
8905 };
8906
8907 template<typename SENDTYPE, typename RECVTYPE>
8909 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
8910 typename SENDTYPE::ModifiedType* sendbufMod;
8912 SENDTYPE* sendtype;
8913 typename RECVTYPE::Type* recvbuf;
8914 typename RECVTYPE::ModifiedType* recvbufMod;
8916 RECVTYPE* recvtype;
8917 int root;
8920 };
8921
8922 template<typename SENDTYPE, typename RECVTYPE>
8923 void AMPI_Igather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
8925 (handle);
8926 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8927 (void)adType;
8928
8929 h->recvbufAdjoints = nullptr;
8930 if(h->root == getCommRank(h->comm)) {
8931 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
8932 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
8933 }
8934 h->sendbufAdjoints = nullptr;
8935 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
8936 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
8937 // Primal buffers are always linear in space so we can accesses them in one sweep
8938 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
8939
8940
8943
8944 }
8945
8946 template<typename SENDTYPE, typename RECVTYPE>
8947 void AMPI_Igather_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8948
8950 (handle);
8951 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8952 (void)adType;
8953 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8954
8955 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
8956 if(adType->isOldPrimalsRequired()) {
8957 if(h->root == getCommRank(h->comm)) {
8958 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
8959 }
8960 }
8961 if(h->root == getCommRank(h->comm)) {
8962 // Primal buffers are always linear in space so we can accesses them in one sweep
8963 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
8964 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
8965 }
8966 }
8967
8968 template<typename SENDTYPE, typename RECVTYPE>
8969 void AMPI_Igather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
8971 (handle);
8972 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8973 (void)adType;
8974
8975 h->recvbufAdjoints = nullptr;
8976 if(h->root == getCommRank(h->comm)) {
8977 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
8978 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
8979 }
8980 h->sendbufAdjoints = nullptr;
8981 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
8982 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
8983 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8984 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8985
8986
8989
8990 }
8991
8992 template<typename SENDTYPE, typename RECVTYPE>
8993 void AMPI_Igather_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8994
8996 (handle);
8997 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8998 (void)adType;
8999 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9000
9001 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9002 if(h->root == getCommRank(h->comm)) {
9003 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9004 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9005 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9006 }
9007 }
9008
9009 template<typename SENDTYPE, typename RECVTYPE>
9010 void AMPI_Igather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
9012 (handle);
9013 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9014 (void)adType;
9015
9016 h->recvbufAdjoints = nullptr;
9017 if(h->root == getCommRank(h->comm)) {
9018 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
9019 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
9020 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9021 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9022
9023 }
9024 if(adType->isOldPrimalsRequired()) {
9025 if(h->root == getCommRank(h->comm)) {
9026 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
9027 }
9028 }
9029 h->sendbufAdjoints = nullptr;
9030 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9031 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
9032
9035
9036 }
9037
9038 template<typename SENDTYPE, typename RECVTYPE>
9039 void AMPI_Igather_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9040
9042 (handle);
9043 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9044 (void)adType;
9045 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9046
9047 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9048 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
9049 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9050 if(h->root == getCommRank(h->comm)) {
9051 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9052 }
9053 }
9054
9055 template<typename SENDTYPE, typename RECVTYPE>
9056 int AMPI_Igather_finish(HandleBase* handle);
9057 template<typename SENDTYPE, typename RECVTYPE>
9058 int AMPI_Igather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
9059 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm, AMPI_Request* request) {
9060 int rStatus;
9061 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
9062
9063 if(!adType->isActiveType()) {
9064 // call the regular function if the type is not active
9065 rStatus = MPI_Igather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
9066 comm, &request->request);
9067 } else {
9068
9069 // the type is an AD type so handle the buffers
9071 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
9072 int sendbufElements = 0;
9073
9074 // compute the total size of the buffer
9075 if(AMPI_IN_PLACE != sendbuf) {
9076 sendbufElements = sendcount;
9077 } else {
9078 sendbufElements = recvcount;
9079 }
9080
9081 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9082 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
9083 } else {
9084 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
9085 }
9086 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
9087 int recvbufElements = 0;
9088
9089 if(root == getCommRank(comm)) {
9090 // compute the total size of the buffer
9091 recvbufElements = recvcount * getCommSize(comm);
9092
9093 if(recvtype->isModifiedBufferRequired() ) {
9094 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
9095 } else {
9096 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
9097 }
9098 }
9099
9100 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
9101 if(adType->isHandleRequired()) {
9103 }
9104 adType->startAssembly(h);
9105 if(sendtype->isModifiedBufferRequired()) {
9106 if(AMPI_IN_PLACE != sendbuf) {
9107 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
9108 } else {
9109 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
9110 recvcount);
9111 }
9112 }
9113
9114 if(nullptr != h) {
9115 // gather the information for the reverse sweep
9116
9117 // create the index buffers
9118 if(AMPI_IN_PLACE != sendbuf) {
9119 h->sendbufCount = sendtype->computeActiveElements(sendcount);
9120 } else {
9121 h->sendbufCount = recvtype->computeActiveElements(recvcount);
9122 }
9123 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
9124 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
9125 if(root == getCommRank(comm)) {
9126 h->recvbufCount = recvtype->computeActiveElements(recvcount);
9127 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
9128 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
9129 }
9130
9131
9132 // extract the old primal values from the recv buffer if the AD tool
9133 // needs the primal values reset
9134 if(adType->isOldPrimalsRequired()) {
9135 if(root == getCommRank(comm)) {
9136 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
9137 if(root == getCommRank(comm)) {
9138 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
9139 }
9140 }
9141 }
9142
9143
9144 if(AMPI_IN_PLACE != sendbuf) {
9145 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
9146 } else {
9147 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
9148 }
9149
9150 if(root == getCommRank(comm)) {
9151 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
9152 }
9153
9154 // pack all the variables in the handle
9158 h->sendcount = sendcount;
9159 h->sendtype = sendtype;
9160 h->recvcount = recvcount;
9161 h->recvtype = recvtype;
9162 h->root = root;
9163 h->comm = comm;
9164 }
9165
9166 if(root == getCommRank(comm)) {
9167 if(!recvtype->isModifiedBufferRequired()) {
9168 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
9169 }
9170 }
9171
9172 rStatus = MPI_Igather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
9173 recvtype->getModifiedMpiType(), root, comm, &request->request);
9174
9176 asyncHandle->sendbuf = sendbuf;
9177 asyncHandle->sendbufMod = sendbufMod;
9178 asyncHandle->sendcount = sendcount;
9179 asyncHandle->sendtype = sendtype;
9180 asyncHandle->recvbuf = recvbuf;
9181 asyncHandle->recvbufMod = recvbufMod;
9182 asyncHandle->recvcount = recvcount;
9183 asyncHandle->recvtype = recvtype;
9184 asyncHandle->root = root;
9185 asyncHandle->comm = comm;
9186 asyncHandle->toolHandle = h;
9187 request->handle = asyncHandle;
9189
9190 // create adjoint wait
9191 if(nullptr != h) {
9194 adType->addToolAction(waitH);
9195 }
9196 }
9197
9198 return rStatus;
9199 }
9200
9201 template<typename SENDTYPE, typename RECVTYPE>
9203 int rStatus = 0;
9204
9206 (handle);
9207 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
9208 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
9209 int sendcount = asyncHandle->sendcount;
9210 SENDTYPE* sendtype = asyncHandle->sendtype;
9211 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
9212 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
9213 int recvcount = asyncHandle->recvcount;
9214 RECVTYPE* recvtype = asyncHandle->recvtype;
9215 int root = asyncHandle->root;
9216 AMPI_Comm comm = asyncHandle->comm;
9217 AMPI_Request* request = asyncHandle->request;
9219 (asyncHandle->toolHandle);
9220 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
9221 MEDI_UNUSED(h); // Unused generated to ignore warnings
9222 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
9223 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
9224 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
9225 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
9226 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
9227 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
9228 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
9229 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
9230 MEDI_UNUSED(root); // Unused generated to ignore warnings
9231 MEDI_UNUSED(comm); // Unused generated to ignore warnings
9232 MEDI_UNUSED(request); // Unused generated to ignore warnings
9233
9234 delete asyncHandle;
9235
9236 if(adType->isActiveType()) {
9237
9238 adType->addToolAction(h);
9239
9240 if(root == getCommRank(comm)) {
9241 if(recvtype->isModifiedBufferRequired()) {
9242 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
9243 }
9244 }
9245
9246 if(nullptr != h) {
9247 // handle the recv buffers
9248 if(root == getCommRank(comm)) {
9249 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
9250 }
9251 }
9252
9253 adType->stopAssembly(h);
9254
9255 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9256 sendtype->deleteModifiedTypeBuffer(sendbufMod);
9257 }
9258 if(root == getCommRank(comm)) {
9259 if(recvtype->isModifiedBufferRequired() ) {
9260 recvtype->deleteModifiedTypeBuffer(recvbufMod);
9261 }
9262 }
9263
9264 // handle is deleted by the AD tool
9265 }
9266
9267 return rStatus;
9268 }
9269
9270#endif
9271#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
9272 template<typename SENDTYPE, typename RECVTYPE>
9275 typename SENDTYPE::IndexType* sendbufIndices;
9276 typename SENDTYPE::PrimalType* sendbufPrimals;
9277 /* required for async */ void* sendbufAdjoints;
9281 SENDTYPE* sendtype;
9283 typename RECVTYPE::IndexType* recvbufIndices;
9284 typename RECVTYPE::PrimalType* recvbufPrimals;
9285 typename RECVTYPE::PrimalType* recvbufOldPrimals;
9286 /* required for async */ void* recvbufAdjoints;
9288 /* required for async */ int* recvbufCountVec;
9289 /* required for async */ int* recvbufDisplsVec;
9290 const int* recvcounts;
9291 const int* displs;
9292 RECVTYPE* recvtype;
9293 int root;
9295
9297 if(nullptr != sendbufIndices) {
9298 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
9299 sendbufIndices = nullptr;
9300 }
9301 if(nullptr != sendbufPrimals) {
9302 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
9303 sendbufPrimals = nullptr;
9304 }
9305 if(nullptr != recvbufIndices) {
9306 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
9307 recvbufIndices = nullptr;
9308 }
9309 if(nullptr != recvbufPrimals) {
9310 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
9311 recvbufPrimals = nullptr;
9312 }
9313 if(nullptr != recvbufOldPrimals) {
9314 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
9315 recvbufOldPrimals = nullptr;
9316 }
9317 if(nullptr != recvbufCount) {
9318 delete [] recvbufCount;
9319 recvbufCount = nullptr;
9320 }
9321 }
9322 };
9323
9324 template<typename SENDTYPE, typename RECVTYPE>
9326 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
9327 typename SENDTYPE::ModifiedType* sendbufMod;
9329 SENDTYPE* sendtype;
9330 typename RECVTYPE::Type* recvbuf;
9331 typename RECVTYPE::ModifiedType* recvbufMod;
9332 const int* displsMod;
9333 const int* recvcounts;
9334 const int* displs;
9335 RECVTYPE* recvtype;
9336 int root;
9339 };
9340
9341 template<typename SENDTYPE, typename RECVTYPE>
9342 void AMPI_Igatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
9344 (handle);
9345 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9346 (void)adType;
9347
9348 h->recvbufAdjoints = nullptr;
9349 if(h->root == getCommRank(h->comm)) {
9351 adjointInterface->getVectorSize());
9352 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
9353 }
9354 h->sendbufAdjoints = nullptr;
9355 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9356 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
9357 // Primal buffers are always linear in space so we can accesses them in one sweep
9358 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
9359
9360
9363 &h->requestReverse);
9364
9365 }
9366
9367 template<typename SENDTYPE, typename RECVTYPE>
9368 void AMPI_Igatherv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9369
9371 (handle);
9372 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9373 (void)adType;
9374 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9375
9376 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
9377 if(adType->isOldPrimalsRequired()) {
9378 if(h->root == getCommRank(h->comm)) {
9379 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
9380 }
9381 }
9382 if(h->root == getCommRank(h->comm)) {
9383 // Primal buffers are always linear in space so we can accesses them in one sweep
9384 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
9385 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
9386 delete [] h->recvbufCountVec;
9387 delete [] h->recvbufDisplsVec;
9388 }
9389 }
9390
9391 template<typename SENDTYPE, typename RECVTYPE>
9392 void AMPI_Igatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
9394 (handle);
9395 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9396 (void)adType;
9397
9398 h->recvbufAdjoints = nullptr;
9399 if(h->root == getCommRank(h->comm)) {
9401 adjointInterface->getVectorSize());
9402 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
9403 }
9404 h->sendbufAdjoints = nullptr;
9405 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9406 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
9407 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9408 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
9409
9410
9413 &h->requestReverse);
9414
9415 }
9416
9417 template<typename SENDTYPE, typename RECVTYPE>
9418 void AMPI_Igatherv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9419
9421 (handle);
9422 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9423 (void)adType;
9424 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9425
9426 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9427 if(h->root == getCommRank(h->comm)) {
9428 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9429 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9430 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9431 delete [] h->recvbufCountVec;
9432 delete [] h->recvbufDisplsVec;
9433 }
9434 }
9435
9436 template<typename SENDTYPE, typename RECVTYPE>
9437 void AMPI_Igatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
9439 (handle);
9440 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9441 (void)adType;
9442
9443 h->recvbufAdjoints = nullptr;
9444 if(h->root == getCommRank(h->comm)) {
9446 adjointInterface->getVectorSize());
9447 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
9448 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9449 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9450
9451 }
9452 if(adType->isOldPrimalsRequired()) {
9453 if(h->root == getCommRank(h->comm)) {
9454 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
9455 }
9456 }
9457 h->sendbufAdjoints = nullptr;
9458 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9459 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
9460
9463 &h->requestReverse);
9464
9465 }
9466
9467 template<typename SENDTYPE, typename RECVTYPE>
9468 void AMPI_Igatherv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9469
9471 (handle);
9472 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9473 (void)adType;
9474 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9475
9476 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9477 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
9478 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9479 if(h->root == getCommRank(h->comm)) {
9480 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9481 delete [] h->recvbufCountVec;
9482 delete [] h->recvbufDisplsVec;
9483 }
9484 }
9485
9486 template<typename SENDTYPE, typename RECVTYPE>
9487 int AMPI_Igatherv_finish(HandleBase* handle);
9488 template<typename SENDTYPE, typename RECVTYPE>
9489 int AMPI_Igatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
9490 typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* displs, RECVTYPE* recvtype, int root,
9491 AMPI_Comm comm, AMPI_Request* request) {
9492 int rStatus;
9493 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
9494
9495 if(!adType->isActiveType()) {
9496 // call the regular function if the type is not active
9497 rStatus = MPI_Igatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs, recvtype->getMpiType(),
9498 root, comm, &request->request);
9499 } else {
9500
9501 // the type is an AD type so handle the buffers
9503 MEDI_OPTIONAL_CONST int* displsMod = displs;
9504 int displsTotalSize = 0;
9505 if(nullptr != displs) {
9506 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
9507 if(recvtype->isModifiedBufferRequired()) {
9508 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
9509 }
9510 }
9511 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
9512 int sendbufElements = 0;
9513
9514 // compute the total size of the buffer
9515 if(AMPI_IN_PLACE != sendbuf) {
9516 sendbufElements = sendcount;
9517 } else {
9518 sendbufElements = recvcounts[getCommRank(comm)];
9519 }
9520
9521 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9522 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
9523 } else {
9524 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
9525 }
9526 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
9527 int recvbufElements = 0;
9528
9529 if(root == getCommRank(comm)) {
9530 // compute the total size of the buffer
9531 recvbufElements = displsTotalSize;
9532
9533 if(recvtype->isModifiedBufferRequired() ) {
9534 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
9535 } else {
9536 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
9537 }
9538 }
9539
9540 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
9541 if(adType->isHandleRequired()) {
9543 }
9544 adType->startAssembly(h);
9545 if(sendtype->isModifiedBufferRequired()) {
9546 if(AMPI_IN_PLACE != sendbuf) {
9547 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
9548 } else {
9549 {
9550 const int rank = getCommRank(comm);
9551 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
9552 }
9553 }
9554 }
9555
9556 if(nullptr != h) {
9557 // gather the information for the reverse sweep
9558
9559 // create the index buffers
9560 if(AMPI_IN_PLACE != sendbuf) {
9561 h->sendbufCount = sendtype->computeActiveElements(sendcount);
9562 } else {
9563 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
9564 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
9565 }
9566 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
9567 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
9568 if(root == getCommRank(comm)) {
9569 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
9570 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
9571 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
9572 }
9573
9574
9575 // extract the old primal values from the recv buffer if the AD tool
9576 // needs the primal values reset
9577 if(adType->isOldPrimalsRequired()) {
9578 if(root == getCommRank(comm)) {
9579 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
9580 if(root == getCommRank(comm)) {
9581 for(int i = 0; i < getCommSize(comm); ++i) {
9582 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
9583 }
9584 }
9585 }
9586 }
9587
9588
9589 if(AMPI_IN_PLACE != sendbuf) {
9590 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
9591 } else {
9592 {
9593 const int rank = getCommRank(comm);
9594 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
9595 }
9596 }
9597
9598 if(root == getCommRank(comm)) {
9599 for(int i = 0; i < getCommSize(comm); ++i) {
9600 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
9601 }
9602 }
9603
9604 // pack all the variables in the handle
9608 h->sendcount = sendcount;
9609 h->sendtype = sendtype;
9610 h->recvcounts = recvcounts;
9611 h->displs = displs;
9612 h->recvtype = recvtype;
9613 h->root = root;
9614 h->comm = comm;
9615 }
9616
9617 if(root == getCommRank(comm)) {
9618 if(!recvtype->isModifiedBufferRequired()) {
9619 for(int i = 0; i < getCommSize(comm); ++i) {
9620 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
9621 }
9622 }
9623 }
9624
9625 rStatus = MPI_Igatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
9626 recvtype->getModifiedMpiType(), root, comm, &request->request);
9627
9629 asyncHandle->sendbuf = sendbuf;
9630 asyncHandle->sendbufMod = sendbufMod;
9631 asyncHandle->sendcount = sendcount;
9632 asyncHandle->sendtype = sendtype;
9633 asyncHandle->recvbuf = recvbuf;
9634 asyncHandle->recvbufMod = recvbufMod;
9635 asyncHandle->displsMod = displsMod;
9636 asyncHandle->recvcounts = recvcounts;
9637 asyncHandle->displs = displs;
9638 asyncHandle->recvtype = recvtype;
9639 asyncHandle->root = root;
9640 asyncHandle->comm = comm;
9641 asyncHandle->toolHandle = h;
9642 request->handle = asyncHandle;
9644
9645 // create adjoint wait
9646 if(nullptr != h) {
9649 adType->addToolAction(waitH);
9650 }
9651 }
9652
9653 return rStatus;
9654 }
9655
9656 template<typename SENDTYPE, typename RECVTYPE>
9658 int rStatus = 0;
9659
9662 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
9663 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
9664 int sendcount = asyncHandle->sendcount;
9665 SENDTYPE* sendtype = asyncHandle->sendtype;
9666 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
9667 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
9668 const int* displsMod = asyncHandle->displsMod;
9669 const int* recvcounts = asyncHandle->recvcounts;
9670 const int* displs = asyncHandle->displs;
9671 RECVTYPE* recvtype = asyncHandle->recvtype;
9672 int root = asyncHandle->root;
9673 AMPI_Comm comm = asyncHandle->comm;
9674 AMPI_Request* request = asyncHandle->request;
9676 (asyncHandle->toolHandle);
9677 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
9678 MEDI_UNUSED(h); // Unused generated to ignore warnings
9679 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
9680 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
9681 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
9682 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
9683 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
9684 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
9685 MEDI_UNUSED(displsMod); // Unused generated to ignore warnings
9686 MEDI_UNUSED(recvcounts); // Unused generated to ignore warnings
9687 MEDI_UNUSED(displs); // Unused generated to ignore warnings
9688 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
9689 MEDI_UNUSED(root); // Unused generated to ignore warnings
9690 MEDI_UNUSED(comm); // Unused generated to ignore warnings
9691 MEDI_UNUSED(request); // Unused generated to ignore warnings
9692
9693 delete asyncHandle;
9694
9695 if(adType->isActiveType()) {
9696
9697 adType->addToolAction(h);
9698
9699 if(root == getCommRank(comm)) {
9700 if(recvtype->isModifiedBufferRequired()) {
9701 for(int i = 0; i < getCommSize(comm); ++i) {
9702 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
9703 }
9704 }
9705 }
9706
9707 if(nullptr != h) {
9708 // handle the recv buffers
9709 if(root == getCommRank(comm)) {
9710 for(int i = 0; i < getCommSize(comm); ++i) {
9711 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
9712 }
9713 }
9714 }
9715
9716 adType->stopAssembly(h);
9717 if(recvtype->isModifiedBufferRequired()) {
9718 delete [] displsMod;
9719 }
9720
9721 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9722 sendtype->deleteModifiedTypeBuffer(sendbufMod);
9723 }
9724 if(root == getCommRank(comm)) {
9725 if(recvtype->isModifiedBufferRequired() ) {
9726 recvtype->deleteModifiedTypeBuffer(recvbufMod);
9727 }
9728 }
9729
9730 // handle is deleted by the AD tool
9731 }
9732
9733 return rStatus;
9734 }
9735
9736#endif
9737#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
9738 template<typename DATATYPE>
9741 typename DATATYPE::IndexType* sendbufIndices;
9742 typename DATATYPE::PrimalType* sendbufPrimals;
9743 /* required for async */ void* sendbufAdjoints;
9747 typename DATATYPE::IndexType* recvbufIndices;
9748 typename DATATYPE::PrimalType* recvbufPrimals;
9749 typename DATATYPE::PrimalType* recvbufOldPrimals;
9750 /* required for async */ void* recvbufAdjoints;
9754 DATATYPE* datatype;
9756 int root;
9758
9760 if(nullptr != sendbufIndices) {
9761 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
9762 sendbufIndices = nullptr;
9763 }
9764 if(nullptr != sendbufPrimals) {
9765 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
9766 sendbufPrimals = nullptr;
9767 }
9768 if(nullptr != recvbufIndices) {
9769 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
9770 recvbufIndices = nullptr;
9771 }
9772 if(nullptr != recvbufPrimals) {
9773 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
9774 recvbufPrimals = nullptr;
9775 }
9776 if(nullptr != recvbufOldPrimals) {
9777 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
9778 recvbufOldPrimals = nullptr;
9779 }
9780 }
9781 };
9782
9783 template<typename DATATYPE>
9785 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf;
9786 typename DATATYPE::ModifiedType* sendbufMod;
9787 typename DATATYPE::Type* recvbuf;
9788 typename DATATYPE::ModifiedType* recvbufMod;
9790 DATATYPE* datatype;
9792 int root;
9795 };
9796
9797 template<typename DATATYPE>
9798 void AMPI_Ireduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
9800 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9801 (void)adType;
9802
9803 AMPI_Op convOp = adType->convertOperator(h->op);
9804 (void)convOp;
9805 h->recvbufAdjoints = nullptr;
9806 if(h->root == getCommRank(h->comm)) {
9807 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
9808 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
9809 }
9810 h->sendbufAdjoints = nullptr;
9811 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9812 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
9813 // Primal buffers are always linear in space so we can accesses them in one sweep
9814 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
9815
9816
9818 h->count, h->datatype, h->op, h->root, h->comm, &h->requestReverse);
9819
9820 }
9821
9822 template<typename DATATYPE>
9824
9826 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9827 (void)adType;
9828 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9829
9830 AMPI_Op convOp = adType->convertOperator(h->op);
9831 (void)convOp;
9832 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
9833 if(adType->isOldPrimalsRequired()) {
9834 if(h->root == getCommRank(h->comm)) {
9835 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
9836 }
9837 }
9838 if(h->root == getCommRank(h->comm)) {
9839 // Primal buffers are always linear in space so we can accesses them in one sweep
9840 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
9841 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
9842 }
9843 }
9844
9845 template<typename DATATYPE>
9846 void AMPI_Ireduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
9848 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9849 (void)adType;
9850
9851 AMPI_Op convOp = adType->convertOperator(h->op);
9852 (void)convOp;
9853 h->recvbufAdjoints = nullptr;
9854 if(h->root == getCommRank(h->comm)) {
9855 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
9856 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
9857 }
9858 h->sendbufAdjoints = nullptr;
9859 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9860 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
9861 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9862 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
9863
9864
9866 h->count, h->datatype, h->op, h->root, h->comm, &h->requestReverse);
9867
9868 }
9869
9870 template<typename DATATYPE>
9872
9874 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9875 (void)adType;
9876 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9877
9878 AMPI_Op convOp = adType->convertOperator(h->op);
9879 (void)convOp;
9880 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9881 if(h->root == getCommRank(h->comm)) {
9882 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9883 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9884 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9885 }
9886 }
9887
9888 template<typename DATATYPE>
9889 void AMPI_Ireduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
9891 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9892 (void)adType;
9893
9894 AMPI_Op convOp = adType->convertOperator(h->op);
9895 (void)convOp;
9896 h->recvbufAdjoints = nullptr;
9897 if(h->root == getCommRank(h->comm)) {
9898 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
9899 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
9900 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9901 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9902
9903 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
9904 }
9905 if(adType->isOldPrimalsRequired()) {
9906 if(h->root == getCommRank(h->comm)) {
9907 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
9908 }
9909 }
9910 h->sendbufAdjoints = nullptr;
9911 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9912 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
9913
9915 h->count, h->datatype, h->op, h->root, h->comm, &h->requestReverse);
9916
9917 }
9918
9919 template<typename DATATYPE>
9921
9923 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9924 (void)adType;
9925 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9926
9927 AMPI_Op convOp = adType->convertOperator(h->op);
9928 (void)convOp;
9929 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
9930 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
9932 adjointInterface->getVectorSize());
9933 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9934 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
9935 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9936 if(h->root == getCommRank(h->comm)) {
9937 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9938 }
9939 }
9940
9941 template<typename DATATYPE>
9942 int AMPI_Ireduce_global_finish(HandleBase* handle);
9943 template<typename DATATYPE>
9944 int AMPI_Ireduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
9945 int count, DATATYPE* datatype, AMPI_Op op, int root, AMPI_Comm comm, AMPI_Request* request) {
9946 int rStatus;
9947 ADToolInterface const* adType = selectADTool(datatype->getADTool());
9948 AMPI_Op convOp = adType->convertOperator(op);
9949 (void)convOp;
9950
9951 if(!adType->isActiveType()) {
9952 // call the regular function if the type is not active
9953 rStatus = MPI_Ireduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, root, comm,
9954 &request->request);
9955 } else {
9956
9957 // the type is an AD type so handle the buffers
9959 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
9960 int sendbufElements = 0;
9961
9962 // compute the total size of the buffer
9963 if(AMPI_IN_PLACE != sendbuf) {
9964 sendbufElements = count;
9965 } else {
9966 sendbufElements = count;
9967 }
9968
9969 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9970 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
9971 } else {
9972 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
9973 }
9974 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
9975 int recvbufElements = 0;
9976
9977 if(root == getCommRank(comm)) {
9978 // compute the total size of the buffer
9979 recvbufElements = count;
9980
9981 if(datatype->isModifiedBufferRequired() ) {
9982 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
9983 } else {
9984 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
9985 }
9986 }
9987
9988 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
9989 if(adType->isHandleRequired()) {
9991 }
9992 adType->startAssembly(h);
9993 if(datatype->isModifiedBufferRequired()) {
9994 if(AMPI_IN_PLACE != sendbuf) {
9995 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
9996 } else {
9997 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
9998 }
9999 }
10000
10001 if(nullptr != h) {
10002 // gather the information for the reverse sweep
10003
10004 // create the index buffers
10005 if(AMPI_IN_PLACE != sendbuf) {
10006 h->sendbufCount = datatype->computeActiveElements(count);
10007 } else {
10008 h->sendbufCount = datatype->computeActiveElements(count);
10009 }
10010 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
10011 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
10012 if(root == getCommRank(comm)) {
10013 h->recvbufCount = datatype->computeActiveElements(count);
10014 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
10015 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
10016 }
10017
10018 // extract the primal values for the operator if required
10019 if(convOp.requiresPrimal) {
10020 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
10021 if(AMPI_IN_PLACE != sendbuf) {
10022 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
10023 } else {
10024 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
10025 }
10026 }
10027
10028 // extract the old primal values from the recv buffer if the AD tool
10029 // needs the primal values reset
10030 if(adType->isOldPrimalsRequired()) {
10031 if(root == getCommRank(comm)) {
10032 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
10033 if(root == getCommRank(comm)) {
10034 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
10035 }
10036 }
10037 }
10038
10039
10040 if(AMPI_IN_PLACE != sendbuf) {
10041 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
10042 } else {
10043 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
10044 }
10045
10046 if(root == getCommRank(comm)) {
10047 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
10048 }
10049
10050 // pack all the variables in the handle
10054 h->count = count;
10055 h->datatype = datatype;
10056 h->op = op;
10057 h->root = root;
10058 h->comm = comm;
10059 }
10060
10061 if(root == getCommRank(comm)) {
10062 if(!datatype->isModifiedBufferRequired()) {
10063 datatype->clearIndices(recvbuf, 0, count);
10064 }
10065 }
10066
10067 rStatus = MPI_Ireduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction,
10068 root, comm, &request->request);
10069
10071 asyncHandle->sendbuf = sendbuf;
10072 asyncHandle->sendbufMod = sendbufMod;
10073 asyncHandle->recvbuf = recvbuf;
10074 asyncHandle->recvbufMod = recvbufMod;
10075 asyncHandle->count = count;
10076 asyncHandle->datatype = datatype;
10077 asyncHandle->op = op;
10078 asyncHandle->root = root;
10079 asyncHandle->comm = comm;
10080 asyncHandle->toolHandle = h;
10081 request->handle = asyncHandle;
10083
10084 // create adjoint wait
10085 if(nullptr != h) {
10088 adType->addToolAction(waitH);
10089 }
10090 }
10091
10092 return rStatus;
10093 }
10094
10095 template<typename DATATYPE>
10097 int rStatus = 0;
10098
10100 (handle);
10101 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf = asyncHandle->sendbuf;
10102 typename DATATYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
10103 typename DATATYPE::Type* recvbuf = asyncHandle->recvbuf;
10104 typename DATATYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
10105 int count = asyncHandle->count;
10106 DATATYPE* datatype = asyncHandle->datatype;
10107 AMPI_Op op = asyncHandle->op;
10108 int root = asyncHandle->root;
10109 AMPI_Comm comm = asyncHandle->comm;
10110 AMPI_Request* request = asyncHandle->request;
10112 (asyncHandle->toolHandle);
10113 ADToolInterface const* adType = selectADTool(datatype->getADTool());
10114 MEDI_UNUSED(h); // Unused generated to ignore warnings
10115 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
10116 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
10117 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
10118 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
10119 MEDI_UNUSED(count); // Unused generated to ignore warnings
10120 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
10121 MEDI_UNUSED(op); // Unused generated to ignore warnings
10122 MEDI_UNUSED(root); // Unused generated to ignore warnings
10123 MEDI_UNUSED(comm); // Unused generated to ignore warnings
10124 MEDI_UNUSED(request); // Unused generated to ignore warnings
10125
10126 delete asyncHandle;
10127
10128 if(adType->isActiveType()) {
10129
10130 AMPI_Op convOp = adType->convertOperator(op);
10131 (void)convOp;
10132 adType->addToolAction(h);
10133
10134 if(root == getCommRank(comm)) {
10135 if(datatype->isModifiedBufferRequired()) {
10136 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
10137 }
10138 }
10139
10140 if(nullptr != h) {
10141 // handle the recv buffers
10142 if(root == getCommRank(comm)) {
10143 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
10144 }
10145 }
10146 // extract the primal values for the operator if required
10147 if(nullptr != h && convOp.requiresPrimal) {
10148 if(root == getCommRank(comm)) {
10149 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
10150 if(root == getCommRank(comm)) {
10151 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
10152 }
10153 }
10154 }
10155
10156 adType->stopAssembly(h);
10157
10158 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
10159 datatype->deleteModifiedTypeBuffer(sendbufMod);
10160 }
10161 if(root == getCommRank(comm)) {
10162 if(datatype->isModifiedBufferRequired() ) {
10163 datatype->deleteModifiedTypeBuffer(recvbufMod);
10164 }
10165 }
10166
10167 // handle is deleted by the AD tool
10168 }
10169
10170 return rStatus;
10171 }
10172
10173#endif
10174#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
10175 template<typename SENDTYPE, typename RECVTYPE>
10178 typename SENDTYPE::IndexType* sendbufIndices;
10179 typename SENDTYPE::PrimalType* sendbufPrimals;
10180 /* required for async */ void* sendbufAdjoints;
10184 SENDTYPE* sendtype;
10186 typename RECVTYPE::IndexType* recvbufIndices;
10187 typename RECVTYPE::PrimalType* recvbufPrimals;
10188 typename RECVTYPE::PrimalType* recvbufOldPrimals;
10189 /* required for async */ void* recvbufAdjoints;
10193 RECVTYPE* recvtype;
10194 int root;
10196
10198 if(nullptr != sendbufIndices) {
10199 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
10200 sendbufIndices = nullptr;
10201 }
10202 if(nullptr != sendbufPrimals) {
10203 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
10204 sendbufPrimals = nullptr;
10205 }
10206 if(nullptr != recvbufIndices) {
10207 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
10208 recvbufIndices = nullptr;
10209 }
10210 if(nullptr != recvbufPrimals) {
10211 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
10212 recvbufPrimals = nullptr;
10213 }
10214 if(nullptr != recvbufOldPrimals) {
10215 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
10216 recvbufOldPrimals = nullptr;
10217 }
10218 }
10219 };
10220
10221 template<typename SENDTYPE, typename RECVTYPE>
10223 const typename SENDTYPE::Type* sendbuf;
10224 typename SENDTYPE::ModifiedType* sendbufMod;
10226 SENDTYPE* sendtype;
10227 typename RECVTYPE::Type* recvbuf;
10228 typename RECVTYPE::ModifiedType* recvbufMod;
10230 RECVTYPE* recvtype;
10231 int root;
10234 };
10235
10236 template<typename SENDTYPE, typename RECVTYPE>
10237 void AMPI_Iscatter_p(HandleBase* handle, AdjointInterface* adjointInterface) {
10239 (handle);
10240 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10241 (void)adType;
10242
10243 h->recvbufAdjoints = nullptr;
10244 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10245 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
10246 h->sendbufAdjoints = nullptr;
10247 if(h->root == getCommRank(h->comm)) {
10248 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10249 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
10250 // Primal buffers are always linear in space so we can accesses them in one sweep
10251 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
10252
10253 }
10254
10257
10258 }
10259
10260 template<typename SENDTYPE, typename RECVTYPE>
10261 void AMPI_Iscatter_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10262
10264 (handle);
10265 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10266 (void)adType;
10267 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10268
10269 if(h->root == getCommRank(h->comm)) {
10270 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
10271 }
10272 if(adType->isOldPrimalsRequired()) {
10273 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10274 }
10275 // Primal buffers are always linear in space so we can accesses them in one sweep
10276 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
10277 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
10278 }
10279
10280 template<typename SENDTYPE, typename RECVTYPE>
10281 void AMPI_Iscatter_d(HandleBase* handle, AdjointInterface* adjointInterface) {
10283 (handle);
10284 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10285 (void)adType;
10286
10287 h->recvbufAdjoints = nullptr;
10288 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10289 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10290 h->sendbufAdjoints = nullptr;
10291 if(h->root == getCommRank(h->comm)) {
10292 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10293 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10294 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10295 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10296
10297 }
10298
10301
10302 }
10303
10304 template<typename SENDTYPE, typename RECVTYPE>
10305 void AMPI_Iscatter_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10306
10308 (handle);
10309 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10310 (void)adType;
10311 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10312
10313 if(h->root == getCommRank(h->comm)) {
10314 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10315 }
10316 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10317 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10318 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10319 }
10320
10321 template<typename SENDTYPE, typename RECVTYPE>
10322 void AMPI_Iscatter_b(HandleBase* handle, AdjointInterface* adjointInterface) {
10324 (handle);
10325 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10326 (void)adType;
10327
10328 h->recvbufAdjoints = nullptr;
10329 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10330 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10331 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10332 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10333
10334 if(adType->isOldPrimalsRequired()) {
10335 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10336 }
10337 h->sendbufAdjoints = nullptr;
10338 if(h->root == getCommRank(h->comm)) {
10339 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10340 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10341 }
10342
10345
10346 }
10347
10348 template<typename SENDTYPE, typename RECVTYPE>
10349 void AMPI_Iscatter_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10350
10352 (handle);
10353 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10354 (void)adType;
10355 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10356
10357 if(h->root == getCommRank(h->comm)) {
10358 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10359 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10360 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10361 }
10362 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10363 }
10364
10365 template<typename SENDTYPE, typename RECVTYPE>
10366 int AMPI_Iscatter_finish(HandleBase* handle);
10367 template<typename SENDTYPE, typename RECVTYPE>
10368 int AMPI_Iscatter(const typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
10369 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm, AMPI_Request* request) {
10370 int rStatus;
10371 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
10372
10373 if(!adType->isActiveType()) {
10374 // call the regular function if the type is not active
10375 rStatus = MPI_Iscatter(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
10376 comm, &request->request);
10377 } else {
10378
10379 // the type is an AD type so handle the buffers
10381 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
10382 int sendbufElements = 0;
10383
10384 if(root == getCommRank(comm)) {
10385 // compute the total size of the buffer
10386 sendbufElements = sendcount * getCommSize(comm);
10387
10388 if(sendtype->isModifiedBufferRequired() ) {
10389 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
10390 } else {
10391 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
10392 }
10393 }
10394 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
10395 int recvbufElements = 0;
10396
10397 // compute the total size of the buffer
10398 if(AMPI_IN_PLACE != recvbuf) {
10399 recvbufElements = recvcount;
10400 } else {
10401 recvbufElements = sendcount;
10402 }
10403
10404 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
10405 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
10406 } else {
10407 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
10408 }
10409
10410 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
10411 if(adType->isHandleRequired()) {
10413 }
10414 adType->startAssembly(h);
10415 if(root == getCommRank(comm)) {
10416 if(sendtype->isModifiedBufferRequired()) {
10417 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
10418 }
10419 }
10420
10421 if(nullptr != h) {
10422 // gather the information for the reverse sweep
10423
10424 // create the index buffers
10425 if(root == getCommRank(comm)) {
10426 h->sendbufCount = sendtype->computeActiveElements(sendcount);
10427 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
10428 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
10429 }
10430 if(AMPI_IN_PLACE != recvbuf) {
10431 h->recvbufCount = recvtype->computeActiveElements(recvcount);
10432 } else {
10433 h->recvbufCount = sendtype->computeActiveElements(sendcount);
10434 }
10435 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
10436 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
10437
10438
10439 // extract the old primal values from the recv buffer if the AD tool
10440 // needs the primal values reset
10441 if(adType->isOldPrimalsRequired()) {
10442 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
10443 if(AMPI_IN_PLACE != recvbuf) {
10444 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
10445 } else {
10446 sendtype->getValues(sendbuf, sendcount * getCommRank(comm), h->recvbufOldPrimals, 0, sendcount);
10447 }
10448 }
10449
10450
10451 if(root == getCommRank(comm)) {
10452 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
10453 }
10454
10455 if(AMPI_IN_PLACE != recvbuf) {
10456 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
10457 } else {
10458 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
10459 0, sendcount);
10460 }
10461
10462 // pack all the variables in the handle
10466 h->sendcount = sendcount;
10467 h->sendtype = sendtype;
10468 h->recvcount = recvcount;
10469 h->recvtype = recvtype;
10470 h->root = root;
10471 h->comm = comm;
10472 }
10473
10474 if(!recvtype->isModifiedBufferRequired()) {
10475 if(AMPI_IN_PLACE != recvbuf) {
10476 recvtype->clearIndices(recvbuf, 0, recvcount);
10477 } else {
10478 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), sendcount);
10479 }
10480 }
10481
10482 rStatus = MPI_Iscatter(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
10483 recvtype->getModifiedMpiType(), root, comm, &request->request);
10484
10486 asyncHandle->sendbuf = sendbuf;
10487 asyncHandle->sendbufMod = sendbufMod;
10488 asyncHandle->sendcount = sendcount;
10489 asyncHandle->sendtype = sendtype;
10490 asyncHandle->recvbuf = recvbuf;
10491 asyncHandle->recvbufMod = recvbufMod;
10492 asyncHandle->recvcount = recvcount;
10493 asyncHandle->recvtype = recvtype;
10494 asyncHandle->root = root;
10495 asyncHandle->comm = comm;
10496 asyncHandle->toolHandle = h;
10497 request->handle = asyncHandle;
10499
10500 // create adjoint wait
10501 if(nullptr != h) {
10504 adType->addToolAction(waitH);
10505 }
10506 }
10507
10508 return rStatus;
10509 }
10510
10511 template<typename SENDTYPE, typename RECVTYPE>
10513 int rStatus = 0;
10514
10517 const typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
10518 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
10519 int sendcount = asyncHandle->sendcount;
10520 SENDTYPE* sendtype = asyncHandle->sendtype;
10521 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
10522 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
10523 int recvcount = asyncHandle->recvcount;
10524 RECVTYPE* recvtype = asyncHandle->recvtype;
10525 int root = asyncHandle->root;
10526 AMPI_Comm comm = asyncHandle->comm;
10527 AMPI_Request* request = asyncHandle->request;
10529 (asyncHandle->toolHandle);
10530 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
10531 MEDI_UNUSED(h); // Unused generated to ignore warnings
10532 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
10533 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
10534 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
10535 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
10536 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
10537 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
10538 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
10539 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
10540 MEDI_UNUSED(root); // Unused generated to ignore warnings
10541 MEDI_UNUSED(comm); // Unused generated to ignore warnings
10542 MEDI_UNUSED(request); // Unused generated to ignore warnings
10543
10544 delete asyncHandle;
10545
10546 if(adType->isActiveType()) {
10547
10548 adType->addToolAction(h);
10549
10550 if(recvtype->isModifiedBufferRequired()) {
10551 if(AMPI_IN_PLACE != recvbuf) {
10552 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
10553 } else {
10554 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm),
10555 sendbufMod, sendcount * getCommRank(comm), sendcount);
10556 }
10557 }
10558
10559 if(nullptr != h) {
10560 // handle the recv buffers
10561 if(AMPI_IN_PLACE != recvbuf) {
10562 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
10563 } else {
10564 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
10565 h->recvbufOldPrimals, 0, sendcount);
10566 }
10567 }
10568
10569 adType->stopAssembly(h);
10570
10571 if(root == getCommRank(comm)) {
10572 if(sendtype->isModifiedBufferRequired() ) {
10573 sendtype->deleteModifiedTypeBuffer(sendbufMod);
10574 }
10575 }
10576 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
10577 recvtype->deleteModifiedTypeBuffer(recvbufMod);
10578 }
10579
10580 // handle is deleted by the AD tool
10581 }
10582
10583 return rStatus;
10584 }
10585
10586#endif
10587#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
10588 template<typename SENDTYPE, typename RECVTYPE>
10591 typename SENDTYPE::IndexType* sendbufIndices;
10592 typename SENDTYPE::PrimalType* sendbufPrimals;
10593 /* required for async */ void* sendbufAdjoints;
10595 /* required for async */ int* sendbufCountVec;
10596 /* required for async */ int* sendbufDisplsVec;
10597 const int* sendcounts;
10598 const int* displs;
10599 SENDTYPE* sendtype;
10601 typename RECVTYPE::IndexType* recvbufIndices;
10602 typename RECVTYPE::PrimalType* recvbufPrimals;
10603 typename RECVTYPE::PrimalType* recvbufOldPrimals;
10604 /* required for async */ void* recvbufAdjoints;
10608 RECVTYPE* recvtype;
10609 int root;
10611
10613 if(nullptr != sendbufIndices) {
10614 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
10615 sendbufIndices = nullptr;
10616 }
10617 if(nullptr != sendbufPrimals) {
10618 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
10619 sendbufPrimals = nullptr;
10620 }
10621 if(nullptr != sendbufCount) {
10622 delete [] sendbufCount;
10623 sendbufCount = nullptr;
10624 }
10625 if(nullptr != recvbufIndices) {
10626 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
10627 recvbufIndices = nullptr;
10628 }
10629 if(nullptr != recvbufPrimals) {
10630 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
10631 recvbufPrimals = nullptr;
10632 }
10633 if(nullptr != recvbufOldPrimals) {
10634 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
10635 recvbufOldPrimals = nullptr;
10636 }
10637 }
10638 };
10639
10640 template<typename SENDTYPE, typename RECVTYPE>
10642 const typename SENDTYPE::Type* sendbuf;
10643 typename SENDTYPE::ModifiedType* sendbufMod;
10644 const int* displsMod;
10645 const int* sendcounts;
10646 const int* displs;
10647 SENDTYPE* sendtype;
10648 typename RECVTYPE::Type* recvbuf;
10649 typename RECVTYPE::ModifiedType* recvbufMod;
10651 RECVTYPE* recvtype;
10652 int root;
10655 };
10656
10657 template<typename SENDTYPE, typename RECVTYPE>
10658 void AMPI_Iscatterv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
10660 (handle);
10661 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10662 (void)adType;
10663
10664 h->recvbufAdjoints = nullptr;
10665 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10666 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
10667 h->sendbufAdjoints = nullptr;
10668 if(h->root == getCommRank(h->comm)) {
10670 adjointInterface->getVectorSize());
10671 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
10672 // Primal buffers are always linear in space so we can accesses them in one sweep
10673 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
10674
10675 }
10676
10679 &h->requestReverse);
10680
10681 }
10682
10683 template<typename SENDTYPE, typename RECVTYPE>
10684 void AMPI_Iscatterv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10685
10687 (handle);
10688 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10689 (void)adType;
10690 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10691
10692 if(h->root == getCommRank(h->comm)) {
10693 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
10694 delete [] h->sendbufCountVec;
10695 delete [] h->sendbufDisplsVec;
10696 }
10697 if(adType->isOldPrimalsRequired()) {
10698 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10699 }
10700 // Primal buffers are always linear in space so we can accesses them in one sweep
10701 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
10702 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
10703 }
10704
10705 template<typename SENDTYPE, typename RECVTYPE>
10706 void AMPI_Iscatterv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
10708 (handle);
10709 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10710 (void)adType;
10711
10712 h->recvbufAdjoints = nullptr;
10713 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10714 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10715 h->sendbufAdjoints = nullptr;
10716 if(h->root == getCommRank(h->comm)) {
10718 adjointInterface->getVectorSize());
10719 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10720 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10721 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10722
10723 }
10724
10727 &h->requestReverse);
10728
10729 }
10730
10731 template<typename SENDTYPE, typename RECVTYPE>
10732 void AMPI_Iscatterv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10733
10735 (handle);
10736 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10737 (void)adType;
10738 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10739
10740 if(h->root == getCommRank(h->comm)) {
10741 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10742 delete [] h->sendbufCountVec;
10743 delete [] h->sendbufDisplsVec;
10744 }
10745 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10746 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10747 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10748 }
10749
10750 template<typename SENDTYPE, typename RECVTYPE>
10751 void AMPI_Iscatterv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
10753 (handle);
10754 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10755 (void)adType;
10756
10757 h->recvbufAdjoints = nullptr;
10758 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10759 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10760 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10761 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10762
10763 if(adType->isOldPrimalsRequired()) {
10764 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10765 }
10766 h->sendbufAdjoints = nullptr;
10767 if(h->root == getCommRank(h->comm)) {
10769 adjointInterface->getVectorSize());
10770 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10771 }
10772
10775 &h->requestReverse);
10776
10777 }
10778
10779 template<typename SENDTYPE, typename RECVTYPE>
10780 void AMPI_Iscatterv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10781
10783 (handle);
10784 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10785 (void)adType;
10786 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10787
10788 if(h->root == getCommRank(h->comm)) {
10789 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10790 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10791 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10792 delete [] h->sendbufCountVec;
10793 delete [] h->sendbufDisplsVec;
10794 }
10795 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10796 }
10797
10798 template<typename SENDTYPE, typename RECVTYPE>
10799 int AMPI_Iscatterv_finish(HandleBase* handle);
10800 template<typename SENDTYPE, typename RECVTYPE>
10801 int AMPI_Iscatterv(const typename SENDTYPE::Type* sendbuf, const int* sendcounts, const int* displs, SENDTYPE* sendtype,
10802 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm, AMPI_Request* request) {
10803 int rStatus;
10804 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
10805
10806 if(!adType->isActiveType()) {
10807 // call the regular function if the type is not active
10808 rStatus = MPI_Iscatterv(sendbuf, sendcounts, displs, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(),
10809 root, comm, &request->request);
10810 } else {
10811
10812 // the type is an AD type so handle the buffers
10814 MEDI_OPTIONAL_CONST int* displsMod = displs;
10815 int displsTotalSize = 0;
10816 if(nullptr != displs) {
10817 displsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
10818 if(recvtype->isModifiedBufferRequired()) {
10819 displsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
10820 }
10821 }
10822 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
10823 int sendbufElements = 0;
10824
10825 if(root == getCommRank(comm)) {
10826 // compute the total size of the buffer
10827 sendbufElements = displsTotalSize;
10828
10829 if(sendtype->isModifiedBufferRequired() ) {
10830 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
10831 } else {
10832 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
10833 }
10834 }
10835 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
10836 int recvbufElements = 0;
10837
10838 // compute the total size of the buffer
10839 if(AMPI_IN_PLACE != recvbuf) {
10840 recvbufElements = recvcount;
10841 } else {
10842 recvbufElements = sendcounts[getCommRank(comm)];
10843 }
10844
10845 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
10846 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
10847 } else {
10848 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
10849 }
10850
10851 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
10852 if(adType->isHandleRequired()) {
10854 }
10855 adType->startAssembly(h);
10856 if(root == getCommRank(comm)) {
10857 if(sendtype->isModifiedBufferRequired()) {
10858 for(int i = 0; i < getCommSize(comm); ++i) {
10859 sendtype->copyIntoModifiedBuffer(sendbuf, displs[i], sendbufMod, displsMod[i], sendcounts[i]);
10860 }
10861 }
10862 }
10863
10864 if(nullptr != h) {
10865 // gather the information for the reverse sweep
10866
10867 // create the index buffers
10868 if(root == getCommRank(comm)) {
10869 createLinearIndexCounts(h->sendbufCount, sendcounts, displs, getCommSize(comm), sendtype);
10870 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
10871 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
10872 }
10873 if(AMPI_IN_PLACE != recvbuf) {
10874 h->recvbufCount = recvtype->computeActiveElements(recvcount);
10875 } else {
10876 h->recvbufCount = sendtype->computeActiveElements(displs[getCommRank(comm)] + sendcounts[getCommRank(
10877 comm)]) - sendtype->computeActiveElements(displs[getCommRank(comm)]);
10878 }
10879 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
10880 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
10881
10882
10883 // extract the old primal values from the recv buffer if the AD tool
10884 // needs the primal values reset
10885 if(adType->isOldPrimalsRequired()) {
10886 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
10887 if(AMPI_IN_PLACE != recvbuf) {
10888 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
10889 } else {
10890 {
10891 const int rank = getCommRank(comm);
10892 sendtype->getValues(sendbuf, displs[rank], h->recvbufOldPrimals, 0, sendcounts[rank]);
10893 }
10894 }
10895 }
10896
10897
10898 if(root == getCommRank(comm)) {
10899 for(int i = 0; i < getCommSize(comm); ++i) {
10900 sendtype->getIndices(sendbuf, displs[i], h->sendbufIndices, displsMod[i], sendcounts[i]);
10901 }
10902 }
10903
10904 if(AMPI_IN_PLACE != recvbuf) {
10905 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
10906 } else {
10907 {
10908 const int rank = getCommRank(comm);
10909 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices, 0,
10910 sendcounts[rank]);
10911 }
10912 }
10913
10914 // pack all the variables in the handle
10918 h->sendcounts = sendcounts;
10919 h->displs = displs;
10920 h->sendtype = sendtype;
10921 h->recvcount = recvcount;
10922 h->recvtype = recvtype;
10923 h->root = root;
10924 h->comm = comm;
10925 }
10926
10927 if(!recvtype->isModifiedBufferRequired()) {
10928 if(AMPI_IN_PLACE != recvbuf) {
10929 recvtype->clearIndices(recvbuf, 0, recvcount);
10930 } else {
10931 {
10932 const int rank = getCommRank(comm);
10933 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendcounts[rank]);
10934 }
10935 }
10936 }
10937
10938 rStatus = MPI_Iscatterv(sendbufMod, sendcounts, displsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
10939 recvtype->getModifiedMpiType(), root, comm, &request->request);
10940
10942 asyncHandle->sendbuf = sendbuf;
10943 asyncHandle->sendbufMod = sendbufMod;
10944 asyncHandle->displsMod = displsMod;
10945 asyncHandle->sendcounts = sendcounts;
10946 asyncHandle->displs = displs;
10947 asyncHandle->sendtype = sendtype;
10948 asyncHandle->recvbuf = recvbuf;
10949 asyncHandle->recvbufMod = recvbufMod;
10950 asyncHandle->recvcount = recvcount;
10951 asyncHandle->recvtype = recvtype;
10952 asyncHandle->root = root;
10953 asyncHandle->comm = comm;
10954 asyncHandle->toolHandle = h;
10955 request->handle = asyncHandle;
10957
10958 // create adjoint wait
10959 if(nullptr != h) {
10962 adType->addToolAction(waitH);
10963 }
10964 }
10965
10966 return rStatus;
10967 }
10968
10969 template<typename SENDTYPE, typename RECVTYPE>
10971 int rStatus = 0;
10972
10975 const typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
10976 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
10977 const int* displsMod = asyncHandle->displsMod;
10978 const int* sendcounts = asyncHandle->sendcounts;
10979 const int* displs = asyncHandle->displs;
10980 SENDTYPE* sendtype = asyncHandle->sendtype;
10981 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
10982 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
10983 int recvcount = asyncHandle->recvcount;
10984 RECVTYPE* recvtype = asyncHandle->recvtype;
10985 int root = asyncHandle->root;
10986 AMPI_Comm comm = asyncHandle->comm;
10987 AMPI_Request* request = asyncHandle->request;
10989 (asyncHandle->toolHandle);
10990 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
10991 MEDI_UNUSED(h); // Unused generated to ignore warnings
10992 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
10993 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
10994 MEDI_UNUSED(displsMod); // Unused generated to ignore warnings
10995 MEDI_UNUSED(sendcounts); // Unused generated to ignore warnings
10996 MEDI_UNUSED(displs); // Unused generated to ignore warnings
10997 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
10998 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
10999 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
11000 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
11001 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
11002 MEDI_UNUSED(root); // Unused generated to ignore warnings
11003 MEDI_UNUSED(comm); // Unused generated to ignore warnings
11004 MEDI_UNUSED(request); // Unused generated to ignore warnings
11005
11006 delete asyncHandle;
11007
11008 if(adType->isActiveType()) {
11009
11010 adType->addToolAction(h);
11011
11012 if(recvtype->isModifiedBufferRequired()) {
11013 if(AMPI_IN_PLACE != recvbuf) {
11014 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
11015 } else {
11016 {
11017 const int rank = getCommRank(comm);
11018 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendbufMod,
11019 displsMod[rank], sendcounts[rank]);
11020 }
11021 }
11022 }
11023
11024 if(nullptr != h) {
11025 // handle the recv buffers
11026 if(AMPI_IN_PLACE != recvbuf) {
11027 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
11028 } else {
11029 {
11030 const int rank = getCommRank(comm);
11031 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices,
11032 h->recvbufOldPrimals, 0, sendcounts[rank]);
11033 }
11034 }
11035 }
11036
11037 adType->stopAssembly(h);
11038 if(recvtype->isModifiedBufferRequired()) {
11039 delete [] displsMod;
11040 }
11041
11042 if(root == getCommRank(comm)) {
11043 if(sendtype->isModifiedBufferRequired() ) {
11044 sendtype->deleteModifiedTypeBuffer(sendbufMod);
11045 }
11046 }
11047 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11048 recvtype->deleteModifiedTypeBuffer(recvbufMod);
11049 }
11050
11051 // handle is deleted by the AD tool
11052 }
11053
11054 return rStatus;
11055 }
11056
11057#endif
11058#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
11059 template<typename DATATYPE>
11062 typename DATATYPE::IndexType* sendbufIndices;
11063 typename DATATYPE::PrimalType* sendbufPrimals;
11064 /* required for async */ void* sendbufAdjoints;
11068 typename DATATYPE::IndexType* recvbufIndices;
11069 typename DATATYPE::PrimalType* recvbufPrimals;
11070 typename DATATYPE::PrimalType* recvbufOldPrimals;
11071 /* required for async */ void* recvbufAdjoints;
11075 DATATYPE* datatype;
11077 int root;
11079
11081 if(nullptr != sendbufIndices) {
11082 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
11083 sendbufIndices = nullptr;
11084 }
11085 if(nullptr != sendbufPrimals) {
11086 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
11087 sendbufPrimals = nullptr;
11088 }
11089 if(nullptr != recvbufIndices) {
11090 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
11091 recvbufIndices = nullptr;
11092 }
11093 if(nullptr != recvbufPrimals) {
11094 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
11095 recvbufPrimals = nullptr;
11096 }
11097 if(nullptr != recvbufOldPrimals) {
11098 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
11099 recvbufOldPrimals = nullptr;
11100 }
11101 }
11102 };
11103
11104
11105 template<typename DATATYPE>
11106 void AMPI_Reduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
11108 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11109 (void)adType;
11110
11111 AMPI_Op convOp = adType->convertOperator(h->op);
11112 (void)convOp;
11113 h->recvbufAdjoints = nullptr;
11114 if(h->root == getCommRank(h->comm)) {
11115 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11116 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
11117 }
11118 h->sendbufAdjoints = nullptr;
11119 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11120 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
11121 // Primal buffers are always linear in space so we can accesses them in one sweep
11122 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
11123
11124
11126 h->datatype, h->op, h->root, h->comm);
11127
11128 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
11129 if(adType->isOldPrimalsRequired()) {
11130 if(h->root == getCommRank(h->comm)) {
11131 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11132 }
11133 }
11134 if(h->root == getCommRank(h->comm)) {
11135 // Primal buffers are always linear in space so we can accesses them in one sweep
11136 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
11137 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
11138 }
11139 }
11140
11141 template<typename DATATYPE>
11142 void AMPI_Reduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
11144 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11145 (void)adType;
11146
11147 AMPI_Op convOp = adType->convertOperator(h->op);
11148 (void)convOp;
11149 h->recvbufAdjoints = nullptr;
11150 if(h->root == getCommRank(h->comm)) {
11151 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11152 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11153 }
11154 h->sendbufAdjoints = nullptr;
11155 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11156 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11157 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11158 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11159
11160
11162 h->count, h->datatype, h->op, h->root, h->comm);
11163
11164 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11165 if(h->root == getCommRank(h->comm)) {
11166 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11167 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11168 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11169 }
11170 }
11171
11172 template<typename DATATYPE>
11173 void AMPI_Reduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
11175 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11176 (void)adType;
11177
11178 AMPI_Op convOp = adType->convertOperator(h->op);
11179 (void)convOp;
11180 h->recvbufAdjoints = nullptr;
11181 if(h->root == getCommRank(h->comm)) {
11182 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11183 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11184 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11185 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11186
11187 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
11188 }
11189 if(adType->isOldPrimalsRequired()) {
11190 if(h->root == getCommRank(h->comm)) {
11191 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11192 }
11193 }
11194 h->sendbufAdjoints = nullptr;
11195 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11196 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11197
11199 h->count, h->datatype, h->op, h->root, h->comm);
11200
11201 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
11202 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
11204 adjointInterface->getVectorSize());
11205 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11206 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11207 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11208 if(h->root == getCommRank(h->comm)) {
11209 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11210 }
11211 }
11212
11213 template<typename DATATYPE>
11214 int AMPI_Reduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
11215 int count, DATATYPE* datatype, AMPI_Op op, int root, AMPI_Comm comm) {
11216 int rStatus;
11217 ADToolInterface const* adType = selectADTool(datatype->getADTool());
11218 AMPI_Op convOp = adType->convertOperator(op);
11219 (void)convOp;
11220
11221 if(!adType->isActiveType()) {
11222 // call the regular function if the type is not active
11223 rStatus = MPI_Reduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, root, comm);
11224 } else {
11225
11226 // the type is an AD type so handle the buffers
11228 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
11229 int sendbufElements = 0;
11230
11231 // compute the total size of the buffer
11232 if(AMPI_IN_PLACE != sendbuf) {
11233 sendbufElements = count;
11234 } else {
11235 sendbufElements = count;
11236 }
11237
11238 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
11239 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
11240 } else {
11241 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
11242 }
11243 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
11244 int recvbufElements = 0;
11245
11246 if(root == getCommRank(comm)) {
11247 // compute the total size of the buffer
11248 recvbufElements = count;
11249
11250 if(datatype->isModifiedBufferRequired() ) {
11251 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
11252 } else {
11253 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
11254 }
11255 }
11256
11257 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
11258 if(adType->isHandleRequired()) {
11260 }
11261 adType->startAssembly(h);
11262 if(datatype->isModifiedBufferRequired()) {
11263 if(AMPI_IN_PLACE != sendbuf) {
11264 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
11265 } else {
11266 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
11267 }
11268 }
11269
11270 if(nullptr != h) {
11271 // gather the information for the reverse sweep
11272
11273 // create the index buffers
11274 if(AMPI_IN_PLACE != sendbuf) {
11275 h->sendbufCount = datatype->computeActiveElements(count);
11276 } else {
11277 h->sendbufCount = datatype->computeActiveElements(count);
11278 }
11279 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
11280 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
11281 if(root == getCommRank(comm)) {
11282 h->recvbufCount = datatype->computeActiveElements(count);
11283 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
11284 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
11285 }
11286
11287 // extract the primal values for the operator if required
11288 if(convOp.requiresPrimal) {
11289 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
11290 if(AMPI_IN_PLACE != sendbuf) {
11291 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
11292 } else {
11293 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
11294 }
11295 }
11296
11297 // extract the old primal values from the recv buffer if the AD tool
11298 // needs the primal values reset
11299 if(adType->isOldPrimalsRequired()) {
11300 if(root == getCommRank(comm)) {
11301 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
11302 if(root == getCommRank(comm)) {
11303 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
11304 }
11305 }
11306 }
11307
11308
11309 if(AMPI_IN_PLACE != sendbuf) {
11310 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
11311 } else {
11312 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
11313 }
11314
11315 if(root == getCommRank(comm)) {
11316 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
11317 }
11318
11319 // pack all the variables in the handle
11323 h->count = count;
11324 h->datatype = datatype;
11325 h->op = op;
11326 h->root = root;
11327 h->comm = comm;
11328 }
11329
11330 if(root == getCommRank(comm)) {
11331 if(!datatype->isModifiedBufferRequired()) {
11332 datatype->clearIndices(recvbuf, 0, count);
11333 }
11334 }
11335
11336 rStatus = MPI_Reduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction, root,
11337 comm);
11338 adType->addToolAction(h);
11339
11340 if(root == getCommRank(comm)) {
11341 if(datatype->isModifiedBufferRequired()) {
11342 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
11343 }
11344 }
11345
11346 if(nullptr != h) {
11347 // handle the recv buffers
11348 if(root == getCommRank(comm)) {
11349 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
11350 }
11351 }
11352 // extract the primal values for the operator if required
11353 if(nullptr != h && convOp.requiresPrimal) {
11354 if(root == getCommRank(comm)) {
11355 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
11356 if(root == getCommRank(comm)) {
11357 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
11358 }
11359 }
11360 }
11361
11362 adType->stopAssembly(h);
11363
11364 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
11365 datatype->deleteModifiedTypeBuffer(sendbufMod);
11366 }
11367 if(root == getCommRank(comm)) {
11368 if(datatype->isModifiedBufferRequired() ) {
11369 datatype->deleteModifiedTypeBuffer(recvbufMod);
11370 }
11371 }
11372
11373 // handle is deleted by the AD tool
11374 }
11375
11376 return rStatus;
11377 }
11378
11379#endif
11380#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
11381 template<typename SENDTYPE, typename RECVTYPE>
11384 typename SENDTYPE::IndexType* sendbufIndices;
11385 typename SENDTYPE::PrimalType* sendbufPrimals;
11386 /* required for async */ void* sendbufAdjoints;
11390 SENDTYPE* sendtype;
11392 typename RECVTYPE::IndexType* recvbufIndices;
11393 typename RECVTYPE::PrimalType* recvbufPrimals;
11394 typename RECVTYPE::PrimalType* recvbufOldPrimals;
11395 /* required for async */ void* recvbufAdjoints;
11399 RECVTYPE* recvtype;
11400 int root;
11402
11404 if(nullptr != sendbufIndices) {
11405 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
11406 sendbufIndices = nullptr;
11407 }
11408 if(nullptr != sendbufPrimals) {
11409 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
11410 sendbufPrimals = nullptr;
11411 }
11412 if(nullptr != recvbufIndices) {
11413 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
11414 recvbufIndices = nullptr;
11415 }
11416 if(nullptr != recvbufPrimals) {
11417 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
11418 recvbufPrimals = nullptr;
11419 }
11420 if(nullptr != recvbufOldPrimals) {
11421 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
11422 recvbufOldPrimals = nullptr;
11423 }
11424 }
11425 };
11426
11427
11428 template<typename SENDTYPE, typename RECVTYPE>
11429 void AMPI_Scatter_p(HandleBase* handle, AdjointInterface* adjointInterface) {
11431 (handle);
11432 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11433 (void)adType;
11434
11435 h->recvbufAdjoints = nullptr;
11436 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11437 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
11438 h->sendbufAdjoints = nullptr;
11439 if(h->root == getCommRank(h->comm)) {
11440 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11441 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
11442 // Primal buffers are always linear in space so we can accesses them in one sweep
11443 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
11444
11445 }
11446
11448 h->recvbufPrimals, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
11449
11450 if(h->root == getCommRank(h->comm)) {
11451 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
11452 }
11453 if(adType->isOldPrimalsRequired()) {
11454 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11455 }
11456 // Primal buffers are always linear in space so we can accesses them in one sweep
11457 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
11458 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
11459 }
11460
11461 template<typename SENDTYPE, typename RECVTYPE>
11462 void AMPI_Scatter_d(HandleBase* handle, AdjointInterface* adjointInterface) {
11464 (handle);
11465 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11466 (void)adType;
11467
11468 h->recvbufAdjoints = nullptr;
11469 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11470 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11471 h->sendbufAdjoints = nullptr;
11472 if(h->root == getCommRank(h->comm)) {
11473 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11474 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11475 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11476 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11477
11478 }
11479
11482
11483 if(h->root == getCommRank(h->comm)) {
11484 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11485 }
11486 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11487 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11488 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11489 }
11490
11491 template<typename SENDTYPE, typename RECVTYPE>
11492 void AMPI_Scatter_b(HandleBase* handle, AdjointInterface* adjointInterface) {
11494 (handle);
11495 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11496 (void)adType;
11497
11498 h->recvbufAdjoints = nullptr;
11499 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11500 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11501 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11502 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11503
11504 if(adType->isOldPrimalsRequired()) {
11505 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11506 }
11507 h->sendbufAdjoints = nullptr;
11508 if(h->root == getCommRank(h->comm)) {
11509 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11510 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11511 }
11512
11515
11516 if(h->root == getCommRank(h->comm)) {
11517 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11518 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11519 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11520 }
11521 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11522 }
11523
11524 template<typename SENDTYPE, typename RECVTYPE>
11525 int AMPI_Scatter(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
11526 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm) {
11527 int rStatus;
11528 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
11529
11530 if(!adType->isActiveType()) {
11531 // call the regular function if the type is not active
11532 rStatus = MPI_Scatter(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
11533 comm);
11534 } else {
11535
11536 // the type is an AD type so handle the buffers
11538 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
11539 int sendbufElements = 0;
11540
11541 if(root == getCommRank(comm)) {
11542 // compute the total size of the buffer
11543 sendbufElements = sendcount * getCommSize(comm);
11544
11545 if(sendtype->isModifiedBufferRequired() ) {
11546 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
11547 } else {
11548 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
11549 }
11550 }
11551 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
11552 int recvbufElements = 0;
11553
11554 // compute the total size of the buffer
11555 if(AMPI_IN_PLACE != recvbuf) {
11556 recvbufElements = recvcount;
11557 } else {
11558 recvbufElements = sendcount;
11559 }
11560
11561 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11562 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
11563 } else {
11564 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
11565 }
11566
11567 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
11568 if(adType->isHandleRequired()) {
11570 }
11571 adType->startAssembly(h);
11572 if(root == getCommRank(comm)) {
11573 if(sendtype->isModifiedBufferRequired()) {
11574 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
11575 }
11576 }
11577
11578 if(nullptr != h) {
11579 // gather the information for the reverse sweep
11580
11581 // create the index buffers
11582 if(root == getCommRank(comm)) {
11583 h->sendbufCount = sendtype->computeActiveElements(sendcount);
11584 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
11585 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
11586 }
11587 if(AMPI_IN_PLACE != recvbuf) {
11588 h->recvbufCount = recvtype->computeActiveElements(recvcount);
11589 } else {
11590 h->recvbufCount = sendtype->computeActiveElements(sendcount);
11591 }
11592 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
11593 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
11594
11595
11596 // extract the old primal values from the recv buffer if the AD tool
11597 // needs the primal values reset
11598 if(adType->isOldPrimalsRequired()) {
11599 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
11600 if(AMPI_IN_PLACE != recvbuf) {
11601 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
11602 } else {
11603 sendtype->getValues(sendbuf, sendcount * getCommRank(comm), h->recvbufOldPrimals, 0, sendcount);
11604 }
11605 }
11606
11607
11608 if(root == getCommRank(comm)) {
11609 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
11610 }
11611
11612 if(AMPI_IN_PLACE != recvbuf) {
11613 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
11614 } else {
11615 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
11616 0, sendcount);
11617 }
11618
11619 // pack all the variables in the handle
11623 h->sendcount = sendcount;
11624 h->sendtype = sendtype;
11625 h->recvcount = recvcount;
11626 h->recvtype = recvtype;
11627 h->root = root;
11628 h->comm = comm;
11629 }
11630
11631 if(!recvtype->isModifiedBufferRequired()) {
11632 if(AMPI_IN_PLACE != recvbuf) {
11633 recvtype->clearIndices(recvbuf, 0, recvcount);
11634 } else {
11635 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), sendcount);
11636 }
11637 }
11638
11639 rStatus = MPI_Scatter(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
11640 recvtype->getModifiedMpiType(), root, comm);
11641 adType->addToolAction(h);
11642
11643 if(recvtype->isModifiedBufferRequired()) {
11644 if(AMPI_IN_PLACE != recvbuf) {
11645 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
11646 } else {
11647 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm),
11648 sendbufMod, sendcount * getCommRank(comm), sendcount);
11649 }
11650 }
11651
11652 if(nullptr != h) {
11653 // handle the recv buffers
11654 if(AMPI_IN_PLACE != recvbuf) {
11655 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
11656 } else {
11657 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
11658 h->recvbufOldPrimals, 0, sendcount);
11659 }
11660 }
11661
11662 adType->stopAssembly(h);
11663
11664 if(root == getCommRank(comm)) {
11665 if(sendtype->isModifiedBufferRequired() ) {
11666 sendtype->deleteModifiedTypeBuffer(sendbufMod);
11667 }
11668 }
11669 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11670 recvtype->deleteModifiedTypeBuffer(recvbufMod);
11671 }
11672
11673 // handle is deleted by the AD tool
11674 }
11675
11676 return rStatus;
11677 }
11678
11679#endif
11680#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
11681 template<typename SENDTYPE, typename RECVTYPE>
11684 typename SENDTYPE::IndexType* sendbufIndices;
11685 typename SENDTYPE::PrimalType* sendbufPrimals;
11686 /* required for async */ void* sendbufAdjoints;
11688 /* required for async */ int* sendbufCountVec;
11689 /* required for async */ int* sendbufDisplsVec;
11690 const int* sendcounts;
11691 const int* displs;
11692 SENDTYPE* sendtype;
11694 typename RECVTYPE::IndexType* recvbufIndices;
11695 typename RECVTYPE::PrimalType* recvbufPrimals;
11696 typename RECVTYPE::PrimalType* recvbufOldPrimals;
11697 /* required for async */ void* recvbufAdjoints;
11701 RECVTYPE* recvtype;
11702 int root;
11704
11706 if(nullptr != sendbufIndices) {
11707 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
11708 sendbufIndices = nullptr;
11709 }
11710 if(nullptr != sendbufPrimals) {
11711 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
11712 sendbufPrimals = nullptr;
11713 }
11714 if(nullptr != sendbufCount) {
11715 delete [] sendbufCount;
11716 sendbufCount = nullptr;
11717 }
11718 if(nullptr != recvbufIndices) {
11719 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
11720 recvbufIndices = nullptr;
11721 }
11722 if(nullptr != recvbufPrimals) {
11723 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
11724 recvbufPrimals = nullptr;
11725 }
11726 if(nullptr != recvbufOldPrimals) {
11727 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
11728 recvbufOldPrimals = nullptr;
11729 }
11730 }
11731 };
11732
11733
11734 template<typename SENDTYPE, typename RECVTYPE>
11735 void AMPI_Scatterv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
11737 (handle);
11738 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11739 (void)adType;
11740
11741 h->recvbufAdjoints = nullptr;
11742 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11743 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
11744 h->sendbufAdjoints = nullptr;
11745 if(h->root == getCommRank(h->comm)) {
11747 adjointInterface->getVectorSize());
11748 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
11749 // Primal buffers are always linear in space so we can accesses them in one sweep
11750 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
11751
11752 }
11753
11755 h->displs, h->sendtype, h->recvbufPrimals, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
11756
11757 if(h->root == getCommRank(h->comm)) {
11758 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
11759 delete [] h->sendbufCountVec;
11760 delete [] h->sendbufDisplsVec;
11761 }
11762 if(adType->isOldPrimalsRequired()) {
11763 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11764 }
11765 // Primal buffers are always linear in space so we can accesses them in one sweep
11766 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
11767 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
11768 }
11769
11770 template<typename SENDTYPE, typename RECVTYPE>
11771 void AMPI_Scatterv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
11773 (handle);
11774 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11775 (void)adType;
11776
11777 h->recvbufAdjoints = nullptr;
11778 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11779 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11780 h->sendbufAdjoints = nullptr;
11781 if(h->root == getCommRank(h->comm)) {
11783 adjointInterface->getVectorSize());
11784 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11785 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11786 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11787
11788 }
11789
11791 h->displs, h->sendtype, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
11792
11793 if(h->root == getCommRank(h->comm)) {
11794 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11795 delete [] h->sendbufCountVec;
11796 delete [] h->sendbufDisplsVec;
11797 }
11798 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11799 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11800 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11801 }
11802
11803 template<typename SENDTYPE, typename RECVTYPE>
11804 void AMPI_Scatterv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
11806 (handle);
11807 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11808 (void)adType;
11809
11810 h->recvbufAdjoints = nullptr;
11811 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11812 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11813 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11814 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11815
11816 if(adType->isOldPrimalsRequired()) {
11817 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11818 }
11819 h->sendbufAdjoints = nullptr;
11820 if(h->root == getCommRank(h->comm)) {
11822 adjointInterface->getVectorSize());
11823 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11824 }
11825
11827 h->displs, h->sendtype, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
11828
11829 if(h->root == getCommRank(h->comm)) {
11830 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11831 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11832 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11833 delete [] h->sendbufCountVec;
11834 delete [] h->sendbufDisplsVec;
11835 }
11836 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11837 }
11838
11839 template<typename SENDTYPE, typename RECVTYPE>
11840 int AMPI_Scatterv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, const int* sendcounts, const int* displs,
11841 SENDTYPE* sendtype, typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm) {
11842 int rStatus;
11843 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
11844
11845 if(!adType->isActiveType()) {
11846 // call the regular function if the type is not active
11847 rStatus = MPI_Scatterv(sendbuf, sendcounts, displs, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(),
11848 root, comm);
11849 } else {
11850
11851 // the type is an AD type so handle the buffers
11853 MEDI_OPTIONAL_CONST int* displsMod = displs;
11854 int displsTotalSize = 0;
11855 if(nullptr != displs) {
11856 displsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
11857 if(recvtype->isModifiedBufferRequired()) {
11858 displsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
11859 }
11860 }
11861 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
11862 int sendbufElements = 0;
11863
11864 if(root == getCommRank(comm)) {
11865 // compute the total size of the buffer
11866 sendbufElements = displsTotalSize;
11867
11868 if(sendtype->isModifiedBufferRequired() ) {
11869 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
11870 } else {
11871 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
11872 }
11873 }
11874 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
11875 int recvbufElements = 0;
11876
11877 // compute the total size of the buffer
11878 if(AMPI_IN_PLACE != recvbuf) {
11879 recvbufElements = recvcount;
11880 } else {
11881 recvbufElements = sendcounts[getCommRank(comm)];
11882 }
11883
11884 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11885 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
11886 } else {
11887 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
11888 }
11889
11890 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
11891 if(adType->isHandleRequired()) {
11893 }
11894 adType->startAssembly(h);
11895 if(root == getCommRank(comm)) {
11896 if(sendtype->isModifiedBufferRequired()) {
11897 for(int i = 0; i < getCommSize(comm); ++i) {
11898 sendtype->copyIntoModifiedBuffer(sendbuf, displs[i], sendbufMod, displsMod[i], sendcounts[i]);
11899 }
11900 }
11901 }
11902
11903 if(nullptr != h) {
11904 // gather the information for the reverse sweep
11905
11906 // create the index buffers
11907 if(root == getCommRank(comm)) {
11908 createLinearIndexCounts(h->sendbufCount, sendcounts, displs, getCommSize(comm), sendtype);
11909 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
11910 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
11911 }
11912 if(AMPI_IN_PLACE != recvbuf) {
11913 h->recvbufCount = recvtype->computeActiveElements(recvcount);
11914 } else {
11915 h->recvbufCount = sendtype->computeActiveElements(displs[getCommRank(comm)] + sendcounts[getCommRank(
11916 comm)]) - sendtype->computeActiveElements(displs[getCommRank(comm)]);
11917 }
11918 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
11919 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
11920
11921
11922 // extract the old primal values from the recv buffer if the AD tool
11923 // needs the primal values reset
11924 if(adType->isOldPrimalsRequired()) {
11925 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
11926 if(AMPI_IN_PLACE != recvbuf) {
11927 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
11928 } else {
11929 {
11930 const int rank = getCommRank(comm);
11931 sendtype->getValues(sendbuf, displs[rank], h->recvbufOldPrimals, 0, sendcounts[rank]);
11932 }
11933 }
11934 }
11935
11936
11937 if(root == getCommRank(comm)) {
11938 for(int i = 0; i < getCommSize(comm); ++i) {
11939 sendtype->getIndices(sendbuf, displs[i], h->sendbufIndices, displsMod[i], sendcounts[i]);
11940 }
11941 }
11942
11943 if(AMPI_IN_PLACE != recvbuf) {
11944 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
11945 } else {
11946 {
11947 const int rank = getCommRank(comm);
11948 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices, 0,
11949 sendcounts[rank]);
11950 }
11951 }
11952
11953 // pack all the variables in the handle
11957 h->sendcounts = sendcounts;
11958 h->displs = displs;
11959 h->sendtype = sendtype;
11960 h->recvcount = recvcount;
11961 h->recvtype = recvtype;
11962 h->root = root;
11963 h->comm = comm;
11964 }
11965
11966 if(!recvtype->isModifiedBufferRequired()) {
11967 if(AMPI_IN_PLACE != recvbuf) {
11968 recvtype->clearIndices(recvbuf, 0, recvcount);
11969 } else {
11970 {
11971 const int rank = getCommRank(comm);
11972 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendcounts[rank]);
11973 }
11974 }
11975 }
11976
11977 rStatus = MPI_Scatterv(sendbufMod, sendcounts, displsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
11978 recvtype->getModifiedMpiType(), root, comm);
11979 adType->addToolAction(h);
11980
11981 if(recvtype->isModifiedBufferRequired()) {
11982 if(AMPI_IN_PLACE != recvbuf) {
11983 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
11984 } else {
11985 {
11986 const int rank = getCommRank(comm);
11987 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendbufMod,
11988 displsMod[rank], sendcounts[rank]);
11989 }
11990 }
11991 }
11992
11993 if(nullptr != h) {
11994 // handle the recv buffers
11995 if(AMPI_IN_PLACE != recvbuf) {
11996 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
11997 } else {
11998 {
11999 const int rank = getCommRank(comm);
12000 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices,
12001 h->recvbufOldPrimals, 0, sendcounts[rank]);
12002 }
12003 }
12004 }
12005
12006 adType->stopAssembly(h);
12007 if(recvtype->isModifiedBufferRequired()) {
12008 delete [] displsMod;
12009 }
12010
12011 if(root == getCommRank(comm)) {
12012 if(sendtype->isModifiedBufferRequired() ) {
12013 sendtype->deleteModifiedTypeBuffer(sendbufMod);
12014 }
12015 }
12016 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
12017 recvtype->deleteModifiedTypeBuffer(recvbufMod);
12018 }
12019
12020 // handle is deleted by the AD tool
12021 }
12022
12023 return rStatus;
12024 }
12025
12026#endif
12027
12028#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12029 inline int AMPI_Buffer_attach(void* buffer, int size) {
12030 return MPI_Buffer_attach(buffer, size);
12031 }
12032
12033#endif
12034#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12035 inline int AMPI_Buffer_detach(void* buffer_addr, int* size) {
12036 return MPI_Buffer_detach(buffer_addr, size);
12037 }
12038
12039#endif
12040#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12041 inline int AMPI_Cancel(AMPI_Request* request) {
12042 return MPI_Cancel(&request->request);
12043 }
12044
12045#endif
12046#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12047 template<typename DATATYPE>
12048 inline int AMPI_Get_count(MEDI_OPTIONAL_CONST AMPI_Status* status, DATATYPE* datatype, int* count) {
12049 return MPI_Get_count(status, datatype->getModifiedMpiType(), count);
12050 }
12051
12052#endif
12053#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12054 inline int AMPI_Iprobe(int source, int tag, AMPI_Comm comm, int* flag, AMPI_Status* status) {
12055 return MPI_Iprobe(source, tag, comm, flag, status);
12056 }
12057
12058#endif
12059#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12060 inline int AMPI_Probe(int source, int tag, AMPI_Comm comm, AMPI_Status* status) {
12061 return MPI_Probe(source, tag, comm, status);
12062 }
12063
12064#endif
12065#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12066 inline int AMPI_Request_get_status(AMPI_Request request, int* flag, AMPI_Status* status) {
12067 return MPI_Request_get_status(request.request, flag, status);
12068 }
12069
12070#endif
12071#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12072 inline int AMPI_Test_cancelled(MEDI_OPTIONAL_CONST AMPI_Status* status, int* flag) {
12073 return MPI_Test_cancelled(status, flag);
12074 }
12075
12076#endif
12077#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
12078 inline MPI_Aint AMPI_Aint_add(AMPI_Aint base, AMPI_Aint disp) {
12079 return MPI_Aint_add(base, disp);
12080 }
12081
12082#endif
12083#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
12084 inline MPI_Aint AMPI_Aint_diff(AMPI_Aint addr1, AMPI_Aint addr2) {
12085 return MPI_Aint_diff(addr1, addr2);
12086 }
12087
12088#endif
12089#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12090 inline int AMPI_Get_address(MEDI_OPTIONAL_CONST void* location, AMPI_Aint* address) {
12091 return MPI_Get_address(location, address);
12092 }
12093
12094#endif
12095#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12096 template<typename DATATYPE>
12097 inline int AMPI_Get_elements(const AMPI_Status* status, DATATYPE* datatype, int* count) {
12098 return MPI_Get_elements(status, datatype->getModifiedMpiType(), count);
12099 }
12100
12101#endif
12102#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12103 template<typename DATATYPE>
12104 inline int AMPI_Get_elements_x(const AMPI_Status* status, DATATYPE* datatype, AMPI_Count* count) {
12105 return MPI_Get_elements_x(status, datatype->getModifiedMpiType(), count);
12106 }
12107
12108#endif
12109#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12110 template<typename DATATYPE>
12111 inline int AMPI_Type_get_contents(DATATYPE* datatype, int max_integers, int max_addresses, int max_datatypes,
12112 int* array_of_integers, AMPI_Aint* array_of_addresses, AMPI_Datatype* array_of_datatypes) {
12113 return MPI_Type_get_contents(datatype->getModifiedMpiType(), max_integers, max_addresses, max_datatypes,
12114 array_of_integers, array_of_addresses, array_of_datatypes);
12115 }
12116
12117#endif
12118#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12119 template<typename DATATYPE>
12120 inline int AMPI_Type_get_envelope(DATATYPE* datatype, int* num_integers, int* num_addresses, int* num_datatypes,
12121 int* combiner) {
12122 return MPI_Type_get_envelope(datatype->getModifiedMpiType(), num_integers, num_addresses, num_datatypes, combiner);
12123 }
12124
12125#endif
12126#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12127 template<typename DATATYPE>
12128 inline int AMPI_Type_get_extent(DATATYPE* datatype, AMPI_Aint* lb, AMPI_Aint* extent) {
12129 return MPI_Type_get_extent(datatype->getModifiedMpiType(), lb, extent);
12130 }
12131
12132#endif
12133#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12134 template<typename DATATYPE>
12135 inline int AMPI_Type_get_extent_x(DATATYPE* datatype, AMPI_Count* lb, AMPI_Count* extent) {
12136 return MPI_Type_get_extent_x(datatype->getModifiedMpiType(), lb, extent);
12137 }
12138
12139#endif
12140#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12141 template<typename DATATYPE>
12142 inline int AMPI_Type_get_true_extent(DATATYPE* datatype, AMPI_Aint* true_lb, AMPI_Aint* true_extent) {
12143 return MPI_Type_get_true_extent(datatype->getModifiedMpiType(), true_lb, true_extent);
12144 }
12145
12146#endif
12147#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12148 template<typename DATATYPE>
12149 inline int AMPI_Type_get_true_extent_x(DATATYPE* datatype, AMPI_Count* true_lb, AMPI_Count* true_extent) {
12150 return MPI_Type_get_true_extent_x(datatype->getModifiedMpiType(), true_lb, true_extent);
12151 }
12152
12153#endif
12154#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12155 template<typename DATATYPE>
12156 inline int AMPI_Type_size(DATATYPE* datatype, int* size) {
12157 return MPI_Type_size(datatype->getModifiedMpiType(), size);
12158 }
12159
12160#endif
12161#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12162 template<typename DATATYPE>
12163 inline int AMPI_Type_size_x(DATATYPE* datatype, AMPI_Count* size) {
12164 return MPI_Type_size_x(datatype->getModifiedMpiType(), size);
12165 }
12166
12167#endif
12168#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12169 inline int AMPI_Barrier(AMPI_Comm comm) {
12170 return MPI_Barrier(comm);
12171 }
12172
12173#endif
12174#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12175 inline int AMPI_Op_commutative(AMPI_Op op, int* commute) {
12176 AMPI_Op convOp = op;
12177 (void)convOp;
12178 return MPI_Op_commutative(convOp.modifiedPrimalFunction, commute);
12179 }
12180
12181#endif
12182#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12183 inline int AMPI_Comm_compare(AMPI_Comm comm1, AMPI_Comm comm2, int* result) {
12184 return MPI_Comm_compare(comm1, comm2, result);
12185 }
12186
12187#endif
12188#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12189 inline int AMPI_Comm_create(AMPI_Comm comm, AMPI_Group group, AMPI_Comm* newcomm) {
12190 return MPI_Comm_create(comm, group, newcomm);
12191 }
12192
12193#endif
12194#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12195 inline int AMPI_Comm_create_group(AMPI_Comm comm, AMPI_Group group, int tag, AMPI_Comm* newcomm) {
12196 return MPI_Comm_create_group(comm, group, tag, newcomm);
12197 }
12198
12199#endif
12200#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12202 AMPI_Comm_delete_attr_function* comm_delete_attr_fn, int* comm_keyval, void* extra_state) {
12203 return MPI_Comm_create_keyval(comm_copy_attr_fn, comm_delete_attr_fn, comm_keyval, extra_state);
12204 }
12205
12206#endif
12207#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12208 inline int AMPI_Comm_delete_attr(AMPI_Comm comm, int comm_keyval) {
12209 return MPI_Comm_delete_attr(comm, comm_keyval);
12210 }
12211
12212#endif
12213#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12214 inline int AMPI_Comm_dup(AMPI_Comm comm, AMPI_Comm* newcomm) {
12215 return MPI_Comm_dup(comm, newcomm);
12216 }
12217
12218#endif
12219#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12220 inline int AMPI_Comm_dup_with_info(AMPI_Comm comm, AMPI_Info info, AMPI_Comm* newcomm) {
12221 return MPI_Comm_dup_with_info(comm, info, newcomm);
12222 }
12223
12224#endif
12225#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12226 inline int AMPI_Comm_free(AMPI_Comm* comm) {
12227 return MPI_Comm_free(comm);
12228 }
12229
12230#endif
12231#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12232 inline int AMPI_Comm_free_keyval(int* comm_keyval) {
12233 return MPI_Comm_free_keyval(comm_keyval);
12234 }
12235
12236#endif
12237#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12238 inline int AMPI_Comm_get_attr(AMPI_Comm comm, int comm_keyval, void* attribute_val, int* flag) {
12239 return MPI_Comm_get_attr(comm, comm_keyval, attribute_val, flag);
12240 }
12241
12242#endif
12243#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12244 inline int AMPI_Comm_get_info(AMPI_Comm comm, AMPI_Info* info_used) {
12245 return MPI_Comm_get_info(comm, info_used);
12246 }
12247
12248#endif
12249#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12250 inline int AMPI_Comm_get_name(AMPI_Comm comm, char* comm_name, int* resultlen) {
12251 return MPI_Comm_get_name(comm, comm_name, resultlen);
12252 }
12253
12254#endif
12255#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12256 inline int AMPI_Comm_group(AMPI_Comm comm, AMPI_Group* group) {
12257 return MPI_Comm_group(comm, group);
12258 }
12259
12260#endif
12261#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12262 inline int AMPI_Comm_idup(AMPI_Comm comm, AMPI_Comm* newcomm, AMPI_Request* request) {
12263 return MPI_Comm_idup(comm, newcomm, &request->request);
12264 }
12265
12266#endif
12267#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12268 inline int AMPI_Comm_rank(AMPI_Comm comm, int* rank) {
12269 return MPI_Comm_rank(comm, rank);
12270 }
12271
12272#endif
12273#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12275 return MPI_Comm_remote_group(comm, group);
12276 }
12277
12278#endif
12279#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12280 inline int AMPI_Comm_remote_size(AMPI_Comm comm, int* size) {
12281 return MPI_Comm_remote_size(comm, size);
12282 }
12283
12284#endif
12285#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12286 inline int AMPI_Comm_set_attr(AMPI_Comm comm, int comm_keyval, void* attribute_val) {
12287 return MPI_Comm_set_attr(comm, comm_keyval, attribute_val);
12288 }
12289
12290#endif
12291#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12292 inline int AMPI_Comm_set_info(AMPI_Comm comm, AMPI_Info info) {
12293 return MPI_Comm_set_info(comm, info);
12294 }
12295
12296#endif
12297#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12298 inline int AMPI_Comm_set_name(AMPI_Comm comm, MEDI_OPTIONAL_CONST char* comm_name) {
12299 return MPI_Comm_set_name(comm, comm_name);
12300 }
12301
12302#endif
12303#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12304 inline int AMPI_Comm_size(AMPI_Comm comm, int* size) {
12305 return MPI_Comm_size(comm, size);
12306 }
12307
12308#endif
12309#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12310 inline int AMPI_Comm_split(AMPI_Comm comm, int color, int key, AMPI_Comm* newcomm) {
12311 return MPI_Comm_split(comm, color, key, newcomm);
12312 }
12313
12314#endif
12315#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12316 inline int AMPI_Comm_split_type(AMPI_Comm comm, int split_type, int key, AMPI_Info info, AMPI_Comm* newcomm) {
12317 return MPI_Comm_split_type(comm, split_type, key, info, newcomm);
12318 }
12319
12320#endif
12321#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12322 inline int AMPI_Comm_test_inter(AMPI_Comm comm, int* flag) {
12323 return MPI_Comm_test_inter(comm, flag);
12324 }
12325
12326#endif
12327#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12328 inline int AMPI_Group_compare(AMPI_Group group1, AMPI_Group group2, int* result) {
12329 return MPI_Group_compare(group1, group2, result);
12330 }
12331
12332#endif
12333#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12334 inline int AMPI_Group_difference(AMPI_Group group1, AMPI_Group group2, AMPI_Group* newgroup) {
12335 return MPI_Group_difference(group1, group2, newgroup);
12336 }
12337
12338#endif
12339#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12340 inline int AMPI_Group_excl(AMPI_Group group, int n, MEDI_OPTIONAL_CONST int* ranks, AMPI_Group* newgroup) {
12341 return MPI_Group_excl(group, n, ranks, newgroup);
12342 }
12343
12344#endif
12345#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12346 inline int AMPI_Group_free(AMPI_Group* group) {
12347 return MPI_Group_free(group);
12348 }
12349
12350#endif
12351#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12352 inline int AMPI_Group_incl(AMPI_Group group, int n, MEDI_OPTIONAL_CONST int* ranks, AMPI_Group* newgroup) {
12353 return MPI_Group_incl(group, n, ranks, newgroup);
12354 }
12355
12356#endif
12357#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12358 inline int AMPI_Group_intersection(AMPI_Group group1, AMPI_Group group2, AMPI_Group* newgroup) {
12359 return MPI_Group_intersection(group1, group2, newgroup);
12360 }
12361
12362#endif
12363#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12364 inline int AMPI_Group_range_excl(AMPI_Group group, int n, ::medi::common::Range* ranges, AMPI_Group* newgroup) {
12365 return MPI_Group_range_excl(group, n, ranges, newgroup);
12366 }
12367
12368#endif
12369#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12370 inline int AMPI_Group_range_incl(AMPI_Group group, int n, ::medi::common::Range* ranges, AMPI_Group* newgroup) {
12371 return MPI_Group_range_incl(group, n, ranges, newgroup);
12372 }
12373
12374#endif
12375#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12376 inline int AMPI_Group_rank(AMPI_Group group, int* rank) {
12377 return MPI_Group_rank(group, rank);
12378 }
12379
12380#endif
12381#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12382 inline int AMPI_Group_size(AMPI_Group group, int* size) {
12383 return MPI_Group_size(group, size);
12384 }
12385
12386#endif
12387#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12388 inline int AMPI_Group_translate_ranks(AMPI_Group group1, int n, MEDI_OPTIONAL_CONST int* ranks1, AMPI_Group group2,
12389 int* ranks2) {
12390 return MPI_Group_translate_ranks(group1, n, ranks1, group2, ranks2);
12391 }
12392
12393#endif
12394#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12395 inline int AMPI_Group_union(AMPI_Group group1, AMPI_Group group2, AMPI_Group* newgroup) {
12396 return MPI_Group_union(group1, group2, newgroup);
12397 }
12398
12399#endif
12400#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12401 inline int AMPI_Intercomm_create(AMPI_Comm local_comm, int local_leader, AMPI_Comm peer_comm, int remote_leader,
12402 int tag, AMPI_Comm* newintercomm) {
12403 return MPI_Intercomm_create(local_comm, local_leader, peer_comm, remote_leader, tag, newintercomm);
12404 }
12405
12406#endif
12407#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12408 inline int AMPI_Intercomm_merge(AMPI_Comm intercomm, int high, AMPI_Comm* newintracomm) {
12409 return MPI_Intercomm_merge(intercomm, high, newintracomm);
12410 }
12411
12412#endif
12413#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12415 AMPI_Type_delete_attr_function* type_delete_attr_fn, int* type_keyval, void* extra_state) {
12416 return MPI_Type_create_keyval(type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state);
12417 }
12418
12419#endif
12420#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12421 template<typename DATATYPE>
12422 inline int AMPI_Type_delete_attr(DATATYPE* datatype, int type_keyval) {
12423 return MPI_Type_delete_attr(datatype->getModifiedMpiType(), type_keyval);
12424 }
12425
12426#endif
12427#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12428 inline int AMPI_Type_free_keyval(int* type_keyval) {
12429 return MPI_Type_free_keyval(type_keyval);
12430 }
12431
12432#endif
12433#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12434 template<typename DATATYPE>
12435 inline int AMPI_Type_get_attr(DATATYPE* datatype, int type_keyval, void* attribute_val, int* flag) {
12436 return MPI_Type_get_attr(datatype->getModifiedMpiType(), type_keyval, attribute_val, flag);
12437 }
12438
12439#endif
12440#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12441 template<typename DATATYPE>
12442 inline int AMPI_Type_get_name(DATATYPE* datatype, char* type_name, int* resultlen) {
12443 return MPI_Type_get_name(datatype->getModifiedMpiType(), type_name, resultlen);
12444 }
12445
12446#endif
12447#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12448 template<typename DATATYPE>
12449 inline int AMPI_Type_set_attr(DATATYPE* datatype, int type_keyval, void* attribute_val) {
12450 return MPI_Type_set_attr(datatype->getModifiedMpiType(), type_keyval, attribute_val);
12451 }
12452
12453#endif
12454#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12455 template<typename DATATYPE>
12456 inline int AMPI_Type_set_name(DATATYPE* datatype, const char* type_name) {
12457 return MPI_Type_set_name(datatype->getModifiedMpiType(), type_name);
12458 }
12459
12460#endif
12461#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12463 AMPI_Win_delete_attr_function* win_delete_attr_fn, int* win_keyval, void* extra_state) {
12464 return MPI_Win_create_keyval(win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state);
12465 }
12466
12467#endif
12468#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12469 inline int AMPI_Win_delete_attr(AMPI_Win win, int win_keyval) {
12470 return MPI_Win_delete_attr(win, win_keyval);
12471 }
12472
12473#endif
12474#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12475 inline int AMPI_Win_free_keyval(int* win_keyval) {
12476 return MPI_Win_free_keyval(win_keyval);
12477 }
12478
12479#endif
12480#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12481 inline int AMPI_Win_get_attr(AMPI_Win win, int win_keyval, void* attribute_val, int* flag) {
12482 return MPI_Win_get_attr(win, win_keyval, attribute_val, flag);
12483 }
12484
12485#endif
12486#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12487 inline int AMPI_Win_get_name(AMPI_Win win, char* win_name, int* resultlen) {
12488 return MPI_Win_get_name(win, win_name, resultlen);
12489 }
12490
12491#endif
12492#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12493 inline int AMPI_Win_set_attr(AMPI_Win win, int win_keyval, void* attribute_val) {
12494 return MPI_Win_set_attr(win, win_keyval, attribute_val);
12495 }
12496
12497#endif
12498#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12499 inline int AMPI_Win_set_name(AMPI_Win win, MEDI_OPTIONAL_CONST char* win_name) {
12500 return MPI_Win_set_name(win, win_name);
12501 }
12502
12503#endif
12504#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12505 inline int AMPI_Cart_coords(AMPI_Comm comm, int rank, int maxdims, int* coords) {
12506 return MPI_Cart_coords(comm, rank, maxdims, coords);
12507 }
12508
12509#endif
12510#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12511 inline int AMPI_Cart_create(AMPI_Comm comm_old, int ndims, MEDI_OPTIONAL_CONST int* dims,
12512 MEDI_OPTIONAL_CONST int* periods, int reorder, AMPI_Comm* comm_cart) {
12513 return MPI_Cart_create(comm_old, ndims, dims, periods, reorder, comm_cart);
12514 }
12515
12516#endif
12517#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12518 inline int AMPI_Cart_get(AMPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
12519 return MPI_Cart_get(comm, maxdims, dims, periods, coords);
12520 }
12521
12522#endif
12523#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12524 inline int AMPI_Cart_map(AMPI_Comm comm, int ndims, MEDI_OPTIONAL_CONST int* dims, MEDI_OPTIONAL_CONST int* periods,
12525 int* newrank) {
12526 return MPI_Cart_map(comm, ndims, dims, periods, newrank);
12527 }
12528
12529#endif
12530#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12531 inline int AMPI_Cart_rank(AMPI_Comm comm, MEDI_OPTIONAL_CONST int* coords, int* rank) {
12532 return MPI_Cart_rank(comm, coords, rank);
12533 }
12534
12535#endif
12536#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12537 inline int AMPI_Cart_shift(AMPI_Comm comm, int direction, int disp, int* rank_source, int* rank_dest) {
12538 return MPI_Cart_shift(comm, direction, disp, rank_source, rank_dest);
12539 }
12540
12541#endif
12542#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12543 inline int AMPI_Cart_sub(AMPI_Comm comm, MEDI_OPTIONAL_CONST int* remain_dims, AMPI_Comm* newcomm) {
12544 return MPI_Cart_sub(comm, remain_dims, newcomm);
12545 }
12546
12547#endif
12548#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12549 inline int AMPI_Cartdim_get(AMPI_Comm comm, int* ndims) {
12550 return MPI_Cartdim_get(comm, ndims);
12551 }
12552
12553#endif
12554#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12555 inline int AMPI_Dims_create(int nnodes, int ndims, int* dims) {
12556 return MPI_Dims_create(nnodes, ndims, dims);
12557 }
12558
12559#endif
12560#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12561 inline int AMPI_Dist_graph_create(AMPI_Comm comm_old, int n, MEDI_OPTIONAL_CONST int* sources,
12562 MEDI_OPTIONAL_CONST int* degrees, MEDI_OPTIONAL_CONST int* destinations, MEDI_OPTIONAL_CONST int* weights,
12563 AMPI_Info info, int reorder, AMPI_Comm* comm_dist_graph) {
12564 return MPI_Dist_graph_create(comm_old, n, sources, degrees, destinations, weights, info, reorder, comm_dist_graph);
12565 }
12566
12567#endif
12568#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12569 inline int AMPI_Dist_graph_create_adjacent(AMPI_Comm comm_old, int indegree, MEDI_OPTIONAL_CONST int* sources,
12570 MEDI_OPTIONAL_CONST int* sourceweights, int outdegree, MEDI_OPTIONAL_CONST int* destinations,
12571 MEDI_OPTIONAL_CONST int* destweights, AMPI_Info info, int reorder, AMPI_Comm* comm_dist_graph) {
12572 return MPI_Dist_graph_create_adjacent(comm_old, indegree, sources, sourceweights, outdegree, destinations, destweights,
12573 info, reorder, comm_dist_graph);
12574 }
12575
12576#endif
12577#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12578 inline int AMPI_Dist_graph_neighbors(AMPI_Comm comm, int maxindegree, int* sources, int* sourceweights,
12579 int maxoutdegree, int* destinations, int* destweights) {
12580 return MPI_Dist_graph_neighbors(comm, maxindegree, sources, sourceweights, maxoutdegree, destinations, destweights);
12581 }
12582
12583#endif
12584#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12585 inline int AMPI_Dist_graph_neighbors_count(AMPI_Comm comm, int* indegree, int* outdegree, int* weighted) {
12586 return MPI_Dist_graph_neighbors_count(comm, indegree, outdegree, weighted);
12587 }
12588
12589#endif
12590#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12591 inline int AMPI_Graph_create(AMPI_Comm comm_old, int nnodes, MEDI_OPTIONAL_CONST int* index,
12592 MEDI_OPTIONAL_CONST int* edges, int reorder, AMPI_Comm* comm_graph) {
12593 return MPI_Graph_create(comm_old, nnodes, index, edges, reorder, comm_graph);
12594 }
12595
12596#endif
12597#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12598 inline int AMPI_Graph_get(AMPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
12599 return MPI_Graph_get(comm, maxindex, maxedges, index, edges);
12600 }
12601
12602#endif
12603#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12604 inline int AMPI_Graph_map(AMPI_Comm comm, int nnodes, MEDI_OPTIONAL_CONST int* index, MEDI_OPTIONAL_CONST int* edges,
12605 int* newrank) {
12606 return MPI_Graph_map(comm, nnodes, index, edges, newrank);
12607 }
12608
12609#endif
12610#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12611 inline int AMPI_Graph_neighbors(AMPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
12612 return MPI_Graph_neighbors(comm, rank, maxneighbors, neighbors);
12613 }
12614
12615#endif
12616#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12617 inline int AMPI_Graph_neighbors_count(AMPI_Comm comm, int rank, int* nneighbors) {
12618 return MPI_Graph_neighbors_count(comm, rank, nneighbors);
12619 }
12620
12621#endif
12622#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12623 inline int AMPI_Graphdims_get(AMPI_Comm comm, int* nnodes, int* nedges) {
12624 return MPI_Graphdims_get(comm, nnodes, nedges);
12625 }
12626
12627#endif
12628#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12629 inline int AMPI_Topo_test(AMPI_Comm comm, int* status) {
12630 return MPI_Topo_test(comm, status);
12631 }
12632
12633#endif
12634#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12635 inline double AMPI_Wtick() {
12636 return MPI_Wtick();
12637 }
12638
12639#endif
12640#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12641 inline double AMPI_Wtime() {
12642 return MPI_Wtime();
12643 }
12644
12645#endif
12646#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12647 inline int AMPI_Abort(AMPI_Comm comm, int errorcode) {
12648 return MPI_Abort(comm, errorcode);
12649 }
12650
12651#endif
12652#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12653 inline int AMPI_Add_error_class(int* errorclass) {
12654 return MPI_Add_error_class(errorclass);
12655 }
12656
12657#endif
12658#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12659 inline int AMPI_Add_error_code(int errorclass, int* errorcode) {
12660 return MPI_Add_error_code(errorclass, errorcode);
12661 }
12662
12663#endif
12664#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12665 inline int AMPI_Add_error_string(int errorcode, MEDI_OPTIONAL_CONST char* string) {
12666 return MPI_Add_error_string(errorcode, string);
12667 }
12668
12669#endif
12670#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12671 inline int AMPI_Alloc_mem(AMPI_Aint size, AMPI_Info info, void* baseptr) {
12672 return MPI_Alloc_mem(size, info, baseptr);
12673 }
12674
12675#endif
12676#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12677 inline int AMPI_Comm_call_errhandler(AMPI_Comm comm, int errorcode) {
12678 return MPI_Comm_call_errhandler(comm, errorcode);
12679 }
12680
12681#endif
12682#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12684 return MPI_Comm_create_errhandler(comm_errhandler_fn, errhandler);
12685 }
12686
12687#endif
12688#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_2_2
12689 inline int AMPI_Comm_create_errhandler(AMPI_Comm_errhandler_fn* comm_errhandler_fn, AMPI_Errhandler* errhandler) {
12690 return MPI_Comm_create_errhandler(comm_errhandler_fn, errhandler);
12691 }
12692
12693#endif
12694#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12696 return MPI_Comm_get_errhandler(comm, errhandler);
12697 }
12698
12699#endif
12700#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12702 return MPI_Comm_set_errhandler(comm, errhandler);
12703 }
12704
12705#endif
12706#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12707 inline int AMPI_Errhandler_free(AMPI_Errhandler* errhandler) {
12708 return MPI_Errhandler_free(errhandler);
12709 }
12710
12711#endif
12712#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12713 inline int AMPI_Error_class(int errorcode, int* errorclass) {
12714 return MPI_Error_class(errorcode, errorclass);
12715 }
12716
12717#endif
12718#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12719 inline int AMPI_Error_string(int errorcode, char* string, int* resultlen) {
12720 return MPI_Error_string(errorcode, string, resultlen);
12721 }
12722
12723#endif
12724#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12725 inline int AMPI_File_call_errhandler(AMPI_File fh, int errorcode) {
12726 return MPI_File_call_errhandler(fh, errorcode);
12727 }
12728
12729#endif
12730#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12732 return MPI_File_create_errhandler(file_errhandler_fn, errhandler);
12733 }
12734
12735#endif
12736#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_2_2
12737 inline int AMPI_File_create_errhandler(AMPI_File_errhandler_fn* file_errhandler_fn, AMPI_Errhandler* errhandler) {
12738 return MPI_File_create_errhandler(file_errhandler_fn, errhandler);
12739 }
12740
12741#endif
12742#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12744 return MPI_File_get_errhandler(file, errhandler);
12745 }
12746
12747#endif
12748#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12750 return MPI_File_set_errhandler(file, errhandler);
12751 }
12752
12753#endif
12754#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12755 inline int AMPI_Finalize() {
12756 return MPI_Finalize();
12757 }
12758
12759#endif
12760#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12761 inline int AMPI_Finalized(int* flag) {
12762 return MPI_Finalized(flag);
12763 }
12764
12765#endif
12766#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12767 inline int AMPI_Free_mem(void* base) {
12768 return MPI_Free_mem(base);
12769 }
12770
12771#endif
12772#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12773 inline int AMPI_Get_library_version(char* version, int* resultlen) {
12774 return MPI_Get_library_version(version, resultlen);
12775 }
12776
12777#endif
12778#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12779 inline int AMPI_Get_processor_name(char* name, int* resultlen) {
12780 return MPI_Get_processor_name(name, resultlen);
12781 }
12782
12783#endif
12784#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12785 inline int AMPI_Get_version(int* version, int* subversion) {
12786 return MPI_Get_version(version, subversion);
12787 }
12788
12789#endif
12790#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12791 inline int AMPI_Initialized(int* flag) {
12792 return MPI_Initialized(flag);
12793 }
12794
12795#endif
12796#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12797 inline int AMPI_Win_call_errhandler(AMPI_Win win, int errorcode) {
12798 return MPI_Win_call_errhandler(win, errorcode);
12799 }
12800
12801#endif
12802#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
12804 return MPI_Win_create_errhandler(win_errhandler_fn, errhandler);
12805 }
12806
12807#endif
12808#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_2_2
12809 inline int AMPI_Win_create_errhandler(AMPI_Win_errhandler_fn* win_errhandler_fn, AMPI_Errhandler* errhandler) {
12810 return MPI_Win_create_errhandler(win_errhandler_fn, errhandler);
12811 }
12812
12813#endif
12814#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12815 inline int AMPI_Win_get_errhandler(AMPI_Win win, AMPI_Errhandler* errhandler) {
12816 return MPI_Win_get_errhandler(win, errhandler);
12817 }
12818
12819#endif
12820#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12822 return MPI_Win_set_errhandler(win, errhandler);
12823 }
12824
12825#endif
12826#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12827 inline int AMPI_Info_create(AMPI_Info* info) {
12828 return MPI_Info_create(info);
12829 }
12830
12831#endif
12832#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12833 inline int AMPI_Info_delete(AMPI_Info info, MEDI_OPTIONAL_CONST char* key) {
12834 return MPI_Info_delete(info, key);
12835 }
12836
12837#endif
12838#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12839 inline int AMPI_Info_dup(AMPI_Info info, AMPI_Info* newinfo) {
12840 return MPI_Info_dup(info, newinfo);
12841 }
12842
12843#endif
12844#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12845 inline int AMPI_Info_free(AMPI_Info* info) {
12846 return MPI_Info_free(info);
12847 }
12848
12849#endif
12850#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12851 inline int AMPI_Info_get(AMPI_Info info, MEDI_OPTIONAL_CONST char* key, int valuelen, char* value, int* flag) {
12852 return MPI_Info_get(info, key, valuelen, value, flag);
12853 }
12854
12855#endif
12856#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12857 inline int AMPI_Info_get_nkeys(AMPI_Info info, int* nkeys) {
12858 return MPI_Info_get_nkeys(info, nkeys);
12859 }
12860
12861#endif
12862#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12863 inline int AMPI_Info_get_nthkey(AMPI_Info info, int n, char* key) {
12864 return MPI_Info_get_nthkey(info, n, key);
12865 }
12866
12867#endif
12868#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12869 inline int AMPI_Info_get_valuelen(AMPI_Info info, MEDI_OPTIONAL_CONST char* key, int* valuelen, int* flag) {
12870 return MPI_Info_get_valuelen(info, key, valuelen, flag);
12871 }
12872
12873#endif
12874#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12875 inline int AMPI_Info_set(AMPI_Info info, MEDI_OPTIONAL_CONST char* key, MEDI_OPTIONAL_CONST char* value) {
12876 return MPI_Info_set(info, key, value);
12877 }
12878
12879#endif
12880#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12881 inline int AMPI_Close_port(MEDI_OPTIONAL_CONST char* port_name) {
12882 return MPI_Close_port(port_name);
12883 }
12884
12885#endif
12886#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12887 inline int AMPI_Comm_accept(MEDI_OPTIONAL_CONST char* port_name, AMPI_Info info, int root, AMPI_Comm comm,
12888 AMPI_Comm* newcomm) {
12889 return MPI_Comm_accept(port_name, info, root, comm, newcomm);
12890 }
12891
12892#endif
12893#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12894 inline int AMPI_Comm_connect(MEDI_OPTIONAL_CONST char* port_name, AMPI_Info info, int root, AMPI_Comm comm,
12895 AMPI_Comm* newcomm) {
12896 return MPI_Comm_connect(port_name, info, root, comm, newcomm);
12897 }
12898
12899#endif
12900#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12902 return MPI_Comm_disconnect(comm);
12903 }
12904
12905#endif
12906#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12907 inline int AMPI_Comm_get_parent(AMPI_Comm* parent) {
12908 return MPI_Comm_get_parent(parent);
12909 }
12910
12911#endif
12912#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12913 inline int AMPI_Comm_join(int fd, AMPI_Comm* intercomm) {
12914 return MPI_Comm_join(fd, intercomm);
12915 }
12916
12917#endif
12918#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12919 inline int AMPI_Comm_spawn(MEDI_OPTIONAL_CONST char* command, char** argv, int maxprocs, AMPI_Info info, int root,
12920 AMPI_Comm comm, AMPI_Comm* intercomm, int* array_of_errcodes) {
12921 return MPI_Comm_spawn(command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes);
12922 }
12923
12924#endif
12925#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12926 inline int AMPI_Comm_spawn_multiple(int count, char** array_of_commands, char*** array_of_argv,
12927 MEDI_OPTIONAL_CONST int* array_of_maxprocs, MEDI_OPTIONAL_CONST AMPI_Info* array_of_info, int root, AMPI_Comm comm,
12928 AMPI_Comm* intercomm, int* array_of_errcodes) {
12929 return MPI_Comm_spawn_multiple(count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm,
12930 intercomm, array_of_errcodes);
12931 }
12932
12933#endif
12934#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12935 inline int AMPI_Lookup_name(MEDI_OPTIONAL_CONST char* service_name, AMPI_Info info, char* port_name) {
12936 return MPI_Lookup_name(service_name, info, port_name);
12937 }
12938
12939#endif
12940#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12941 inline int AMPI_Open_port(AMPI_Info info, char* port_name) {
12942 return MPI_Open_port(info, port_name);
12943 }
12944
12945#endif
12946#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12947 inline int AMPI_Publish_name(MEDI_OPTIONAL_CONST char* service_name, AMPI_Info info,
12948 MEDI_OPTIONAL_CONST char* port_name) {
12949 return MPI_Publish_name(service_name, info, port_name);
12950 }
12951
12952#endif
12953#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12954 inline int AMPI_Unpublish_name(MEDI_OPTIONAL_CONST char* service_name, AMPI_Info info,
12955 MEDI_OPTIONAL_CONST char* port_name) {
12956 return MPI_Unpublish_name(service_name, info, port_name);
12957 }
12958
12959#endif
12960#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12962 return MPI_Grequest_complete(request.request);
12963 }
12964
12965#endif
12966#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12968 AMPI_Grequest_cancel_function* cancel_fn, void* extra_state, AMPI_Request* request) {
12969 return MPI_Grequest_start(query_fn, free_fn, cancel_fn, extra_state, &request->request);
12970 }
12971
12972#endif
12973#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12974 inline int AMPI_Is_thread_main(int* flag) {
12975 return MPI_Is_thread_main(flag);
12976 }
12977
12978#endif
12979#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12980 inline int AMPI_Query_thread(int* provided) {
12981 return MPI_Query_thread(provided);
12982 }
12983
12984#endif
12985#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12986 inline int AMPI_Status_set_cancelled(AMPI_Status* status, int flag) {
12987 return MPI_Status_set_cancelled(status, flag);
12988 }
12989
12990#endif
12991#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12992 template<typename DATATYPE>
12993 inline int AMPI_Status_set_elements(AMPI_Status* status, DATATYPE* datatype, int count) {
12994 return MPI_Status_set_elements(status, datatype->getModifiedMpiType(), count);
12995 }
12996
12997#endif
12998#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12999 template<typename DATATYPE>
13000 inline int AMPI_Status_set_elements_x(AMPI_Status* status, DATATYPE* datatype, AMPI_Count count) {
13001 return MPI_Status_set_elements_x(status, datatype->getModifiedMpiType(), count);
13002 }
13003
13004#endif
13005#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13006 inline int AMPI_File_close(AMPI_File* fh) {
13007 return MPI_File_close(fh);
13008 }
13009
13010#endif
13011#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13012 inline int AMPI_File_delete(MEDI_OPTIONAL_CONST char* filename, AMPI_Info info) {
13013 return MPI_File_delete(filename, info);
13014 }
13015
13016#endif
13017#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13018 inline int AMPI_File_get_amode(AMPI_File fh, int* amode) {
13019 return MPI_File_get_amode(fh, amode);
13020 }
13021
13022#endif
13023#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13024 inline int AMPI_File_get_atomicity(AMPI_File fh, int* flag) {
13025 return MPI_File_get_atomicity(fh, flag);
13026 }
13027
13028#endif
13029#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13031 return MPI_File_get_byte_offset(fh, offset, disp);
13032 }
13033
13034#endif
13035#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13037 return MPI_File_get_group(fh, group);
13038 }
13039
13040#endif
13041#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13042 inline int AMPI_File_get_info(AMPI_File fh, AMPI_Info* info_used) {
13043 return MPI_File_get_info(fh, info_used);
13044 }
13045
13046#endif
13047#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13049 return MPI_File_get_position(fh, offset);
13050 }
13051
13052#endif
13053#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13055 return MPI_File_get_position_shared(fh, offset);
13056 }
13057
13058#endif
13059#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13061 return MPI_File_get_size(fh, size);
13062 }
13063
13064#endif
13065#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13066 template<typename DATATYPE>
13067 inline int AMPI_File_get_type_extent(AMPI_File fh, DATATYPE* datatype, AMPI_Aint* extent) {
13068 return MPI_File_get_type_extent(fh, datatype->getModifiedMpiType(), extent);
13069 }
13070
13071#endif
13072#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13073 template<typename ETYPE, typename FILETYPE>
13074 inline int AMPI_File_get_view(AMPI_File fh, AMPI_Offset* disp, ETYPE* etype, FILETYPE* filetype, char* datarep) {
13075 return MPI_File_get_view(fh, disp, etype->getModifiedMpiType(), filetype->getModifiedMpiType(), datarep);
13076 }
13077
13078#endif
13079#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13080 template<typename DATATYPE>
13081 inline int AMPI_File_iread(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13082 return MPI_File_iread(fh, buf, count, datatype->getModifiedMpiType(), request);
13083 }
13084
13085#endif
13086#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13087 template<typename DATATYPE>
13088 inline int AMPI_File_iread_all(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13089 return MPI_File_iread_all(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13090 }
13091
13092#endif
13093#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13094 template<typename DATATYPE>
13095 inline int AMPI_File_iread_at(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
13096 AMPI_Request* request) {
13097 return MPI_File_iread_at(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13098 }
13099
13100#endif
13101#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13102 template<typename DATATYPE>
13103 inline int AMPI_File_iread_at_all(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
13104 AMPI_Request* request) {
13105 return MPI_File_iread_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13106 }
13107
13108#endif
13109#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13110 template<typename DATATYPE>
13111 inline int AMPI_File_iread_shared(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13112 return MPI_File_iread_shared(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13113 }
13114
13115#endif
13116#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13117 template<typename DATATYPE>
13118 inline int AMPI_File_iwrite(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13119 return MPI_File_iwrite(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13120 }
13121
13122#endif
13123#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13124 template<typename DATATYPE>
13125 inline int AMPI_File_iwrite_all(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13126 return MPI_File_iwrite_all(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13127 }
13128
13129#endif
13130#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13131 template<typename DATATYPE>
13132 inline int AMPI_File_iwrite_at(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
13133 AMPI_Request* request) {
13134 return MPI_File_iwrite_at(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13135 }
13136
13137#endif
13138#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13139 template<typename DATATYPE>
13140 inline int AMPI_File_iwrite_at_all(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
13141 AMPI_Request* request) {
13142 return MPI_File_iwrite_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13143 }
13144
13145#endif
13146#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13147 template<typename DATATYPE>
13148 inline int AMPI_File_iwrite_shared(AMPI_File fh, const void* buf, int count, DATATYPE* datatype,
13149 AMPI_Request* request) {
13150 return MPI_File_iwrite_shared(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13151 }
13152
13153#endif
13154#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13155 inline int AMPI_File_open(AMPI_Comm comm, MEDI_OPTIONAL_CONST char* filename, int amode, AMPI_Info info,
13156 AMPI_File* fh) {
13157 return MPI_File_open(comm, filename, amode, info, fh);
13158 }
13159
13160#endif
13161#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13163 return MPI_File_preallocate(fh, size);
13164 }
13165
13166#endif
13167#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13168 template<typename DATATYPE>
13169 inline int AMPI_File_read(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13170 return MPI_File_read(fh, buf, count, datatype->getModifiedMpiType(), status);
13171 }
13172
13173#endif
13174#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13175 template<typename DATATYPE>
13176 inline int AMPI_File_read_all(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13177 return MPI_File_read_all(fh, buf, count, datatype->getModifiedMpiType(), status);
13178 }
13179
13180#endif
13181#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13182 template<typename DATATYPE>
13183 inline int AMPI_File_read_all_begin(AMPI_File fh, void* buf, int count, DATATYPE* datatype) {
13184 return MPI_File_read_all_begin(fh, buf, count, datatype->getModifiedMpiType());
13185 }
13186
13187#endif
13188#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13189 inline int AMPI_File_read_all_end(AMPI_File fh, void* buf, AMPI_Status* status) {
13190 return MPI_File_read_all_end(fh, buf, status);
13191 }
13192
13193#endif
13194#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13195 template<typename DATATYPE>
13196 inline int AMPI_File_read_at(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
13197 AMPI_Status* status) {
13198 return MPI_File_read_at(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
13199 }
13200
13201#endif
13202#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13203 template<typename DATATYPE>
13204 inline int AMPI_File_read_at_all(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
13205 AMPI_Status* status) {
13206 return MPI_File_read_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
13207 }
13208
13209#endif
13210#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13211 template<typename DATATYPE>
13212 inline int AMPI_File_read_at_all_begin(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype) {
13213 return MPI_File_read_at_all_begin(fh, offset, buf, count, datatype->getModifiedMpiType());
13214 }
13215
13216#endif
13217#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13218 inline int AMPI_File_read_at_all_end(AMPI_File fh, void* buf, AMPI_Status* status) {
13219 return MPI_File_read_at_all_end(fh, buf, status);
13220 }
13221
13222#endif
13223#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13224 template<typename DATATYPE>
13225 inline int AMPI_File_read_ordered(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13226 return MPI_File_read_ordered(fh, buf, count, datatype->getModifiedMpiType(), status);
13227 }
13228
13229#endif
13230#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13231 template<typename DATATYPE>
13232 inline int AMPI_File_read_ordered_begin(AMPI_File fh, void* buf, int count, DATATYPE* datatype) {
13233 return MPI_File_read_ordered_begin(fh, buf, count, datatype->getModifiedMpiType());
13234 }
13235
13236#endif
13237#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13238 inline int AMPI_File_read_ordered_end(AMPI_File fh, void* buf, AMPI_Status* status) {
13239 return MPI_File_read_ordered_end(fh, buf, status);
13240 }
13241
13242#endif
13243#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13244 template<typename DATATYPE>
13245 inline int AMPI_File_read_shared(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13246 return MPI_File_read_shared(fh, buf, count, datatype->getModifiedMpiType(), status);
13247 }
13248
13249#endif
13250#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13251 inline int AMPI_File_seek(AMPI_File fh, AMPI_Offset offset, int whence) {
13252 return MPI_File_seek(fh, offset, whence);
13253 }
13254
13255#endif
13256#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13257 inline int AMPI_File_seek_shared(AMPI_File fh, AMPI_Offset offset, int whence) {
13258 return MPI_File_seek_shared(fh, offset, whence);
13259 }
13260
13261#endif
13262#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13263 inline int AMPI_File_set_atomicity(AMPI_File fh, int flag) {
13264 return MPI_File_set_atomicity(fh, flag);
13265 }
13266
13267#endif
13268#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13270 return MPI_File_set_info(fh, info);
13271 }
13272
13273#endif
13274#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13276 return MPI_File_set_size(fh, size);
13277 }
13278
13279#endif
13280#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13281 template<typename ETYPE, typename FILETYPE>
13282 inline int AMPI_File_set_view(AMPI_File fh, AMPI_Offset disp, ETYPE* etype, FILETYPE* filetype, const char* datarep,
13283 AMPI_Info info) {
13284 return MPI_File_set_view(fh, disp, etype->getModifiedMpiType(), filetype->getModifiedMpiType(), datarep, info);
13285 }
13286
13287#endif
13288#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13289 inline int AMPI_File_sync(AMPI_File fh) {
13290 return MPI_File_sync(fh);
13291 }
13292
13293#endif
13294#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13295 template<typename DATATYPE>
13296 inline int AMPI_File_write(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13297 return MPI_File_write(fh, buf, count, datatype->getModifiedMpiType(), status);
13298 }
13299
13300#endif
13301#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13302 template<typename DATATYPE>
13303 inline int AMPI_File_write_all(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13304 return MPI_File_write_all(fh, buf, count, datatype->getModifiedMpiType(), status);
13305 }
13306
13307#endif
13308#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13309 template<typename DATATYPE>
13310 inline int AMPI_File_write_all_begin(AMPI_File fh, const void* buf, int count, DATATYPE* datatype) {
13311 return MPI_File_write_all_begin(fh, buf, count, datatype->getModifiedMpiType());
13312 }
13313
13314#endif
13315#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13317 return MPI_File_write_all_end(fh, buf, status);
13318 }
13319
13320#endif
13321#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13322 template<typename DATATYPE>
13323 inline int AMPI_File_write_at(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
13324 AMPI_Status* status) {
13325 return MPI_File_write_at(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
13326 }
13327
13328#endif
13329#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13330 template<typename DATATYPE>
13331 inline int AMPI_File_write_at_all(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
13332 AMPI_Status* status) {
13333 return MPI_File_write_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
13334 }
13335
13336#endif
13337#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13338 template<typename DATATYPE>
13339 inline int AMPI_File_write_at_all_begin(AMPI_File fh, AMPI_Offset offset, const void* buf, int count,
13340 DATATYPE* datatype) {
13341 return MPI_File_write_at_all_begin(fh, offset, buf, count, datatype->getModifiedMpiType());
13342 }
13343
13344#endif
13345#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13347 return MPI_File_write_at_all_end(fh, buf, status);
13348 }
13349
13350#endif
13351#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13352 template<typename DATATYPE>
13353 inline int AMPI_File_write_ordered(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13354 return MPI_File_write_ordered(fh, buf, count, datatype->getModifiedMpiType(), status);
13355 }
13356
13357#endif
13358#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13359 template<typename DATATYPE>
13360 inline int AMPI_File_write_ordered_begin(AMPI_File fh, const void* buf, int count, DATATYPE* datatype) {
13361 return MPI_File_write_ordered_begin(fh, buf, count, datatype->getModifiedMpiType());
13362 }
13363
13364#endif
13365#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13367 return MPI_File_write_ordered_end(fh, buf, status);
13368 }
13369
13370#endif
13371#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13372 template<typename DATATYPE>
13373 inline int AMPI_File_write_shared(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
13374 return MPI_File_write_shared(fh, buf, count, datatype->getModifiedMpiType(), status);
13375 }
13376
13377#endif
13378#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13380 AMPI_Datarep_conversion_function* read_conversion_fn, AMPI_Datarep_conversion_function* write_conversion_fn,
13381 AMPI_Datarep_extent_function* dtype_file_extent_fn, void* extra_state) {
13382 return MPI_Register_datarep(datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state);
13383 }
13384
13385#endif
13386#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13387 inline MPI_Fint AMPI_Comm_c2f(AMPI_Comm comm) {
13388 return MPI_Comm_c2f(comm);
13389 }
13390
13391#endif
13392#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13393 inline MPI_Comm AMPI_Comm_f2c(AMPI_Fint comm) {
13394 return MPI_Comm_f2c(comm);
13395 }
13396
13397#endif
13398#if MEDI_MPI_VERSION_2_1 <= MEDI_MPI_TARGET
13399 inline MPI_Fint AMPI_Errhandler_c2f(AMPI_Errhandler errhandler) {
13400 return MPI_Errhandler_c2f(errhandler);
13401 }
13402
13403#endif
13404#if MEDI_MPI_VERSION_2_1 <= MEDI_MPI_TARGET
13405 inline MPI_Errhandler AMPI_Errhandler_f2c(AMPI_Fint errhandler) {
13406 return MPI_Errhandler_f2c(errhandler);
13407 }
13408
13409#endif
13410#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13411 inline MPI_Fint AMPI_File_c2f(AMPI_File file) {
13412 return MPI_File_c2f(file);
13413 }
13414
13415#endif
13416#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13417 inline MPI_File AMPI_File_f2c(AMPI_Fint file) {
13418 return MPI_File_f2c(file);
13419 }
13420
13421#endif
13422#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13423 inline MPI_Fint AMPI_Group_c2f(AMPI_Group group) {
13424 return MPI_Group_c2f(group);
13425 }
13426
13427#endif
13428#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13429 inline MPI_Group AMPI_Group_f2c(AMPI_Fint group) {
13430 return MPI_Group_f2c(group);
13431 }
13432
13433#endif
13434#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13435 inline MPI_Fint AMPI_Info_c2f(AMPI_Info info) {
13436 return MPI_Info_c2f(info);
13437 }
13438
13439#endif
13440#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13441 inline MPI_Info AMPI_Info_f2c(AMPI_Fint info) {
13442 return MPI_Info_f2c(info);
13443 }
13444
13445#endif
13446#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13448 return MPI_Status_c2f(c_status, f_status);
13449 }
13450
13451#endif
13452#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13454 return MPI_Status_f2c(f_status, c_status);
13455 }
13456
13457#endif
13458#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13459 inline MPI_Fint AMPI_Win_c2f(AMPI_Win win) {
13460 return MPI_Win_c2f(win);
13461 }
13462
13463#endif
13464#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13465 inline MPI_Win AMPI_Win_f2c(AMPI_Fint win) {
13466 return MPI_Win_f2c(win);
13467 }
13468
13469#endif
13470#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13471 inline int AMPI_T_category_changed(int* stamp) {
13472 return MPI_T_category_changed(stamp);
13473 }
13474
13475#endif
13476#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13477 inline int AMPI_T_category_get_categories(int cat_index, int len, int* indices) {
13478 return MPI_T_category_get_categories(cat_index, len, indices);
13479 }
13480
13481#endif
13482#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13483 inline int AMPI_T_category_get_cvars(int cat_index, int len, int* indices) {
13484 return MPI_T_category_get_cvars(cat_index, len, indices);
13485 }
13486
13487#endif
13488#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13489 inline int AMPI_T_category_get_index(const char* name, int* cat_index) {
13490 return MPI_T_category_get_index(name, cat_index);
13491 }
13492
13493#endif
13494#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13495 inline int AMPI_T_category_get_info(int cat_index, char* name, int* name_len, char* desc, int* desc_len, int* num_cvars,
13496 int* num_pvars, int* num_categories) {
13497 return MPI_T_category_get_info(cat_index, name, name_len, desc, desc_len, num_cvars, num_pvars, num_categories);
13498 }
13499
13500#endif
13501#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13502 inline int AMPI_T_category_get_num(int* num_cat) {
13503 return MPI_T_category_get_num(num_cat);
13504 }
13505
13506#endif
13507#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13508 inline int AMPI_T_category_get_pvars(int cat_index, int len, int* indices) {
13509 return MPI_T_category_get_pvars(cat_index, len, indices);
13510 }
13511
13512#endif
13513#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13514 inline int AMPI_T_cvar_get_index(const char* name, int* cvar_index) {
13515 return MPI_T_cvar_get_index(name, cvar_index);
13516 }
13517
13518#endif
13519#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13520 inline int AMPI_T_cvar_get_num(int* num_cvar) {
13521 return MPI_T_cvar_get_num(num_cvar);
13522 }
13523
13524#endif
13525#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13526 inline int AMPI_T_cvar_handle_alloc(int cvar_index, void* obj_handle, AMPI_T_cvar_handle* handle, int* count) {
13527 return MPI_T_cvar_handle_alloc(cvar_index, obj_handle, handle, count);
13528 }
13529
13530#endif
13531#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13533 return MPI_T_cvar_handle_free(handle);
13534 }
13535
13536#endif
13537#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13538 inline int AMPI_T_cvar_read(AMPI_T_cvar_handle handle, void* buf) {
13539 return MPI_T_cvar_read(handle, buf);
13540 }
13541
13542#endif
13543#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13544 inline int AMPI_T_cvar_write(AMPI_T_cvar_handle handle, const void* buf) {
13545 return MPI_T_cvar_write(handle, buf);
13546 }
13547
13548#endif
13549#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13550 inline int AMPI_T_enum_get_info(AMPI_T_enum enumtype, int* num, char* name, int* name_len) {
13551 return MPI_T_enum_get_info(enumtype, num, name, name_len);
13552 }
13553
13554#endif
13555#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13556 inline int AMPI_T_enum_get_item(AMPI_T_enum enumtype, int index, int* value, char* name, int* name_len) {
13557 return MPI_T_enum_get_item(enumtype, index, value, name, name_len);
13558 }
13559
13560#endif
13561#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13562 inline int AMPI_T_finalize() {
13563 return MPI_T_finalize();
13564 }
13565
13566#endif
13567#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13568 inline int AMPI_T_init_thread(int required, int* provided) {
13569 return MPI_T_init_thread(required, provided);
13570 }
13571
13572#endif
13573#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13574 inline int AMPI_T_pvar_get_index(const char* name, int var_class, int* pvar_index) {
13575 return MPI_T_pvar_get_index(name, var_class, pvar_index);
13576 }
13577
13578#endif
13579#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13580 inline int AMPI_T_pvar_get_num(int* num_pvar) {
13581 return MPI_T_pvar_get_num(num_pvar);
13582 }
13583
13584#endif
13585#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13586 inline int AMPI_T_pvar_handle_alloc(AMPI_T_pvar_session session, int pvar_index, void* obj_handle,
13587 AMPI_T_pvar_handle* handle, int* count) {
13588 return MPI_T_pvar_handle_alloc(session, pvar_index, obj_handle, handle, count);
13589 }
13590
13591#endif
13592#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13594 return MPI_T_pvar_handle_free(session, handle);
13595 }
13596
13597#endif
13598#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13599 inline int AMPI_T_pvar_read(AMPI_T_pvar_session session, AMPI_T_pvar_handle handle, void* buf) {
13600 return MPI_T_pvar_read(session, handle, buf);
13601 }
13602
13603#endif
13604#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13605 inline int AMPI_T_pvar_readreset(AMPI_T_pvar_session session, AMPI_T_pvar_handle handle, void* buf) {
13606 return MPI_T_pvar_readreset(session, handle, buf);
13607 }
13608
13609#endif
13610#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13612 return MPI_T_pvar_reset(session, handle);
13613 }
13614
13615#endif
13616#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13618 return MPI_T_pvar_session_create(session);
13619 }
13620
13621#endif
13622#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13624 return MPI_T_pvar_session_free(session);
13625 }
13626
13627#endif
13628#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13630 return MPI_T_pvar_start(session, handle);
13631 }
13632
13633#endif
13634#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13636 return MPI_T_pvar_stop(session, handle);
13637 }
13638
13639#endif
13640#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13641 inline int AMPI_T_pvar_write(AMPI_T_pvar_session session, AMPI_T_pvar_handle handle, const void* buf) {
13642 return MPI_T_pvar_write(session, handle, buf);
13643 }
13644
13645#endif
13646#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
13647 inline int AMPI_Address(void* location, AMPI_Aint* address) {
13648 return MPI_Address(location, address);
13649 }
13650
13651#endif
13652#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13653 inline int AMPI_Attr_delete(AMPI_Comm comm, int keyval) {
13654 return MPI_Attr_delete(comm, keyval);
13655 }
13656
13657#endif
13658#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13659 inline int AMPI_Attr_get(AMPI_Comm comm, int keyval, void* attribute_val, int* flag) {
13660 return MPI_Attr_get(comm, keyval, attribute_val, flag);
13661 }
13662
13663#endif
13664#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13665 inline int AMPI_Attr_put(AMPI_Comm comm, int keyval, void* attribute_val) {
13666 return MPI_Attr_put(comm, keyval, attribute_val);
13667 }
13668
13669#endif
13670#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13671 inline int AMPI_Keyval_create(AMPI_Copy_function* copy_fn, AMPI_Delete_function* delete_fn, int* keyval,
13672 void* extra_state) {
13673 return MPI_Keyval_create(copy_fn, delete_fn, keyval, extra_state);
13674 }
13675
13676#endif
13677#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13678 inline int AMPI_Keyval_free(int* keyval) {
13679 return MPI_Keyval_free(keyval);
13680 }
13681
13682#endif
13683#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
13684 inline int AMPI_Errhandler_create(AMPI_Handler_function* function, AMPI_Errhandler* errhandler) {
13685 return MPI_Errhandler_create(function, errhandler);
13686 }
13687
13688#endif
13689#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
13690 inline int AMPI_Errhandler_get(AMPI_Comm comm, AMPI_Errhandler* errhandler) {
13691 return MPI_Errhandler_get(comm, errhandler);
13692 }
13693
13694#endif
13695#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
13696 inline int AMPI_Errhandler_set(AMPI_Comm comm, AMPI_Errhandler errhandler) {
13697 return MPI_Errhandler_set(comm, errhandler);
13698 }
13699
13700#endif
13701#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
13702 template<typename DATATYPE>
13703 inline int AMPI_Type_extent(DATATYPE* datatype, AMPI_Aint* extent) {
13704 return MPI_Type_extent(datatype->getModifiedMpiType(), extent);
13705 }
13706
13707#endif
13708#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
13709 template<typename DATATYPE>
13710 inline int AMPI_Type_lb(DATATYPE* datatype, AMPI_Aint* displacement) {
13711 return MPI_Type_lb(datatype->getModifiedMpiType(), displacement);
13712 }
13713
13714#endif
13715#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
13716 template<typename DATATYPE>
13717 inline int AMPI_Type_ub(DATATYPE* datatype, AMPI_Aint* displacement) {
13718 return MPI_Type_ub(datatype->getModifiedMpiType(), displacement);
13719 }
13720
13721#endif
13722
13723#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13724#define AMPI_Pcontrol MPI_Pcontrol
13725#endif
13726
13727
13728}
#define AMPI_T_pvar_session
Definition ampiDefinitions.h:805
#define AMPI_Status
Definition ampiDefinitions.h:772
#define AMPI_T_cvar_handle
Definition ampiDefinitions.h:799
#define AMPI_Errhandler
Definition ampiDefinitions.h:781
#define AMPI_T_pvar_handle
Definition ampiDefinitions.h:802
#define AMPI_Aint
Definition ampiDefinitions.h:760
#define AMPI_Info
Definition ampiDefinitions.h:790
#define AMPI_Win
Definition ampiDefinitions.h:793
#define AMPI_Group
Definition ampiDefinitions.h:787
#define AMPI_Comm
Definition ampiDefinitions.h:778
#define AMPI_Fint
Definition ampiDefinitions.h:766
#define AMPI_Count
Definition ampiDefinitions.h:763
#define AMPI_Offset
Definition ampiDefinitions.h:769
#define AMPI_File
Definition ampiDefinitions.h:784
#define AMPI_T_enum
Definition ampiDefinitions.h:796
The interface for the AD tool that is accessed by MeDiPack.
Definition adToolInterface.h:42
virtual AMPI_Op convertOperator(AMPI_Op op) const =0
Convert the mpi intrinsic operators like MPI_SUM to the specific one for the AD tool.
virtual void startAssembly(HandleBase *h) const =0
Indicates to the AD tool that an adjoint action is in the progress of beeing recorded.
virtual void stopAssembly(HandleBase *h) const =0
Indicates to the AD tool that an adjoint action is beeing finished.
virtual void addToolAction(HandleBase *h) const =0
Register the handle so that the AD tool can evaluate it in the reverse sweep.
virtual bool isHandleRequired() const =0
The handle needs to be created if an adjoint action is required by the AD tool.
virtual bool isActiveType() const =0
If this AD interface represents an AD type.
virtual bool isOldPrimalsRequired() const =0
Indicates if MeDiPack needs store the overwritten primal values for the AD tool.
Definition adjointInterface.hpp:40
virtual void updateAdjoints(const void *indices, const void *adjoints, int elements) const =0
Add the adjoint varaibles to the ones in the AD tool. That is the AD tool should perform the operatio...
virtual void createPrimalTypeBuffer(void *&buf, size_t size) const =0
Create an array for the primal variables.
virtual void deletePrimalTypeBuffer(void *&buf) const =0
Delete the array of the primal variables.
virtual void getPrimals(const void *indices, const void *primals, int elements) const =0
Get the primal values from the AD tool.
virtual void getAdjoints(const void *indices, void *adjoints, int elements) const =0
Get the adjoints for the indices from the AD tool.
virtual void createAdjointTypeBuffer(void *&buf, size_t size) const =0
Create an array for the adjoint variables.
virtual int getVectorSize() const =0
The vector size for the current evaluation.
virtual void combineAdjoints(void *buf, const int elements, const int ranks) const =0
Perform a reduction in the first element of the buffer.
virtual void deleteAdjointTypeBuffer(void *&buf) const =0
Delete the array of the adjoint variables.
virtual void setPrimals(const void *indices, const void *primals, int elements) const =0
Set the primal values on the AD tool.
#define MEDI_OPTIONAL_CONST
Definition macros.h:70
#define MEDI_UNUSED(name)
Definition macros.h:108
int Range[3]
Definition mpiTools.h:43
Global namespace for MeDiPack - Message Differentiation Package.
Definition adjointInterface.hpp:37
void AMPI_Igatherv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9342
int AMPI_Comm_free_keyval(int *comm_keyval)
Definition ampiFunctions.hpp:12232
int AMPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len)
Definition ampiFunctions.hpp:13550
int AMPI_Info_dup(MPI_Info info, MPI_Info *newinfo)
Definition ampiFunctions.hpp:12839
MPI_Comm_errhandler_function AMPI_Comm_errhandler_function
Definition ampiDefinitions.h:848
int AMPI_Errhandler_free(MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:12707
void AMPI_Iallgather_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:273
int AMPI_Topo_test(MPI_Comm comm, int *status)
Definition ampiFunctions.hpp:12629
MPI_Win AMPI_Win_f2c(MPI_Fint win)
Definition ampiFunctions.hpp:13465
void AMPI_Mrecv_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, AMPI_Message *message, MPI_Status *status, RecvAdjCall reverse_call)
Definition forwardFunctions.hpp:119
int AMPI_Reduce_global(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:11214
void AMPI_Irsend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1325
void AMPI_Iscatter_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10261
void AMPI_Ibcast_wrap_pri(typename DATATYPE::PrimalType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, int root, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:169
int AMPI_Allgather(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition ampiFunctions.hpp:4220
void AMPI_Iscatter_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10305
void AMPI_Bsend_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition forwardFunctions.hpp:62
void AMPI_Isend_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:54
int AMPI_File_get_amode(MPI_File fh, int *amode)
Definition ampiFunctions.hpp:13018
int AMPI_Send_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:3400
void AMPI_Igatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9437
int AMPI_File_create_errhandler(AMPI_File_errhandler_function *file_errhandler_fn, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:12731
int AMPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
Definition ampiFunctions.hpp:13635
int AMPI_Free_mem(void *base)
Definition ampiFunctions.hpp:12767
int AMPI_Grequest_start(AMPI_Grequest_query_function *query_fn, AMPI_Grequest_free_function *free_fn, AMPI_Grequest_cancel_function *cancel_fn, void *extra_state, AMPI_Request *request)
Definition ampiFunctions.hpp:12967
int AMPI_File_write_all_begin(MPI_File fh, const void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:13310
MPI_Datarep_conversion_function AMPI_Datarep_conversion_function
Definition ampiDefinitions.h:878
void AMPI_Irecv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1047
int AMPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
Definition ampiFunctions.hpp:12358
void AMPI_Bcast_wrap_pri(typename DATATYPE::PrimalType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, int root, MPI_Comm comm)
Definition primalFunctions.hpp:157
int AMPI_Info_delete(MPI_Info info, const char *key)
Definition ampiFunctions.hpp:12833
int AMPI_Get_elements(const MPI_Status *status, DATATYPE *datatype, int *count)
Definition ampiFunctions.hpp:12097
void AMPI_Igather_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8993
void AMPI_Ibcast_wrap_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8582
void AMPI_Isend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1557
MPI_Delete_function AMPI_Delete_function
Definition ampiDefinitions.h:884
void AMPI_Reduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11173
void AMPI_Iallreduce_global_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7308
void AMPI_Iallgather_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:273
int AMPI_Issend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:1906
int AMPI_Bsend_init(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:488
int AMPI_File_write_all_end(MPI_File fh, const void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:13316
void AMPI_Gatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6234
int AMPI_Comm_delete_attr(MPI_Comm comm, int comm_keyval)
Definition ampiFunctions.hpp:12208
int AMPI_Type_get_true_extent_x(DATATYPE *datatype, MPI_Count *true_lb, MPI_Count *true_extent)
Definition ampiFunctions.hpp:12149
void AMPI_Issend_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:86
void AMPI_Imrecv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:752
int AMPI_Close_port(const char *port_name)
Definition ampiFunctions.hpp:12881
int AMPI_T_pvar_start(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
Definition ampiFunctions.hpp:13629
int MPI_Ibcast_wrap(void *bufferSend, void *bufferRecv, int count, MPI_Datatype type, int root, MPI_Comm comm, MPI_Request *request)
Definition wrappers.hpp:68
int AMPI_Graph_map(MPI_Comm comm, int nnodes, const int *index, const int *edges, int *newrank)
Definition ampiFunctions.hpp:12604
int AMPI_Attr_delete(MPI_Comm comm, int keyval)
Definition ampiFunctions.hpp:13653
void AMPI_Recv_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int src, int tag, MPI_Comm comm, MPI_Status *status, RecvAdjCall reverse_call)
Definition reverseFunctions.hpp:108
MPI_Aint AMPI_Aint_add(MPI_Aint base, MPI_Aint disp)
Definition ampiFunctions.hpp:12078
void AMPI_Iallgatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6976
int AMPI_Mrecv(typename DATATYPE::Type *buf, int count, DATATYPE *datatype, AMPI_Message *message, MPI_Status *status, RecvAdjCall reverse_send=RecvAdjCall::Send)
Definition ampiFunctions.hpp:2133
int AMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int *coords)
Definition ampiFunctions.hpp:12505
MPI_Aint AMPI_Aint_diff(MPI_Aint addr1, MPI_Aint addr2)
Definition ampiFunctions.hpp:12084
int AMPI_File_read_ordered(MPI_File fh, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13225
void AMPI_Iscatterv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10780
int AMPI_Comm_join(int fd, MPI_Comm *intercomm)
Definition ampiFunctions.hpp:12913
int AMPI_T_finalize()
Definition ampiFunctions.hpp:13562
int AMPI_Comm_group(MPI_Comm comm, MPI_Group *group)
Definition ampiFunctions.hpp:12256
void AMPI_Issend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1865
void AMPI_Bsend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:90
int AMPI_Status_set_cancelled(MPI_Status *status, int flag)
Definition ampiFunctions.hpp:12986
void AMPI_Irsend_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:100
int AMPI_Iallreduce_global_finish(HandleBase *handle)
Definition ampiFunctions.hpp:7583
int AMPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name, int *name_len)
Definition ampiFunctions.hpp:13556
void AMPI_Igather_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8969
void AMPI_Ireduce_global_pri(typename DATATYPE::PrimalType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:359
int AMPI_Add_error_code(int errorclass, int *errorcode)
Definition ampiFunctions.hpp:12659
int AMPI_Open_port(MPI_Info info, char *port_name)
Definition ampiFunctions.hpp:12941
int AMPI_Barrier(MPI_Comm comm)
Definition ampiFunctions.hpp:12169
void AMPI_Send_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3097
void AMPI_Iscatterv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10684
int AMPI_Info_get_nthkey(MPI_Info info, int n, char *key)
Definition ampiFunctions.hpp:12863
void AMPI_Alltoall_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4987
void AMPI_Bsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:72
void AMPI_Imrecv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:768
int AMPI_Info_free(MPI_Info *info)
Definition ampiFunctions.hpp:12845
void AMPI_Irsend_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:102
void AMPI_Alltoallv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5259
int AMPI_Dist_graph_neighbors_count(MPI_Comm comm, int *indegree, int *outdegree, int *weighted)
Definition ampiFunctions.hpp:12585
void AMPI_Alltoallv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5328
void AMPI_Ireduce_global_fwd(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:359
int AMPI_File_iwrite_all(MPI_File fh, const void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13125
int AMPI_File_iread(MPI_File fh, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13081
int AMPI_Type_set_name(DATATYPE *datatype, const char *type_name)
Definition ampiFunctions.hpp:12456
void AMPI_Mrecv_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, AMPI_Message *message, MPI_Status *status, RecvAdjCall reverse_call)
Definition reverseFunctions.hpp:127
int AMPI_Win_get_errhandler(MPI_Win win, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:12815
void AMPI_Irecv_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int src, int tag, MPI_Comm comm, AMPI_Request *request, IrecvAdjCall reverse_call)
Definition reverseFunctions.hpp:134
void AMPI_Rsend_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition primalFunctions.hpp:94
int AMPI_File_get_position_shared(MPI_File fh, MPI_Offset *offset)
Definition ampiFunctions.hpp:13054
int AMPI_T_pvar_readreset(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void *buf)
Definition ampiFunctions.hpp:13605
void AMPI_Ireduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9889
int AMPI_Ssend_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:4047
int AMPI_Rsend_init(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:2844
int AMPI_Bsend_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:613
int AMPI_Bsend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:125
int AMPI_Iallgather_finish(HandleBase *handle)
Definition ampiFunctions.hpp:6761
int AMPI_File_get_position(MPI_File fh, MPI_Offset *offset)
Definition ampiFunctions.hpp:13048
int AMPI_Cart_create(MPI_Comm comm_old, int ndims, const int *dims, const int *periods, int reorder, MPI_Comm *comm_cart)
Definition ampiFunctions.hpp:12511
void AMPI_Ireduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9846
void AMPI_Gather_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5862
int AMPI_Alltoallv(const typename SENDTYPE::Type *sendbuf, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm)
Definition ampiFunctions.hpp:5364
int AMPI_Irsend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:1469
int AMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status)
Definition ampiFunctions.hpp:12060
int AMPI_T_category_get_info(int cat_index, char *name, int *name_len, char *desc, int *desc_len, int *num_cvars, int *num_pvars, int *num_categories)
Definition ampiFunctions.hpp:13495
int AMPI_Allgatherv(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm)
Definition ampiFunctions.hpp:4497
int AMPI_Ialltoallv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:8402
int AMPI_File_get_size(MPI_File fh, MPI_Offset *size)
Definition ampiFunctions.hpp:13060
int AMPI_Add_error_class(int *errorclass)
Definition ampiFunctions.hpp:12653
int AMPI_Gather(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:5959
void AMPI_Issend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1836
void AMPI_Recv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2299
void AMPI_Iallgatherv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6891
int AMPI_Isend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:1730
MPI_File_errhandler_function AMPI_File_errhandler_function
Definition ampiDefinitions.h:854
int AMPI_Keyval_free(int *keyval)
Definition ampiFunctions.hpp:13678
int AMPI_Is_thread_main(int *flag)
Definition ampiFunctions.hpp:12974
MPI_Win_copy_attr_function AMPI_Win_copy_attr_function
Definition ampiDefinitions.h:836
int AMPI_Type_size(DATATYPE *datatype, int *size)
Definition ampiFunctions.hpp:12156
void AMPI_Ialltoallv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8168
int AMPI_Comm_size(MPI_Comm comm, int *size)
Definition ampiFunctions.hpp:12304
void AMPI_Ireduce_global_adj(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:375
int AMPI_Get_library_version(char *version, int *resultlen)
Definition ampiFunctions.hpp:12773
int AMPI_Iscatter_finish(HandleBase *handle)
Definition ampiFunctions.hpp:10512
int AMPI_Buffer_attach(void *buffer, int size)
Definition ampiFunctions.hpp:12029
int AMPI_T_pvar_read(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void *buf)
Definition ampiFunctions.hpp:13599
int AMPI_File_set_size(MPI_File fh, MPI_Offset size)
Definition ampiFunctions.hpp:13275
void AMPI_Allgather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4190
int AMPI_Igather(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:9058
int AMPI_Send_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:3359
int AMPI_Rsend_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:2889
int AMPI_Ssend_init(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:3881
int AMPI_Get_version(int *version, int *subversion)
Definition ampiFunctions.hpp:12785
void AMPI_Ibcast_wrap_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8647
int AMPI_Cart_rank(MPI_Comm comm, const int *coords, int *rank)
Definition ampiFunctions.hpp:12531
int AMPI_Iscatter(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:10368
int AMPI_File_get_atomicity(MPI_File fh, int *flag)
Definition ampiFunctions.hpp:13024
int AMPI_T_category_get_cvars(int cat_index, int len, int *indices)
Definition ampiFunctions.hpp:13483
int AMPI_Dims_create(int nnodes, int ndims, int *dims)
Definition ampiFunctions.hpp:12555
void AMPI_Ialltoall_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7750
int AMPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence)
Definition ampiFunctions.hpp:13257
void AMPI_Gather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5925
void AMPI_Scatter_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11462
int AMPI_Comm_remote_group(MPI_Comm comm, MPI_Group *group)
Definition ampiFunctions.hpp:12274
int AMPI_Info_set(MPI_Info info, const char *key, const char *value)
Definition ampiFunctions.hpp:12875
int AMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int *index, int *edges)
Definition ampiFunctions.hpp:12598
void AMPI_Bcast_wrap_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5615
int AMPI_File_get_errhandler(MPI_File file, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:12743
int AMPI_Attr_get(MPI_Comm comm, int keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:13659
int AMPI_Igather_finish(HandleBase *handle)
Definition ampiFunctions.hpp:9202
void AMPI_Igather_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:231
void AMPI_Iallgather_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:281
void AMPI_Bcast_wrap_adj(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, int root, MPI_Comm comm)
Definition reverseFunctions.hpp:171
int AMPI_File_get_view(MPI_File fh, MPI_Offset *disp, ETYPE *etype, FILETYPE *filetype, char *datarep)
Definition ampiFunctions.hpp:13074
int AMPI_Scatterv(const typename SENDTYPE::Type *sendbuf, const int *sendcounts, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:11840
void AMPI_Sendrecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3492
int AMPI_Cartdim_get(MPI_Comm comm, int *ndims)
Definition ampiFunctions.hpp:12549
void AMPI_Ibcast_wrap_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8563
int AMPI_Ibcast_wrap(typename DATATYPE::Type *bufferSend, typename DATATYPE::Type *bufferRecv, int count, DATATYPE *datatype, int root, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:8666
MPI_Comm AMPI_Comm_f2c(MPI_Fint comm)
Definition ampiFunctions.hpp:13393
void AMPI_Gather_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition forwardFunctions.hpp:221
int AMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int *neighbors)
Definition ampiFunctions.hpp:12611
void AMPI_Mrecv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2093
int AMPI_Isend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:1645
void AMPI_Bsend_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition primalFunctions.hpp:62
void AMPI_Iscatterv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10658
int AMPI_File_iread_at(MPI_File fh, MPI_Offset offset, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13095
int AMPI_Win_create_errhandler(AMPI_Win_errhandler_function *win_errhandler_fn, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:12803
void AMPI_Iscatterv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10732
int AMPI_File_read_at_all_begin(MPI_File fh, MPI_Offset offset, void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:13212
int AMPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info, MPI_File *fh)
Definition ampiFunctions.hpp:13155
void AMPI_Send_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition forwardFunctions.hpp:46
void AMPI_Igatherv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:260
int AMPI_Type_size_x(DATATYPE *datatype, MPI_Count *size)
Definition ampiFunctions.hpp:12163
void AMPI_Ibsend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:263
void AMPI_Iscatter_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:199
void AMPI_Mrecv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2111
void AMPI_Sendrecv_pri(typename SENDTYPE::PrimalType *sendbuf, int sendbufSize, int sendcount, SENDTYPE *sendtype, int dest, int sendtag, typename RECVTYPE::PrimalType *recvbuf, int recvbufSize, int recvcount, RECVTYPE *recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)
Definition primalFunctions.hpp:146
IrecvAdjCall
Definition enums.hpp:40
@ Isend
Definition enums.hpp:41
int AMPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13204
int AMPI_Comm_set_name(MPI_Comm comm, const char *comm_name)
Definition ampiFunctions.hpp:12298
int AMPI_Igatherv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:9657
int AMPI_Comm_set_info(MPI_Comm comm, MPI_Info info)
Definition ampiFunctions.hpp:12292
int AMPI_Type_create_keyval(AMPI_Type_copy_attr_function *type_copy_attr_fn, AMPI_Type_delete_attr_function *type_delete_attr_fn, int *type_keyval, void *extra_state)
Definition ampiFunctions.hpp:12414
int AMPI_Comm_spawn_multiple(int count, char **array_of_commands, char ***array_of_argv, const int *array_of_maxprocs, const MPI_Info *array_of_info, int root, MPI_Comm comm, MPI_Comm *intercomm, int *array_of_errcodes)
Definition ampiFunctions.hpp:12926
MPI_Fint AMPI_Win_c2f(MPI_Win win)
Definition ampiFunctions.hpp:13459
int AMPI_Win_get_name(MPI_Win win, char *win_name, int *resultlen)
Definition ampiFunctions.hpp:12487
void AMPI_Irsend_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:102
void AMPI_Ibcast_wrap_fwd(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, int root, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:169
int AMPI_File_set_atomicity(MPI_File fh, int flag)
Definition ampiFunctions.hpp:13263
int AMPI_T_init_thread(int required, int *provided)
Definition ampiFunctions.hpp:13568
int AMPI_T_category_get_categories(int cat_index, int len, int *indices)
Definition ampiFunctions.hpp:13477
void AMPI_Iallgather_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6573
void AMPI_Igatherv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:252
int AMPI_Irecv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:1202
int AMPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
Definition ampiFunctions.hpp:13665
void AMPI_Allreduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4733
int AMPI_Ialltoall(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:7829
int AMPI_Group_range_incl(MPI_Group group, int n, ::medi::common::Range *ranges, MPI_Group *newgroup)
Definition ampiFunctions.hpp:12370
int AMPI_File_delete(const char *filename, MPI_Info info)
Definition ampiFunctions.hpp:13012
int AMPI_Group_rank(MPI_Group group, int *rank)
Definition ampiFunctions.hpp:12376
int AMPI_Rsend_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:2969
void AMPI_Ialltoallv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8121
void AMPI_Igather_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:231
void AMPI_Ibcast_wrap_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8621
void AMPI_Irsend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1343
int AMPI_File_iwrite(MPI_File fh, const void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13118
void AMPI_Gatherv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition reverseFunctions.hpp:249
void AMPI_Igatherv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9392
void AMPI_Ibcast_wrap_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8540
void AMPI_Irecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1016
int AMPI_File_set_info(MPI_File fh, MPI_Info info)
Definition ampiFunctions.hpp:13269
int AMPI_Status_set_elements_x(MPI_Status *status, DATATYPE *datatype, MPI_Count count)
Definition ampiFunctions.hpp:13000
int AMPI_Win_create_keyval(AMPI_Win_copy_attr_function *win_copy_attr_fn, AMPI_Win_delete_attr_function *win_delete_attr_fn, int *win_keyval, void *extra_state)
Definition ampiFunctions.hpp:12462
int computeDisplacementsTotalSize(const int *counts, int ranks)
Compute the total size of a message that has a different size on each rank.
Definition displacementTools.hpp:105
int AMPI_Comm_test_inter(MPI_Comm comm, int *flag)
Definition ampiFunctions.hpp:12322
int AMPI_Ssend_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:4006
int AMPI_Cart_map(MPI_Comm comm, int ndims, const int *dims, const int *periods, int *newrank)
Definition ampiFunctions.hpp:12524
void AMPI_Ibsend_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:70
int AMPI_File_iwrite_shared(MPI_File fh, const void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13148
int AMPI_Comm_idup(MPI_Comm comm, MPI_Comm *newcomm, AMPI_Request *request)
Definition ampiFunctions.hpp:12262
int AMPI_Comm_create_keyval(AMPI_Comm_copy_attr_function *comm_copy_attr_fn, AMPI_Comm_delete_attr_function *comm_delete_attr_fn, int *comm_keyval, void *extra_state)
Definition ampiFunctions.hpp:12201
int AMPI_Cart_shift(MPI_Comm comm, int direction, int disp, int *rank_source, int *rank_dest)
Definition ampiFunctions.hpp:12537
void AMPI_Isend_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1630
double AMPI_Wtick()
Definition ampiFunctions.hpp:12635
int AMPI_Lookup_name(const char *service_name, MPI_Info info, char *port_name)
Definition ampiFunctions.hpp:12935
int AMPI_T_cvar_get_num(int *num_cvar)
Definition ampiFunctions.hpp:13520
int AMPI_Comm_get_attr(MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:12238
void AMPI_Ssend_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition forwardFunctions.hpp:78
int AMPI_Comm_free(MPI_Comm *comm)
Definition ampiFunctions.hpp:12226
int AMPI_Recv_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:2571
RecvAdjCall
Definition enums.hpp:44
@ Send
Definition enums.hpp:45
const AMPI_IN_PLACE_IMPL AMPI_IN_PLACE
This structure is able to be cast to any type.
Definition ampi.cpp:40
void AMPI_Irsend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1354
void AMPI_Gather_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition reverseFunctions.hpp:229
void AMPI_Bcast_wrap_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5644
void AMPI_Recv_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int src, int tag, MPI_Comm comm, MPI_Status *status, RecvAdjCall reverse_call)
Definition forwardFunctions.hpp:110
int AMPI_Win_free_keyval(int *win_keyval)
Definition ampiFunctions.hpp:12475
int MPI_Bcast_wrap(void *bufferSend, void *bufferRecv, int count, MPI_Datatype type, int root, MPI_Comm comm)
Definition wrappers.hpp:52
int AMPI_Group_excl(MPI_Group group, int n, const int *ranks, MPI_Group *newgroup)
Definition ampiFunctions.hpp:12340
int AMPI_Request_get_status(AMPI_Request request, int *flag, MPI_Status *status)
Definition ampiFunctions.hpp:12066
void AMPI_Rsend_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition forwardFunctions.hpp:94
void AMPI_Ialltoallv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8096
int AMPI_Iallgather(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:6631
void AMPI_Send_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition reverseFunctions.hpp:44
void AMPI_Iallreduce_global_pri(typename DATATYPE::PrimalType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:380
int AMPI_Get_count(const MPI_Status *status, DATATYPE *datatype, int *count)
Definition ampiFunctions.hpp:12048
void AMPI_Iallgatherv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6959
ADToolInterface const * selectADTool(ADToolInterface const &tool)
Definition adToolInterface.h:342
int AMPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status)
Definition ampiFunctions.hpp:13453
int AMPI_File_set_errhandler(MPI_File file, MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:12749
void(* ForwardFunction)(HandleBase *h, AdjointInterface *a)
Definition typeDefinitions.h:47
int AMPI_Ibsend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:333
MPI_Group AMPI_Group_f2c(MPI_Fint group)
Definition ampiFunctions.hpp:13429
int AMPI_File_read(MPI_File fh, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13169
void AMPI_Irecv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1096
void AMPI_Ibcast_wrap_adj(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, int root, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:180
void AMPI_Scatter_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11492
int AMPI_Intercomm_merge(MPI_Comm intercomm, int high, MPI_Comm *newintracomm)
Definition ampiFunctions.hpp:12408
int AMPI_File_preallocate(MPI_File fh, MPI_Offset size)
Definition ampiFunctions.hpp:13162
void AMPI_Ssend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3744
void AMPI_Iallgather_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6551
void AMPI_Bcast_wrap_fwd(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, int root, MPI_Comm comm)
Definition forwardFunctions.hpp:157
int AMPI_Comm_remote_size(MPI_Comm comm, int *size)
Definition ampiFunctions.hpp:12280
int AMPI_Type_delete_attr(DATATYPE *datatype, int type_keyval)
Definition ampiFunctions.hpp:12422
int AMPI_Status_set_elements(MPI_Status *status, DATATYPE *datatype, int count)
Definition ampiFunctions.hpp:12993
void AMPI_Iscatterv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispl, const int *sendcount, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:219
void AMPI_Iallgather_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6511
int AMPI_Group_size(MPI_Group group, int *size)
Definition ampiFunctions.hpp:12382
MPI_Info AMPI_Info_f2c(MPI_Fint info)
Definition ampiFunctions.hpp:13441
int AMPI_Info_create(MPI_Info *info)
Definition ampiFunctions.hpp:12827
int AMPI_T_category_get_pvars(int cat_index, int len, int *indices)
Definition ampiFunctions.hpp:13508
void AMPI_Ialltoallv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8215
void AMPI_Iallgatherv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:294
MPI_Win_delete_attr_function AMPI_Win_delete_attr_function
Definition ampiDefinitions.h:839
void AMPI_Alltoallv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispls, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm)
Definition primalFunctions.hpp:325
int AMPI_Ialltoall_finish(HandleBase *handle)
Definition ampiFunctions.hpp:7958
int AMPI_Finalize()
Definition ampiFunctions.hpp:12755
int AMPI_Igatherv(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:9489
void AMPI_Scatterv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispl, const int *sendcount, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition reverseFunctions.hpp:209
void AMPI_Ibsend_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:318
int AMPI_Issend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:1991
MPI_Grequest_query_function AMPI_Grequest_query_function
Definition ampiDefinitions.h:866
MPI_Type_delete_attr_function AMPI_Type_delete_attr_function
Definition ampiDefinitions.h:845
int * createLinearDisplacements(const int *counts, int ranks)
Creates the linearized displacements of a message with a different size on each rank.
Definition displacementTools.hpp:122
void AMPI_Sendrecv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3549
MPI_Win_errhandler_function AMPI_Win_errhandler_function
Definition ampiDefinitions.h:851
int AMPI_Graph_create(MPI_Comm comm_old, int nnodes, const int *index, const int *edges, int reorder, MPI_Comm *comm_graph)
Definition ampiFunctions.hpp:12591
void AMPI_Allgather_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4135
int AMPI_Info_get(MPI_Info info, const char *key, int valuelen, char *value, int *flag)
Definition ampiFunctions.hpp:12851
MPI_Fint AMPI_Info_c2f(MPI_Info info)
Definition ampiFunctions.hpp:13435
int AMPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:12821
int AMPI_File_get_group(MPI_File fh, MPI_Group *group)
Definition ampiFunctions.hpp:13036
int AMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:12701
int AMPI_File_read_shared(MPI_File fh, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13245
int AMPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index, void *obj_handle, MPI_T_pvar_handle *handle, int *count)
Definition ampiFunctions.hpp:13586
void AMPI_Irsend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1314
void AMPI_Igather_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8923
int AMPI_Get_address(const void *location, MPI_Aint *address)
Definition ampiFunctions.hpp:12090
int AMPI_Win_set_attr(MPI_Win win, int win_keyval, void *attribute_val)
Definition ampiFunctions.hpp:12493
void AMPI_Imrecv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:796
int AMPI_Query_thread(int *provided)
Definition ampiFunctions.hpp:12980
int AMPI_File_sync(MPI_File fh)
Definition ampiFunctions.hpp:13289
void AMPI_Issend_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:86
void AMPI_Alltoall_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5016
int AMPI_Rsend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:2742
void AMPI_Igather_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8947
int AMPI_Send_init(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:3234
void AMPI_Igather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9010
int AMPI_Ssend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:3779
int AMPI_T_pvar_reset(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
Definition ampiFunctions.hpp:13611
void AMPI_Imrecv_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, AMPI_Message *message, AMPI_Request *request, IrecvAdjCall reverse_call)
Definition primalFunctions.hpp:137
int AMPI_Initialized(int *flag)
Definition ampiFunctions.hpp:12791
void AMPI_Allgatherv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm)
Definition reverseFunctions.hpp:291
void AMPI_Iallreduce_global_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7421
void AMPI_Igatherv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9418
int AMPI_Group_range_excl(MPI_Group group, int n, ::medi::common::Range *ranges, MPI_Group *newgroup)
Definition ampiFunctions.hpp:12364
int AMPI_Type_set_attr(DATATYPE *datatype, int type_keyval, void *attribute_val)
Definition ampiFunctions.hpp:12449
double AMPI_Wtime()
Definition ampiFunctions.hpp:12641
int AMPI_File_set_view(MPI_File fh, MPI_Offset disp, ETYPE *etype, FILETYPE *filetype, const char *datarep, MPI_Info info)
Definition ampiFunctions.hpp:13282
int AMPI_Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status)
Definition ampiFunctions.hpp:12054
void AMPI_Send_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3115
void AMPI_Rsend_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition reverseFunctions.hpp:92
MPI_Grequest_cancel_function AMPI_Grequest_cancel_function
Definition ampiDefinitions.h:872
void AMPI_Iscatter_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10322
void AMPI_Allgather_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition reverseFunctions.hpp:271
int AMPI_T_pvar_get_num(int *num_pvar)
Definition ampiFunctions.hpp:13580
void AMPI_Ialltoall_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:328
int AMPI_File_write(MPI_File fh, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13296
void AMPI_Iscatter_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10281
int AMPI_Iscatterv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:10970
int AMPI_Dist_graph_neighbors(MPI_Comm comm, int maxindegree, int *sources, int *sourceweights, int maxoutdegree, int *destinations, int *destweights)
Definition ampiFunctions.hpp:12578
void AMPI_Ssend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3726
int AMPI_Comm_get_name(MPI_Comm comm, char *comm_name, int *resultlen)
Definition ampiFunctions.hpp:12250
void AMPI_Scatterv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11804
void AMPI_Irecv_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int src, int tag, MPI_Comm comm, AMPI_Request *request, IrecvAdjCall reverse_call)
Definition primalFunctions.hpp:128
int AMPI_T_category_get_index(const char *name, int *cat_index)
Definition ampiFunctions.hpp:13489
void AMPI_Ialltoall_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7812
void AMPI_Gather_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5896
int AMPI_Get_elements_x(const MPI_Status *status, DATATYPE *datatype, MPI_Count *count)
Definition ampiFunctions.hpp:12104
void AMPI_Gatherv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition forwardFunctions.hpp:241
void AMPI_Allreduce_global_pri(typename DATATYPE::PrimalType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm)
Definition primalFunctions.hpp:369
MPI_Errhandler AMPI_Errhandler_f2c(MPI_Fint errhandler)
Definition ampiFunctions.hpp:13405
int AMPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12214
int AMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
Definition ampiFunctions.hpp:12334
void AMPI_Iscatter_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10237
void AMPI_Ssend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3762
void AMPI_Alltoall_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition primalFunctions.hpp:305
int AMPI_Dist_graph_create(MPI_Comm comm_old, int n, const int *sources, const int *degrees, const int *destinations, const int *weights, MPI_Info info, int reorder, MPI_Comm *comm_dist_graph)
Definition ampiFunctions.hpp:12561
int AMPI_Grequest_complete(AMPI_Request request)
Definition ampiFunctions.hpp:12961
void AMPI_Iallgather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6588
void createLinearDisplacementsAndCount(int *&countsOut, int *&displsOut, const int *counts, int ranks, int scale)
Creates the linearized displacements of a message with a different size on each rank.
Definition displacementTools.hpp:144
int AMPI_Group_translate_ranks(MPI_Group group1, int n, const int *ranks1, MPI_Group group2, int *ranks2)
Definition ampiFunctions.hpp:12388
int AMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
Definition ampiFunctions.hpp:12183
void AMPI_Scatter_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition forwardFunctions.hpp:181
int AMPI_File_read_all(MPI_File fh, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13176
void AMPI_Iscatterv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispl, const int *sendcount, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:211
int AMPI_Comm_call_errhandler(MPI_Comm comm, int errorcode)
Definition ampiFunctions.hpp:12677
int AMPI_Type_get_extent_x(DATATYPE *datatype, MPI_Count *lb, MPI_Count *extent)
Definition ampiFunctions.hpp:12135
int AMPI_Win_delete_attr(MPI_Win win, int win_keyval)
Definition ampiFunctions.hpp:12469
void AMPI_Allreduce_global_adj(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm)
Definition reverseFunctions.hpp:388
int AMPI_Imrecv(typename DATATYPE::Type *buf, int count, DATATYPE *datatype, AMPI_Message *message, AMPI_Request *request, IrecvAdjCall reverse_send=IrecvAdjCall::Isend)
Definition ampiFunctions.hpp:830
void AMPI_Scatter_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition primalFunctions.hpp:181
void createLinearIndexCounts(int *&linearCounts, const int *counts, const int *displs, int ranks, Datatype *type)
Creates the counts for a message with a different size on each rank.
Definition displacementTools.hpp:170
MPI_Fint AMPI_File_c2f(MPI_File file)
Definition ampiFunctions.hpp:13411
int AMPI_Allreduce_global(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm)
Definition ampiFunctions.hpp:4796
void AMPI_Igather_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9039
MPI_Fint AMPI_Group_c2f(MPI_Group group)
Definition ampiFunctions.hpp:13423
void AMPI_Iscatterv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10706
void AMPI_Imrecv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:783
int AMPI_T_pvar_session_free(MPI_T_pvar_session *session)
Definition ampiFunctions.hpp:13623
int AMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int *nneighbors)
Definition ampiFunctions.hpp:12617
int AMPI_Iscatterv(const typename SENDTYPE::Type *sendbuf, const int *sendcounts, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:10801
int AMPI_Ibsend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:418
int AMPI_File_write_shared(MPI_File fh, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13373
int AMPI_Ialltoallv(const typename SENDTYPE::Type *sendbuf, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:8236
int AMPI_Info_get_valuelen(MPI_Info info, const char *key, int *valuelen, int *flag)
Definition ampiFunctions.hpp:12869
int AMPI_Win_set_name(MPI_Win win, const char *win_name)
Definition ampiFunctions.hpp:12499
int AMPI_Dist_graph_create_adjacent(MPI_Comm comm_old, int indegree, const int *sources, const int *sourceweights, int outdegree, const int *destinations, const int *destweights, MPI_Info info, int reorder, MPI_Comm *comm_dist_graph)
Definition ampiFunctions.hpp:12569
void AMPI_Irsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1296
void AMPI_Recv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2280
void AMPI_Isend_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:52
int AMPI_Recv_init(typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int source, int tag, MPI_Comm comm, AMPI_Request *request, IrecvAdjCall reverse_send=IrecvAdjCall::Isend)
Definition ampiFunctions.hpp:2436
int AMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12310
int AMPI_Type_get_true_extent(DATATYPE *datatype, MPI_Aint *true_lb, MPI_Aint *true_extent)
Definition ampiFunctions.hpp:12142
int AMPI_File_get_byte_offset(MPI_File fh, MPI_Offset offset, MPI_Offset *disp)
Definition ampiFunctions.hpp:13030
int AMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr)
Definition ampiFunctions.hpp:12671
MPI_Type_copy_attr_function AMPI_Type_copy_attr_function
Definition ampiDefinitions.h:842
int AMPI_Get_processor_name(char *name, int *resultlen)
Definition ampiFunctions.hpp:12779
void AMPI_Rsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2689
int AMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12189
void AMPI_Irecv_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int src, int tag, MPI_Comm comm, AMPI_Request *request, IrecvAdjCall reverse_call)
Definition forwardFunctions.hpp:128
MPI_Datarep_extent_function AMPI_Datarep_extent_function
Definition ampiDefinitions.h:875
int getCommSize(MPI_Comm comm)
Helper function that gets the number of ranks from the communicator.
Definition mpiTools.h:64
void AMPI_Iscatterv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispl, const int *sendcount, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:211
int AMPI_Comm_disconnect(MPI_Comm *comm)
Definition ampiFunctions.hpp:12901
int AMPI_Win_call_errhandler(MPI_Win win, int errorcode)
Definition ampiFunctions.hpp:12797
void AMPI_Igatherv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9368
int AMPI_T_pvar_handle_free(MPI_T_pvar_session session, MPI_T_pvar_handle *handle)
Definition ampiFunctions.hpp:13593
void AMPI_Mrecv_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, AMPI_Message *message, MPI_Status *status, RecvAdjCall reverse_call)
Definition primalFunctions.hpp:119
int AMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:12695
int AMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12316
void AMPI_Sendrecv_adj(typename SENDTYPE::AdjointType *sendbuf, int sendbufSize, int sendcount, SENDTYPE *sendtype, int dest, int sendtag, typename RECVTYPE::AdjointType *recvbuf, int recvbufSize, int recvcount, RECVTYPE *recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)
Definition reverseFunctions.hpp:160
int AMPI_Add_error_string(int errorcode, const char *string)
Definition ampiFunctions.hpp:12665
int AMPI_Irecv(typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int source, int tag, MPI_Comm comm, AMPI_Request *request, IrecvAdjCall reverse_send=IrecvAdjCall::Isend)
Definition ampiFunctions.hpp:1109
int AMPI_Register_datarep(const char *datarep, AMPI_Datarep_conversion_function *read_conversion_fn, AMPI_Datarep_conversion_function *write_conversion_fn, AMPI_Datarep_extent_function *dtype_file_extent_fn, void *extra_state)
Definition ampiFunctions.hpp:13379
void AMPI_Allgather_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition primalFunctions.hpp:263
void AMPI_Issend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1876
int getCommRank(MPI_Comm comm)
Helper function that gets the own rank number from the communicator.
Definition mpiTools.h:52
void AMPI_Iallgather_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6533
MPI_Fint AMPI_Errhandler_c2f(MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:13399
int AMPI_Iallgatherv(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:7023
int AMPI_Comm_get_parent(MPI_Comm *parent)
Definition ampiFunctions.hpp:12907
void AMPI_Imrecv_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, AMPI_Message *message, AMPI_Request *request, IrecvAdjCall reverse_call)
Definition forwardFunctions.hpp:137
int AMPI_Group_incl(MPI_Group group, int n, const int *ranks, MPI_Group *newgroup)
Definition ampiFunctions.hpp:12352
int AMPI_Comm_set_attr(MPI_Comm comm, int comm_keyval, void *attribute_val)
Definition ampiFunctions.hpp:12286
void AMPI_Issend_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:84
void AMPI_Allreduce_global_fwd(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm)
Definition forwardFunctions.hpp:369
int AMPI_Ssend_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:3926
void AMPI_Iallgatherv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6915
int AMPI_Comm_spawn(const char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int *array_of_errcodes)
Definition ampiFunctions.hpp:12919
int AMPI_Op_commutative(AMPI_Op op, int *commute)
Definition ampiFunctions.hpp:12175
void AMPI_Iscatter_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10349
void AMPI_Allgatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4464
int AMPI_Buffer_detach(void *buffer_addr, int *size)
Definition ampiFunctions.hpp:12035
void AMPI_Bsend_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition reverseFunctions.hpp:60
int AMPI_File_iread_all(MPI_File fh, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13088
void AMPI_Rsend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2707
void AMPI_Issend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1818
void AMPI_Imrecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:737
int AMPI_Finalized(int *flag)
Definition ampiFunctions.hpp:12761
int AMPI_Alltoall(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition ampiFunctions.hpp:5071
void AMPI_Iallgatherv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:304
int AMPI_File_write_ordered(MPI_File fh, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13353
void AMPI_Iscatter_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:191
MPI_Copy_function AMPI_Copy_function
Definition ampiDefinitions.h:881
int AMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13196
void AMPI_Alltoall_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition reverseFunctions.hpp:318
void AMPI_Igather_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:239
int AMPI_T_cvar_get_index(const char *name, int *cvar_index)
Definition ampiFunctions.hpp:13514
int AMPI_File_read_all_begin(MPI_File fh, void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:13183
int AMPI_Bcast_wrap(typename DATATYPE::Type *bufferSend, typename DATATYPE::Type *bufferRecv, int count, DATATYPE *datatype, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:5677
void AMPI_Allgatherv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4435
void AMPI_Iallreduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7352
void AMPI_Alltoallv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispls, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm)
Definition forwardFunctions.hpp:325
int AMPI_Publish_name(const char *service_name, MPI_Info info, const char *port_name)
Definition ampiFunctions.hpp:12947
void AMPI_Ibsend_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:68
void AMPI_Iscatterv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10751
int AMPI_Imrecv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:919
void AMPI_Isend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1615
void AMPI_Allreduce_global_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4703
int AMPI_File_get_type_extent(MPI_File fh, DATATYPE *datatype, MPI_Aint *extent)
Definition ampiFunctions.hpp:13067
int AMPI_Recv_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:2482
void AMPI_Ialltoall_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7772
void AMPI_Rsend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2725
void AMPI_Ibsend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:274
void AMPI_Iallreduce_global_adj(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:398
int AMPI_Unpublish_name(const char *service_name, MPI_Info info, const char *port_name)
Definition ampiFunctions.hpp:12954
int AMPI_Bsend_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:654
void AMPI_Ibsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:245
void AMPI_Ialltoall_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:315
void AMPI_Scatterv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11735
int AMPI_Rsend_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:3010
int AMPI_Iallreduce_global(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:7445
int AMPI_Gatherv(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:6272
void AMPI_Scatterv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispl, const int *sendcount, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition primalFunctions.hpp:201
void AMPI_Scatterv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11771
void AMPI_Recv_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int src, int tag, MPI_Comm comm, MPI_Status *status, RecvAdjCall reverse_call)
Definition primalFunctions.hpp:110
void AMPI_Ireduce_global_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9798
void AMPI_Gatherv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6201
void AMPI_Iscatter_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:191
int AMPI_File_close(MPI_File *fh)
Definition ampiFunctions.hpp:13006
MPI_Grequest_free_function AMPI_Grequest_free_function
Definition ampiDefinitions.h:869
void AMPI_Ibcast_wrap_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8605
void AMPI_Bsend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:108
void AMPI_Ssend_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition reverseFunctions.hpp:76
int AMPI_Ibcast_wrap_finish(HandleBase *handle)
Definition ampiFunctions.hpp:8800
void AMPI_Iallreduce_global_fwd(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:380
void AMPI_Sendrecv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3522
int AMPI_T_pvar_session_create(MPI_T_pvar_session *session)
Definition ampiFunctions.hpp:13617
int AMPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
Definition ampiFunctions.hpp:12395
void AMPI_Alltoallv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5295
void AMPI_Send_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3079
void AMPI_Reduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11142
int(* ContinueFunction)(HandleBase *h)
Definition typeDefinitions.h:49
void AMPI_Iallreduce_global_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7332
MpiTypeInterface * AMPI_Datatype
Definition ampiMisc.h:38
int AMPI_File_write_at_all_end(MPI_File fh, const void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:13346
int AMPI_Type_get_extent(DATATYPE *datatype, MPI_Aint *lb, MPI_Aint *extent)
Definition ampiFunctions.hpp:12128
void AMPI_Isend_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:54
void AMPI_Mrecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2073
int AMPI_Test_cancelled(const MPI_Status *status, int *flag)
Definition ampiFunctions.hpp:12072
void AMPI_Iallreduce_global_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7376
void AMPI_Ireduce_global_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9871
void AMPI_Allgatherv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4403
void AMPI_Iallgather_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6613
void AMPI_Alltoall_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition forwardFunctions.hpp:305
void AMPI_Ialltoallv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispls, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition reverseFunctions.hpp:350
int AMPI_File_call_errhandler(MPI_File fh, int errorcode)
Definition ampiFunctions.hpp:12725
int AMPI_File_write_at_all_begin(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:13339
int AMPI_Type_get_envelope(DATATYPE *datatype, int *num_integers, int *num_addresses, int *num_datatypes, int *combiner)
Definition ampiFunctions.hpp:12120
int AMPI_Group_free(MPI_Group *group)
Definition ampiFunctions.hpp:12346
void AMPI_Ialltoall_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7787
void AMPI_Iallgatherv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:294
void AMPI_Gatherv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6163
void AMPI_Iallgatherv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6935
void AMPI_Imrecv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:817
int AMPI_Cart_sub(MPI_Comm comm, const int *remain_dims, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12543
int AMPI_File_read_ordered_begin(MPI_File fh, void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:13232
void AMPI_Isend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1586
void AMPI_Allgatherv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm)
Definition forwardFunctions.hpp:283
int AMPI_File_get_info(MPI_File fh, MPI_Info *info_used)
Definition ampiFunctions.hpp:13042
int AMPI_File_iread_shared(MPI_File fh, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13111
int AMPI_Comm_accept(const char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12887
void AMPI_Gatherv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition primalFunctions.hpp:241
int AMPI_T_category_get_num(int *num_cat)
Definition ampiFunctions.hpp:13502
void AMPI_Alltoall_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5042
int AMPI_Recv_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:2618
MPI_Fint AMPI_Comm_c2f(MPI_Comm comm)
Definition ampiFunctions.hpp:13387
void AMPI_Issend_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1891
void AMPI_Igatherv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, int root, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:252
int AMPI_File_iread_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13103
void AMPI_Recv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2258
int AMPI_Send_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:3279
void AMPI_Isend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1575
int AMPI_File_write_at_all(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13331
void AMPI_Allgather_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm)
Definition forwardFunctions.hpp:263
int AMPI_File_write_ordered_begin(MPI_File fh, const void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:13360
void AMPI_Ssend_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition primalFunctions.hpp:78
int AMPI_Status_c2f(const MPI_Status *c_status, MPI_Fint *f_status)
Definition ampiFunctions.hpp:13447
void AMPI_Scatterv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispl, const int *sendcount, const int *displs, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition forwardFunctions.hpp:201
int AMPI_Graphdims_get(MPI_Comm comm, int *nnodes, int *nedges)
Definition ampiFunctions.hpp:12623
void AMPI_Alltoallv_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispls, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm)
Definition reverseFunctions.hpp:338
void AMPI_Iallgatherv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7003
int AMPI_File_write_all(MPI_File fh, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13303
int AMPI_Comm_connect(const char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12894
void AMPI_Bcast_wrap_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5583
int AMPI_Type_get_name(DATATYPE *datatype, char *type_name, int *resultlen)
Definition ampiFunctions.hpp:12442
void AMPI_Ibsend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:303
int AMPI_T_cvar_read(MPI_T_cvar_handle handle, void *buf)
Definition ampiFunctions.hpp:13538
void AMPI_Irecv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1075
int AMPI_File_iwrite_at_all(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13140
int AMPI_File_write_at(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:13323
void AMPI_Igatherv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9468
void AMPI_Irecv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1031
int AMPI_T_pvar_get_index(const char *name, int var_class, int *pvar_index)
Definition ampiFunctions.hpp:13574
int AMPI_Ireduce_global(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:9944
int AMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm *newintercomm)
Definition ampiFunctions.hpp:12401
int AMPI_Type_get_attr(DATATYPE *datatype, int type_keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:12435
void(* ReverseFunction)(HandleBase *h, AdjointInterface *a)
Definition typeDefinitions.h:46
int AMPI_Type_free_keyval(int *type_keyval)
Definition ampiFunctions.hpp:12428
int AMPI_Irsend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition ampiFunctions.hpp:1384
void AMPI_Ialltoallv_fwd(typename SENDTYPE::AdjointType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispls, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:337
int AMPI_Abort(MPI_Comm comm, int errorcode)
Definition ampiFunctions.hpp:12647
void AMPI_Scatter_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11429
int AMPI_File_iwrite_at(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13132
int AMPI_Ireduce_global_finish(HandleBase *handle)
Definition ampiFunctions.hpp:10096
void AMPI_Allgatherv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *displs, RECVTYPE *recvtype, MPI_Comm comm)
Definition primalFunctions.hpp:283
int AMPI_T_cvar_handle_alloc(int cvar_index, void *obj_handle, MPI_T_cvar_handle *handle, int *count)
Definition ampiFunctions.hpp:13526
int AMPI_Win_get_attr(MPI_Win win, int win_keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:12481
void AMPI_Allreduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4760
int AMPI_Recv(typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int source, int tag, MPI_Comm comm, MPI_Status *status, RecvAdjCall reverse_send=RecvAdjCall::Send)
Definition ampiFunctions.hpp:2322
int AMPI_Comm_get_info(MPI_Comm comm, MPI_Info *info_used)
Definition ampiFunctions.hpp:12244
int AMPI_Bsend_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:533
int AMPI_Scatter(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:11525
void AMPI_Ialltoall_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7732
int AMPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int tag, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12195
MPI_File AMPI_File_f2c(MPI_Fint file)
Definition ampiFunctions.hpp:13417
int AMPI_File_read_ordered_end(MPI_File fh, void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:13238
void AMPI_Reduce_global_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11106
void AMPI_Iallreduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7393
void AMPI_Send_pri(typename DATATYPE::PrimalType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition primalFunctions.hpp:46
void AMPI_Irsend_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1369
int AMPI_Iallgatherv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:7177
int AMPI_Error_string(int errorcode, char *string, int *resultlen)
Definition ampiFunctions.hpp:12719
int AMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:12220
int AMPI_T_cvar_handle_free(MPI_T_cvar_handle *handle)
Definition ampiFunctions.hpp:13532
int AMPI_Comm_create_errhandler(AMPI_Comm_errhandler_function *comm_errhandler_fn, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:12683
int AMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence)
Definition ampiFunctions.hpp:13251
int AMPI_Type_get_contents(DATATYPE *datatype, int max_integers, int max_addresses, int max_datatypes, int *array_of_integers, MPI_Aint *array_of_addresses, AMPI_Datatype *array_of_datatypes)
Definition ampiFunctions.hpp:12111
int AMPI_Cart_get(MPI_Comm comm, int maxdims, int *dims, int *periods, int *coords)
Definition ampiFunctions.hpp:12518
void AMPI_Ialltoallv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8143
int AMPI_Send(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:3132
void AMPI_Issend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1847
void AMPI_Ireduce_global_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9823
int AMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
Definition ampiFunctions.hpp:12328
void AMPI_Reduce_global_adj(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm)
Definition reverseFunctions.hpp:362
int AMPI_Sendrecv(const typename SENDTYPE::Type *sendbuf, int sendcount, SENDTYPE *sendtype, int dest, int sendtag, typename RECVTYPE::Type *recvbuf, int recvcount, RECVTYPE *recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)
Definition ampiFunctions.hpp:3579
void AMPI_Ialltoall_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7710
void AMPI_Gather_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition primalFunctions.hpp:221
void AMPI_Imrecv_adj(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, AMPI_Message *message, AMPI_Request *request, IrecvAdjCall reverse_call)
Definition reverseFunctions.hpp:152
int AMPI_T_category_changed(int *stamp)
Definition ampiFunctions.hpp:13471
void AMPI_Isend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1604
void AMPI_Ialltoallv_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int *sendbufCounts, const int *sendbufDispls, const int *sendcounts, const int *sdispls, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int *recvbufCounts, const int *recvbufDispls, const int *recvcounts, const int *rdispls, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:337
void AMPI_Allgather_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4164
int AMPI_Comm_rank(MPI_Comm comm, int *rank)
Definition ampiFunctions.hpp:12268
int AMPI_Info_get_nkeys(MPI_Info info, int *nkeys)
Definition ampiFunctions.hpp:12857
int AMPI_Cancel(AMPI_Request *request)
Definition ampiFunctions.hpp:12041
void AMPI_Ialltoallv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8187
void AMPI_Irecv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1062
void AMPI_Ialltoall_pri(typename SENDTYPE::PrimalType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, MPI_Comm comm, AMPI_Request *request)
Definition primalFunctions.hpp:315
int AMPI_File_read_at_all_end(MPI_File fh, void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:13218
int AMPI_T_cvar_write(MPI_T_cvar_handle handle, const void *buf)
Definition ampiFunctions.hpp:13544
void AMPI_Scatter_adj(typename SENDTYPE::AdjointType *&sendbufAdjoints, int sendbufSize, int sendcount, SENDTYPE *sendtype, typename RECVTYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int recvcount, RECVTYPE *recvtype, int root, MPI_Comm comm)
Definition reverseFunctions.hpp:189
MPI_Comm_delete_attr_function AMPI_Comm_delete_attr_function
Definition ampiDefinitions.h:833
void AMPI_Sendrecv_fwd(typename SENDTYPE::AdjointType *sendbuf, int sendbufSize, int sendcount, SENDTYPE *sendtype, int dest, int sendtag, typename RECVTYPE::AdjointType *recvbuf, int recvbufSize, int recvcount, RECVTYPE *recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)
Definition forwardFunctions.hpp:146
void AMPI_Ireduce_global_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9920
void AMPI_Reduce_global_fwd(typename DATATYPE::AdjointType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::AdjointType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm)
Definition forwardFunctions.hpp:349
int AMPI_File_read_all_end(MPI_File fh, void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:13189
MPI_Comm_copy_attr_function AMPI_Comm_copy_attr_function
Definition ampiDefinitions.h:830
void AMPI_Ibsend_fwd(typename DATATYPE::AdjointType *bufAdjoints, int bufSize, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm, AMPI_Request *request)
Definition forwardFunctions.hpp:70
int AMPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, const void *buf)
Definition ampiFunctions.hpp:13641
int AMPI_Error_class(int errorcode, int *errorclass)
Definition ampiFunctions.hpp:12713
void AMPI_Ibsend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:292
int AMPI_File_write_ordered_end(MPI_File fh, const void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:13366
int AMPI_Keyval_create(AMPI_Copy_function *copy_fn, AMPI_Delete_function *delete_fn, int *keyval, void *extra_state)
Definition ampiFunctions.hpp:13671
void AMPI_Reduce_global_pri(typename DATATYPE::PrimalType *&sendbufAdjoints, int sendbufSize, typename DATATYPE::PrimalType *&recvbufAdjoints, int recvbufSize, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm)
Definition primalFunctions.hpp:349
Definition ampiFunctions.hpp:4089
int sendbufTotalSize
Definition ampiFunctions.hpp:4090
int recvbufCountVec
Definition ampiFunctions.hpp:4104
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:4099
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:4100
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:4092
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:4091
int sendcount
Definition ampiFunctions.hpp:4096
void * recvbufAdjoints
Definition ampiFunctions.hpp:4102
int recvbufTotalSize
Definition ampiFunctions.hpp:4098
void * sendbufAdjoints
Definition ampiFunctions.hpp:4093
int recvbufCount
Definition ampiFunctions.hpp:4103
int recvcount
Definition ampiFunctions.hpp:4105
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:4101
~AMPI_Allgather_AdjointHandle()
Definition ampiFunctions.hpp:4109
int sendbufCountVec
Definition ampiFunctions.hpp:4095
int sendbufCount
Definition ampiFunctions.hpp:4094
RECVTYPE * recvtype
Definition ampiFunctions.hpp:4106
MPI_Comm comm
Definition ampiFunctions.hpp:4107
SENDTYPE * sendtype
Definition ampiFunctions.hpp:4097
Definition ampiFunctions.hpp:4351
int * recvbufCount
Definition ampiFunctions.hpp:4365
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:4354
int sendbufTotalSize
Definition ampiFunctions.hpp:4352
void * sendbufAdjoints
Definition ampiFunctions.hpp:4355
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:4353
MPI_Comm comm
Definition ampiFunctions.hpp:4371
void * recvbufAdjoints
Definition ampiFunctions.hpp:4364
int * recvbufDisplsVec
Definition ampiFunctions.hpp:4367
int * recvbufCountVec
Definition ampiFunctions.hpp:4366
int sendbufCountVec
Definition ampiFunctions.hpp:4357
SENDTYPE * sendtype
Definition ampiFunctions.hpp:4359
int sendcount
Definition ampiFunctions.hpp:4358
int recvbufTotalSize
Definition ampiFunctions.hpp:4360
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:4361
RECVTYPE * recvtype
Definition ampiFunctions.hpp:4370
~AMPI_Allgatherv_AdjointHandle()
Definition ampiFunctions.hpp:4373
int sendbufCount
Definition ampiFunctions.hpp:4356
const int * recvcounts
Definition ampiFunctions.hpp:4368
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:4363
const int * displs
Definition ampiFunctions.hpp:4369
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:4362
Definition ampiFunctions.hpp:4658
~AMPI_Allreduce_global_AdjointHandle()
Definition ampiFunctions.hpp:4677
void * sendbufAdjoints
Definition ampiFunctions.hpp:4662
void * recvbufAdjoints
Definition ampiFunctions.hpp:4669
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:4667
DATATYPE * datatype
Definition ampiFunctions.hpp:4673
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:4666
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:4660
int count
Definition ampiFunctions.hpp:4672
int sendbufCountVec
Definition ampiFunctions.hpp:4664
int recvbufCountVec
Definition ampiFunctions.hpp:4671
MPI_Comm comm
Definition ampiFunctions.hpp:4675
int sendbufTotalSize
Definition ampiFunctions.hpp:4659
int sendbufCount
Definition ampiFunctions.hpp:4663
int recvbufTotalSize
Definition ampiFunctions.hpp:4665
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:4661
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:4668
AMPI_Op op
Definition ampiFunctions.hpp:4674
int recvbufCount
Definition ampiFunctions.hpp:4670
Definition ampiFunctions.hpp:4941
void * sendbufAdjoints
Definition ampiFunctions.hpp:4945
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:4951
int sendbufCount
Definition ampiFunctions.hpp:4946
int sendbufTotalSize
Definition ampiFunctions.hpp:4942
int recvbufCountVec
Definition ampiFunctions.hpp:4956
int sendcount
Definition ampiFunctions.hpp:4948
SENDTYPE * sendtype
Definition ampiFunctions.hpp:4949
int recvcount
Definition ampiFunctions.hpp:4957
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:4952
int recvbufTotalSize
Definition ampiFunctions.hpp:4950
MPI_Comm comm
Definition ampiFunctions.hpp:4959
RECVTYPE * recvtype
Definition ampiFunctions.hpp:4958
int sendbufCountVec
Definition ampiFunctions.hpp:4947
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:4953
int recvbufCount
Definition ampiFunctions.hpp:4955
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:4944
~AMPI_Alltoall_AdjointHandle()
Definition ampiFunctions.hpp:4961
void * recvbufAdjoints
Definition ampiFunctions.hpp:4954
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:4943
Definition ampiFunctions.hpp:5201
const int * rdispls
Definition ampiFunctions.hpp:5221
int * recvbufCount
Definition ampiFunctions.hpp:5217
int * sendbufCount
Definition ampiFunctions.hpp:5206
MPI_Comm comm
Definition ampiFunctions.hpp:5223
~AMPI_Alltoallv_AdjointHandle()
Definition ampiFunctions.hpp:5225
void * recvbufAdjoints
Definition ampiFunctions.hpp:5216
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:5213
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:5214
SENDTYPE * sendtype
Definition ampiFunctions.hpp:5211
int * recvbufCountVec
Definition ampiFunctions.hpp:5218
const int * sdispls
Definition ampiFunctions.hpp:5210
int * sendbufDisplsVec
Definition ampiFunctions.hpp:5208
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:5204
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:5215
const int * sendcounts
Definition ampiFunctions.hpp:5209
void * sendbufAdjoints
Definition ampiFunctions.hpp:5205
int * recvbufDisplsVec
Definition ampiFunctions.hpp:5219
RECVTYPE * recvtype
Definition ampiFunctions.hpp:5222
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:5203
const int * recvcounts
Definition ampiFunctions.hpp:5220
int sendbufTotalSize
Definition ampiFunctions.hpp:5202
int * sendbufCountVec
Definition ampiFunctions.hpp:5207
int recvbufTotalSize
Definition ampiFunctions.hpp:5212
Definition ampiFunctions.hpp:5538
int bufferRecvCountVec
Definition ampiFunctions.hpp:5551
int bufferSendTotalSize
Definition ampiFunctions.hpp:5539
int bufferRecvCount
Definition ampiFunctions.hpp:5550
DATATYPE::PrimalType * bufferSendPrimals
Definition ampiFunctions.hpp:5541
void * bufferRecvAdjoints
Definition ampiFunctions.hpp:5549
int bufferSendCount
Definition ampiFunctions.hpp:5543
int bufferRecvTotalSize
Definition ampiFunctions.hpp:5545
int root
Definition ampiFunctions.hpp:5554
MPI_Comm comm
Definition ampiFunctions.hpp:5555
DATATYPE::PrimalType * bufferRecvPrimals
Definition ampiFunctions.hpp:5547
int count
Definition ampiFunctions.hpp:5552
void * bufferSendAdjoints
Definition ampiFunctions.hpp:5542
DATATYPE * datatype
Definition ampiFunctions.hpp:5553
int bufferSendCountVec
Definition ampiFunctions.hpp:5544
DATATYPE::PrimalType * bufferRecvOldPrimals
Definition ampiFunctions.hpp:5548
~AMPI_Bcast_wrap_AdjointHandle()
Definition ampiFunctions.hpp:5557
DATATYPE::IndexType * bufferRecvIndices
Definition ampiFunctions.hpp:5546
DATATYPE::IndexType * bufferSendIndices
Definition ampiFunctions.hpp:5540
Definition ampiFunctions.hpp:45
int bufCountVec
Definition ampiFunctions.hpp:51
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:47
int bufCount
Definition ampiFunctions.hpp:50
int count
Definition ampiFunctions.hpp:52
int tag
Definition ampiFunctions.hpp:55
int bufTotalSize
Definition ampiFunctions.hpp:46
MPI_Comm comm
Definition ampiFunctions.hpp:56
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:48
DATATYPE * datatype
Definition ampiFunctions.hpp:53
void * bufAdjoints
Definition ampiFunctions.hpp:49
int dest
Definition ampiFunctions.hpp:54
~AMPI_Bsend_AdjointHandle()
Definition ampiFunctions.hpp:58
Definition ampiFunctions.hpp:469
AMPI_Request * request
Definition ampiFunctions.hpp:477
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:471
int count
Definition ampiFunctions.hpp:472
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:470
int tag
Definition ampiFunctions.hpp:475
DATATYPE * datatype
Definition ampiFunctions.hpp:473
int dest
Definition ampiFunctions.hpp:474
MPI_Comm comm
Definition ampiFunctions.hpp:476
Definition ampiFunctions.hpp:5815
int sendbufCount
Definition ampiFunctions.hpp:5820
SENDTYPE * sendtype
Definition ampiFunctions.hpp:5823
RECVTYPE * recvtype
Definition ampiFunctions.hpp:5832
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:5817
int sendcount
Definition ampiFunctions.hpp:5822
int sendbufTotalSize
Definition ampiFunctions.hpp:5816
int recvbufCountVec
Definition ampiFunctions.hpp:5830
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:5826
int recvcount
Definition ampiFunctions.hpp:5831
MPI_Comm comm
Definition ampiFunctions.hpp:5834
int sendbufCountVec
Definition ampiFunctions.hpp:5821
int root
Definition ampiFunctions.hpp:5833
int recvbufCount
Definition ampiFunctions.hpp:5829
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:5825
int recvbufTotalSize
Definition ampiFunctions.hpp:5824
~AMPI_Gather_AdjointHandle()
Definition ampiFunctions.hpp:5836
void * sendbufAdjoints
Definition ampiFunctions.hpp:5819
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:5827
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:5818
void * recvbufAdjoints
Definition ampiFunctions.hpp:5828
Definition ampiFunctions.hpp:6110
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6118
int sendcount
Definition ampiFunctions.hpp:6117
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:6120
const int * recvcounts
Definition ampiFunctions.hpp:6127
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6129
int sendbufCountVec
Definition ampiFunctions.hpp:6116
const int * displs
Definition ampiFunctions.hpp:6128
int root
Definition ampiFunctions.hpp:6130
int * recvbufCountVec
Definition ampiFunctions.hpp:6125
~AMPI_Gatherv_AdjointHandle()
Definition ampiFunctions.hpp:6133
void * recvbufAdjoints
Definition ampiFunctions.hpp:6123
void * sendbufAdjoints
Definition ampiFunctions.hpp:6114
int recvbufTotalSize
Definition ampiFunctions.hpp:6119
int * recvbufCount
Definition ampiFunctions.hpp:6124
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:6122
int sendbufCount
Definition ampiFunctions.hpp:6115
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:6113
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:6112
int * recvbufDisplsVec
Definition ampiFunctions.hpp:6126
int sendbufTotalSize
Definition ampiFunctions.hpp:6111
MPI_Comm comm
Definition ampiFunctions.hpp:6131
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:6121
Definition ampiFunctions.hpp:6452
int recvbufCount
Definition ampiFunctions.hpp:6466
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:6462
int sendcount
Definition ampiFunctions.hpp:6459
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:6463
int recvcount
Definition ampiFunctions.hpp:6468
int recvbufTotalSize
Definition ampiFunctions.hpp:6461
int recvbufCountVec
Definition ampiFunctions.hpp:6467
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6469
void * sendbufAdjoints
Definition ampiFunctions.hpp:6456
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6460
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:6454
int sendbufTotalSize
Definition ampiFunctions.hpp:6453
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:6455
int sendbufCount
Definition ampiFunctions.hpp:6457
~AMPI_Iallgather_AdjointHandle()
Definition ampiFunctions.hpp:6472
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:6464
int sendbufCountVec
Definition ampiFunctions.hpp:6458
void * recvbufAdjoints
Definition ampiFunctions.hpp:6465
MPI_Comm comm
Definition ampiFunctions.hpp:6470
Definition ampiFunctions.hpp:6497
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:6499
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6501
MPI_Comm comm
Definition ampiFunctions.hpp:6506
int sendcount
Definition ampiFunctions.hpp:6500
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6505
int recvcount
Definition ampiFunctions.hpp:6504
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:6498
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:6503
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:6502
AMPI_Request * request
Definition ampiFunctions.hpp:6507
Definition ampiFunctions.hpp:6824
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:6827
int * recvbufCount
Definition ampiFunctions.hpp:6838
MPI_Comm comm
Definition ampiFunctions.hpp:6844
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:6836
int * recvbufDisplsVec
Definition ampiFunctions.hpp:6840
const int * displs
Definition ampiFunctions.hpp:6842
int sendcount
Definition ampiFunctions.hpp:6831
void * sendbufAdjoints
Definition ampiFunctions.hpp:6828
int sendbufCountVec
Definition ampiFunctions.hpp:6830
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:6826
~AMPI_Iallgatherv_AdjointHandle()
Definition ampiFunctions.hpp:6846
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6832
int sendbufTotalSize
Definition ampiFunctions.hpp:6825
void * recvbufAdjoints
Definition ampiFunctions.hpp:6837
int * recvbufCountVec
Definition ampiFunctions.hpp:6839
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6843
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:6835
int sendbufCount
Definition ampiFunctions.hpp:6829
int recvbufTotalSize
Definition ampiFunctions.hpp:6833
const int * recvcounts
Definition ampiFunctions.hpp:6841
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:6834
Definition ampiFunctions.hpp:6875
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:6877
MPI_Comm comm
Definition ampiFunctions.hpp:6886
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6885
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6879
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:6876
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:6881
const int * recvcounts
Definition ampiFunctions.hpp:6883
int sendcount
Definition ampiFunctions.hpp:6878
AMPI_Request * request
Definition ampiFunctions.hpp:6887
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:6880
const int * displsMod
Definition ampiFunctions.hpp:6882
const int * displs
Definition ampiFunctions.hpp:6884
Definition ampiFunctions.hpp:7251
MPI_Comm comm
Definition ampiFunctions.hpp:7268
void * sendbufAdjoints
Definition ampiFunctions.hpp:7255
int recvbufCountVec
Definition ampiFunctions.hpp:7264
int count
Definition ampiFunctions.hpp:7265
~AMPI_Iallreduce_global_AdjointHandle()
Definition ampiFunctions.hpp:7270
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:7260
int recvbufTotalSize
Definition ampiFunctions.hpp:7258
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:7254
void * recvbufAdjoints
Definition ampiFunctions.hpp:7262
int recvbufCount
Definition ampiFunctions.hpp:7263
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:7253
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:7261
DATATYPE * datatype
Definition ampiFunctions.hpp:7266
int sendbufTotalSize
Definition ampiFunctions.hpp:7252
int sendbufCountVec
Definition ampiFunctions.hpp:7257
int sendbufCount
Definition ampiFunctions.hpp:7256
AMPI_Op op
Definition ampiFunctions.hpp:7267
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:7259
Definition ampiFunctions.hpp:7295
AMPI_Op op
Definition ampiFunctions.hpp:7302
DATATYPE * datatype
Definition ampiFunctions.hpp:7301
int count
Definition ampiFunctions.hpp:7300
DATATYPE::Type * recvbuf
Definition ampiFunctions.hpp:7298
DATATYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:7299
AMPI_Request * request
Definition ampiFunctions.hpp:7304
const DATATYPE::Type * sendbuf
Definition ampiFunctions.hpp:7296
MPI_Comm comm
Definition ampiFunctions.hpp:7303
DATATYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:7297
Definition ampiFunctions.hpp:7651
RECVTYPE * recvtype
Definition ampiFunctions.hpp:7668
int sendcount
Definition ampiFunctions.hpp:7658
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:7661
int recvcount
Definition ampiFunctions.hpp:7667
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:7663
int recvbufTotalSize
Definition ampiFunctions.hpp:7660
int sendbufTotalSize
Definition ampiFunctions.hpp:7652
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:7662
MPI_Comm comm
Definition ampiFunctions.hpp:7669
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:7654
~AMPI_Ialltoall_AdjointHandle()
Definition ampiFunctions.hpp:7671
int sendbufCountVec
Definition ampiFunctions.hpp:7657
void * sendbufAdjoints
Definition ampiFunctions.hpp:7655
SENDTYPE * sendtype
Definition ampiFunctions.hpp:7659
void * recvbufAdjoints
Definition ampiFunctions.hpp:7664
int sendbufCount
Definition ampiFunctions.hpp:7656
int recvbufCount
Definition ampiFunctions.hpp:7665
int recvbufCountVec
Definition ampiFunctions.hpp:7666
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:7653
Definition ampiFunctions.hpp:7696
MPI_Comm comm
Definition ampiFunctions.hpp:7705
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:7702
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:7697
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:7701
int sendcount
Definition ampiFunctions.hpp:7699
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:7698
AMPI_Request * request
Definition ampiFunctions.hpp:7706
RECVTYPE * recvtype
Definition ampiFunctions.hpp:7704
int recvcount
Definition ampiFunctions.hpp:7703
SENDTYPE * sendtype
Definition ampiFunctions.hpp:7700
Definition ampiFunctions.hpp:8021
int * sendbufCountVec
Definition ampiFunctions.hpp:8027
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8031
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:8023
const int * sdispls
Definition ampiFunctions.hpp:8030
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:8034
int * recvbufCountVec
Definition ampiFunctions.hpp:8038
~AMPI_Ialltoallv_AdjointHandle()
Definition ampiFunctions.hpp:8045
const int * recvcounts
Definition ampiFunctions.hpp:8040
MPI_Comm comm
Definition ampiFunctions.hpp:8043
int * recvbufDisplsVec
Definition ampiFunctions.hpp:8039
void * recvbufAdjoints
Definition ampiFunctions.hpp:8036
int sendbufTotalSize
Definition ampiFunctions.hpp:8022
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8042
const int * sendcounts
Definition ampiFunctions.hpp:8029
int * sendbufDisplsVec
Definition ampiFunctions.hpp:8028
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:8024
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:8035
int recvbufTotalSize
Definition ampiFunctions.hpp:8032
int * sendbufCount
Definition ampiFunctions.hpp:8026
int * recvbufCount
Definition ampiFunctions.hpp:8037
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:8033
void * sendbufAdjoints
Definition ampiFunctions.hpp:8025
const int * rdispls
Definition ampiFunctions.hpp:8041
Definition ampiFunctions.hpp:8078
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:8086
const int * rdisplsMod
Definition ampiFunctions.hpp:8087
const int * rdispls
Definition ampiFunctions.hpp:8089
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:8085
AMPI_Request * request
Definition ampiFunctions.hpp:8092
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8090
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8084
const int * sendcounts
Definition ampiFunctions.hpp:8082
const int * sdisplsMod
Definition ampiFunctions.hpp:8081
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:8080
const int * sdispls
Definition ampiFunctions.hpp:8083
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:8079
const int * recvcounts
Definition ampiFunctions.hpp:8088
MPI_Comm comm
Definition ampiFunctions.hpp:8091
Definition ampiFunctions.hpp:8483
int bufferSendTotalSize
Definition ampiFunctions.hpp:8484
DATATYPE::PrimalType * bufferRecvPrimals
Definition ampiFunctions.hpp:8492
~AMPI_Ibcast_wrap_AdjointHandle()
Definition ampiFunctions.hpp:8502
DATATYPE::PrimalType * bufferSendPrimals
Definition ampiFunctions.hpp:8486
MPI_Comm comm
Definition ampiFunctions.hpp:8500
int bufferSendCountVec
Definition ampiFunctions.hpp:8489
int bufferSendCount
Definition ampiFunctions.hpp:8488
int count
Definition ampiFunctions.hpp:8497
int bufferRecvTotalSize
Definition ampiFunctions.hpp:8490
DATATYPE::IndexType * bufferSendIndices
Definition ampiFunctions.hpp:8485
int root
Definition ampiFunctions.hpp:8499
void * bufferRecvAdjoints
Definition ampiFunctions.hpp:8494
DATATYPE::PrimalType * bufferRecvOldPrimals
Definition ampiFunctions.hpp:8493
DATATYPE * datatype
Definition ampiFunctions.hpp:8498
int bufferRecvCountVec
Definition ampiFunctions.hpp:8496
void * bufferSendAdjoints
Definition ampiFunctions.hpp:8487
DATATYPE::IndexType * bufferRecvIndices
Definition ampiFunctions.hpp:8491
int bufferRecvCount
Definition ampiFunctions.hpp:8495
Definition ampiFunctions.hpp:8527
DATATYPE::Type * bufferRecv
Definition ampiFunctions.hpp:8530
AMPI_Request * request
Definition ampiFunctions.hpp:8536
DATATYPE * datatype
Definition ampiFunctions.hpp:8533
int root
Definition ampiFunctions.hpp:8534
DATATYPE::ModifiedType * bufferSendMod
Definition ampiFunctions.hpp:8529
MPI_Comm comm
Definition ampiFunctions.hpp:8535
DATATYPE::ModifiedType * bufferRecvMod
Definition ampiFunctions.hpp:8531
DATATYPE::Type * bufferSend
Definition ampiFunctions.hpp:8528
int count
Definition ampiFunctions.hpp:8532
Definition ampiFunctions.hpp:207
int dest
Definition ampiFunctions.hpp:216
int bufCount
Definition ampiFunctions.hpp:212
int count
Definition ampiFunctions.hpp:214
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:210
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:209
int tag
Definition ampiFunctions.hpp:217
~AMPI_Ibsend_AdjointHandle()
Definition ampiFunctions.hpp:220
DATATYPE * datatype
Definition ampiFunctions.hpp:215
void * bufAdjoints
Definition ampiFunctions.hpp:211
MPI_Comm comm
Definition ampiFunctions.hpp:218
int bufTotalSize
Definition ampiFunctions.hpp:208
int bufCountVec
Definition ampiFunctions.hpp:213
Definition ampiFunctions.hpp:233
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:234
int count
Definition ampiFunctions.hpp:236
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:235
MPI_Comm comm
Definition ampiFunctions.hpp:240
AMPI_Request * request
Definition ampiFunctions.hpp:241
int dest
Definition ampiFunctions.hpp:238
int tag
Definition ampiFunctions.hpp:239
DATATYPE * datatype
Definition ampiFunctions.hpp:237
Definition ampiFunctions.hpp:8862
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8870
int sendbufTotalSize
Definition ampiFunctions.hpp:8863
int sendbufCount
Definition ampiFunctions.hpp:8867
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:8874
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:8864
int sendbufCountVec
Definition ampiFunctions.hpp:8868
int root
Definition ampiFunctions.hpp:8880
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:8873
int recvbufCount
Definition ampiFunctions.hpp:8876
int recvbufCountVec
Definition ampiFunctions.hpp:8877
void * recvbufAdjoints
Definition ampiFunctions.hpp:8875
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8879
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:8865
~AMPI_Igather_AdjointHandle()
Definition ampiFunctions.hpp:8883
void * sendbufAdjoints
Definition ampiFunctions.hpp:8866
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:8872
int sendcount
Definition ampiFunctions.hpp:8869
int recvcount
Definition ampiFunctions.hpp:8878
int recvbufTotalSize
Definition ampiFunctions.hpp:8871
MPI_Comm comm
Definition ampiFunctions.hpp:8881
Definition ampiFunctions.hpp:8908
AMPI_Request * request
Definition ampiFunctions.hpp:8919
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:8914
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:8910
MPI_Comm comm
Definition ampiFunctions.hpp:8918
int sendcount
Definition ampiFunctions.hpp:8911
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8916
int recvcount
Definition ampiFunctions.hpp:8915
int root
Definition ampiFunctions.hpp:8917
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:8909
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:8913
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8912
Definition ampiFunctions.hpp:9273
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:9285
int sendcount
Definition ampiFunctions.hpp:9280
~AMPI_Igatherv_AdjointHandle()
Definition ampiFunctions.hpp:9296
int * recvbufCount
Definition ampiFunctions.hpp:9287
const int * recvcounts
Definition ampiFunctions.hpp:9290
int root
Definition ampiFunctions.hpp:9293
void * sendbufAdjoints
Definition ampiFunctions.hpp:9277
int sendbufCountVec
Definition ampiFunctions.hpp:9279
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:9284
int * recvbufDisplsVec
Definition ampiFunctions.hpp:9289
void * recvbufAdjoints
Definition ampiFunctions.hpp:9286
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:9275
int sendbufCount
Definition ampiFunctions.hpp:9278
MPI_Comm comm
Definition ampiFunctions.hpp:9294
const int * displs
Definition ampiFunctions.hpp:9291
int recvbufTotalSize
Definition ampiFunctions.hpp:9282
SENDTYPE * sendtype
Definition ampiFunctions.hpp:9281
int sendbufTotalSize
Definition ampiFunctions.hpp:9274
RECVTYPE * recvtype
Definition ampiFunctions.hpp:9292
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:9283
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:9276
int * recvbufCountVec
Definition ampiFunctions.hpp:9288
Definition ampiFunctions.hpp:9325
MPI_Comm comm
Definition ampiFunctions.hpp:9337
int root
Definition ampiFunctions.hpp:9336
const int * displsMod
Definition ampiFunctions.hpp:9332
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:9330
AMPI_Request * request
Definition ampiFunctions.hpp:9338
int sendcount
Definition ampiFunctions.hpp:9328
RECVTYPE * recvtype
Definition ampiFunctions.hpp:9335
SENDTYPE * sendtype
Definition ampiFunctions.hpp:9329
const int * displs
Definition ampiFunctions.hpp:9334
const int * recvcounts
Definition ampiFunctions.hpp:9333
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:9331
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:9326
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:9327
Definition ampiFunctions.hpp:696
void * bufAdjoints
Definition ampiFunctions.hpp:701
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:700
int bufCountVec
Definition ampiFunctions.hpp:703
DATATYPE * datatype
Definition ampiFunctions.hpp:705
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:707
int bufCount
Definition ampiFunctions.hpp:702
int bufTotalSize
Definition ampiFunctions.hpp:697
~AMPI_Imrecv_AdjointHandle()
Definition ampiFunctions.hpp:709
int count
Definition ampiFunctions.hpp:704
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:699
AMPI_Message message
Definition ampiFunctions.hpp:706
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:698
Definition ampiFunctions.hpp:726
int count
Definition ampiFunctions.hpp:729
DATATYPE::Type * buf
Definition ampiFunctions.hpp:727
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:728
DATATYPE * datatype
Definition ampiFunctions.hpp:730
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:733
AMPI_Request * request
Definition ampiFunctions.hpp:732
AMPI_Message * message
Definition ampiFunctions.hpp:731
Definition ampiFunctions.hpp:971
int bufCount
Definition ampiFunctions.hpp:977
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:973
int source
Definition ampiFunctions.hpp:981
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:984
int bufTotalSize
Definition ampiFunctions.hpp:972
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:975
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:974
int tag
Definition ampiFunctions.hpp:982
void * bufAdjoints
Definition ampiFunctions.hpp:976
int bufCountVec
Definition ampiFunctions.hpp:978
DATATYPE * datatype
Definition ampiFunctions.hpp:980
MPI_Comm comm
Definition ampiFunctions.hpp:983
int count
Definition ampiFunctions.hpp:979
~AMPI_Irecv_AdjointHandle()
Definition ampiFunctions.hpp:986
Definition ampiFunctions.hpp:1003
int count
Definition ampiFunctions.hpp:1006
int source
Definition ampiFunctions.hpp:1008
DATATYPE::Type * buf
Definition ampiFunctions.hpp:1004
int tag
Definition ampiFunctions.hpp:1009
DATATYPE * datatype
Definition ampiFunctions.hpp:1007
MPI_Comm comm
Definition ampiFunctions.hpp:1010
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1005
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:1012
AMPI_Request * request
Definition ampiFunctions.hpp:1011
Definition ampiFunctions.hpp:9739
int sendbufCount
Definition ampiFunctions.hpp:9744
~AMPI_Ireduce_global_AdjointHandle()
Definition ampiFunctions.hpp:9759
AMPI_Op op
Definition ampiFunctions.hpp:9755
DATATYPE * datatype
Definition ampiFunctions.hpp:9754
void * recvbufAdjoints
Definition ampiFunctions.hpp:9750
int root
Definition ampiFunctions.hpp:9756
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:9742
MPI_Comm comm
Definition ampiFunctions.hpp:9757
int sendbufTotalSize
Definition ampiFunctions.hpp:9740
int count
Definition ampiFunctions.hpp:9753
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:9749
void * sendbufAdjoints
Definition ampiFunctions.hpp:9743
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:9741
int sendbufCountVec
Definition ampiFunctions.hpp:9745
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:9748
int recvbufCountVec
Definition ampiFunctions.hpp:9752
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:9747
int recvbufTotalSize
Definition ampiFunctions.hpp:9746
int recvbufCount
Definition ampiFunctions.hpp:9751
Definition ampiFunctions.hpp:9784
const DATATYPE::Type * sendbuf
Definition ampiFunctions.hpp:9785
DATATYPE * datatype
Definition ampiFunctions.hpp:9790
DATATYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:9786
MPI_Comm comm
Definition ampiFunctions.hpp:9793
AMPI_Request * request
Definition ampiFunctions.hpp:9794
DATATYPE::Type * recvbuf
Definition ampiFunctions.hpp:9787
DATATYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:9788
int root
Definition ampiFunctions.hpp:9792
int count
Definition ampiFunctions.hpp:9789
AMPI_Op op
Definition ampiFunctions.hpp:9791
Definition ampiFunctions.hpp:1258
int bufCountVec
Definition ampiFunctions.hpp:1264
DATATYPE * datatype
Definition ampiFunctions.hpp:1266
int bufCount
Definition ampiFunctions.hpp:1263
MPI_Comm comm
Definition ampiFunctions.hpp:1269
int bufTotalSize
Definition ampiFunctions.hpp:1259
void * bufAdjoints
Definition ampiFunctions.hpp:1262
~AMPI_Irsend_AdjointHandle()
Definition ampiFunctions.hpp:1271
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:1260
int dest
Definition ampiFunctions.hpp:1267
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:1261
int tag
Definition ampiFunctions.hpp:1268
int count
Definition ampiFunctions.hpp:1265
Definition ampiFunctions.hpp:1284
int dest
Definition ampiFunctions.hpp:1289
AMPI_Request * request
Definition ampiFunctions.hpp:1292
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1286
DATATYPE * datatype
Definition ampiFunctions.hpp:1288
int count
Definition ampiFunctions.hpp:1287
MPI_Comm comm
Definition ampiFunctions.hpp:1291
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:1285
int tag
Definition ampiFunctions.hpp:1290
Definition ampiFunctions.hpp:10176
MPI_Comm comm
Definition ampiFunctions.hpp:10195
void * sendbufAdjoints
Definition ampiFunctions.hpp:10180
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:10188
SENDTYPE * sendtype
Definition ampiFunctions.hpp:10184
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:10178
int sendbufTotalSize
Definition ampiFunctions.hpp:10177
int sendbufCount
Definition ampiFunctions.hpp:10181
RECVTYPE * recvtype
Definition ampiFunctions.hpp:10193
int recvbufCountVec
Definition ampiFunctions.hpp:10191
~AMPI_Iscatter_AdjointHandle()
Definition ampiFunctions.hpp:10197
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:10186
int recvcount
Definition ampiFunctions.hpp:10192
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:10187
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:10179
int recvbufTotalSize
Definition ampiFunctions.hpp:10185
int root
Definition ampiFunctions.hpp:10194
void * recvbufAdjoints
Definition ampiFunctions.hpp:10189
int sendcount
Definition ampiFunctions.hpp:10183
int recvbufCount
Definition ampiFunctions.hpp:10190
int sendbufCountVec
Definition ampiFunctions.hpp:10182
Definition ampiFunctions.hpp:10222
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:10228
int root
Definition ampiFunctions.hpp:10231
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:10227
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:10224
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:10223
SENDTYPE * sendtype
Definition ampiFunctions.hpp:10226
RECVTYPE * recvtype
Definition ampiFunctions.hpp:10230
int sendcount
Definition ampiFunctions.hpp:10225
AMPI_Request * request
Definition ampiFunctions.hpp:10233
int recvcount
Definition ampiFunctions.hpp:10229
MPI_Comm comm
Definition ampiFunctions.hpp:10232
Definition ampiFunctions.hpp:10589
int recvcount
Definition ampiFunctions.hpp:10607
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:10601
const int * sendcounts
Definition ampiFunctions.hpp:10597
int sendbufTotalSize
Definition ampiFunctions.hpp:10590
int * sendbufCount
Definition ampiFunctions.hpp:10594
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:10591
int recvbufCountVec
Definition ampiFunctions.hpp:10606
RECVTYPE * recvtype
Definition ampiFunctions.hpp:10608
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:10603
int * sendbufCountVec
Definition ampiFunctions.hpp:10595
void * sendbufAdjoints
Definition ampiFunctions.hpp:10593
int * sendbufDisplsVec
Definition ampiFunctions.hpp:10596
SENDTYPE * sendtype
Definition ampiFunctions.hpp:10599
MPI_Comm comm
Definition ampiFunctions.hpp:10610
int root
Definition ampiFunctions.hpp:10609
int recvbufCount
Definition ampiFunctions.hpp:10605
void * recvbufAdjoints
Definition ampiFunctions.hpp:10604
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:10592
int recvbufTotalSize
Definition ampiFunctions.hpp:10600
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:10602
~AMPI_Iscatterv_AdjointHandle()
Definition ampiFunctions.hpp:10612
const int * displs
Definition ampiFunctions.hpp:10598
Definition ampiFunctions.hpp:10641
MPI_Comm comm
Definition ampiFunctions.hpp:10653
int root
Definition ampiFunctions.hpp:10652
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:10649
RECVTYPE * recvtype
Definition ampiFunctions.hpp:10651
int recvcount
Definition ampiFunctions.hpp:10650
const int * displsMod
Definition ampiFunctions.hpp:10644
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:10642
const int * displs
Definition ampiFunctions.hpp:10646
const int * sendcounts
Definition ampiFunctions.hpp:10645
AMPI_Request * request
Definition ampiFunctions.hpp:10654
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:10643
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:10648
SENDTYPE * sendtype
Definition ampiFunctions.hpp:10647
Definition ampiFunctions.hpp:1519
int bufCountVec
Definition ampiFunctions.hpp:1525
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:1522
int tag
Definition ampiFunctions.hpp:1529
void * bufAdjoints
Definition ampiFunctions.hpp:1523
int count
Definition ampiFunctions.hpp:1526
~AMPI_Isend_AdjointHandle()
Definition ampiFunctions.hpp:1532
DATATYPE * datatype
Definition ampiFunctions.hpp:1527
int dest
Definition ampiFunctions.hpp:1528
MPI_Comm comm
Definition ampiFunctions.hpp:1530
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:1521
int bufCount
Definition ampiFunctions.hpp:1524
int bufTotalSize
Definition ampiFunctions.hpp:1520
Definition ampiFunctions.hpp:1545
int count
Definition ampiFunctions.hpp:1548
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:1546
int dest
Definition ampiFunctions.hpp:1550
DATATYPE * datatype
Definition ampiFunctions.hpp:1549
AMPI_Request * request
Definition ampiFunctions.hpp:1553
int tag
Definition ampiFunctions.hpp:1551
MPI_Comm comm
Definition ampiFunctions.hpp:1552
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1547
Definition ampiFunctions.hpp:1780
~AMPI_Issend_AdjointHandle()
Definition ampiFunctions.hpp:1793
int bufCountVec
Definition ampiFunctions.hpp:1786
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:1783
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:1782
int bufCount
Definition ampiFunctions.hpp:1785
MPI_Comm comm
Definition ampiFunctions.hpp:1791
int tag
Definition ampiFunctions.hpp:1790
int dest
Definition ampiFunctions.hpp:1789
void * bufAdjoints
Definition ampiFunctions.hpp:1784
int bufTotalSize
Definition ampiFunctions.hpp:1781
int count
Definition ampiFunctions.hpp:1787
DATATYPE * datatype
Definition ampiFunctions.hpp:1788
Definition ampiFunctions.hpp:1806
int count
Definition ampiFunctions.hpp:1809
AMPI_Request * request
Definition ampiFunctions.hpp:1814
int tag
Definition ampiFunctions.hpp:1812
int dest
Definition ampiFunctions.hpp:1811
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1808
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:1807
DATATYPE * datatype
Definition ampiFunctions.hpp:1810
MPI_Comm comm
Definition ampiFunctions.hpp:1813
Stores additional information for a MPI_Message.
Definition message.hpp:44
MPI_Message message
Definition message.hpp:45
Definition ampiFunctions.hpp:2041
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:2044
~AMPI_Mrecv_AdjointHandle()
Definition ampiFunctions.hpp:2055
int bufTotalSize
Definition ampiFunctions.hpp:2042
int count
Definition ampiFunctions.hpp:2049
RecvAdjCall reverse_send
Definition ampiFunctions.hpp:2053
int bufCountVec
Definition ampiFunctions.hpp:2048
AMPI_Message message
Definition ampiFunctions.hpp:2051
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:2045
DATATYPE * datatype
Definition ampiFunctions.hpp:2050
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:2043
int bufCount
Definition ampiFunctions.hpp:2047
void * bufAdjoints
Definition ampiFunctions.hpp:2046
MPI_Status * status
Definition ampiFunctions.hpp:2052
Structure for the special handling of the MPI_Op structure.
Definition op.hpp:50
PreAdjointOperation preAdjointOperation
The operation that is evaluated on each adjoint value before they are send in a message.
Definition op.hpp:82
PostAdjointOperation postAdjointOperation
The operation that is evaluated on each adjoint after the values have been received in a message.
Definition op.hpp:87
MPI_Op primalFunction
The mpi operator for the unmodified AD types. The AD tool needs to record all operations that are eva...
Definition op.hpp:69
bool requiresPrimal
Indicates if the primal on the sending and receiving side are required by this operator.
Definition op.hpp:55
MPI_Op modifiedPrimalFunction
The mpi operator for the modified AD types. This are the operations that are evaluated during the mpi...
Definition op.hpp:77
Definition ampiFunctions.hpp:2225
~AMPI_Recv_AdjointHandle()
Definition ampiFunctions.hpp:2240
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:2228
int count
Definition ampiFunctions.hpp:2233
RecvAdjCall reverse_send
Definition ampiFunctions.hpp:2238
MPI_Comm comm
Definition ampiFunctions.hpp:2237
int source
Definition ampiFunctions.hpp:2235
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:2229
int bufCountVec
Definition ampiFunctions.hpp:2232
void * bufAdjoints
Definition ampiFunctions.hpp:2230
int bufTotalSize
Definition ampiFunctions.hpp:2226
int bufCount
Definition ampiFunctions.hpp:2231
DATATYPE * datatype
Definition ampiFunctions.hpp:2234
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:2227
int tag
Definition ampiFunctions.hpp:2236
Definition ampiFunctions.hpp:2416
MPI_Comm comm
Definition ampiFunctions.hpp:2423
DATATYPE::Type * buf
Definition ampiFunctions.hpp:2417
int count
Definition ampiFunctions.hpp:2419
int tag
Definition ampiFunctions.hpp:2422
AMPI_Request * request
Definition ampiFunctions.hpp:2424
int source
Definition ampiFunctions.hpp:2421
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:2425
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:2418
DATATYPE * datatype
Definition ampiFunctions.hpp:2420
Definition ampiFunctions.hpp:11060
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:11070
int sendbufTotalSize
Definition ampiFunctions.hpp:11061
int recvbufCountVec
Definition ampiFunctions.hpp:11073
DATATYPE * datatype
Definition ampiFunctions.hpp:11075
int recvbufTotalSize
Definition ampiFunctions.hpp:11067
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:11063
int count
Definition ampiFunctions.hpp:11074
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:11069
void * sendbufAdjoints
Definition ampiFunctions.hpp:11064
int sendbufCountVec
Definition ampiFunctions.hpp:11066
~AMPI_Reduce_global_AdjointHandle()
Definition ampiFunctions.hpp:11080
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:11062
AMPI_Op op
Definition ampiFunctions.hpp:11076
void * recvbufAdjoints
Definition ampiFunctions.hpp:11071
MPI_Comm comm
Definition ampiFunctions.hpp:11078
int root
Definition ampiFunctions.hpp:11077
int recvbufCount
Definition ampiFunctions.hpp:11072
int sendbufCount
Definition ampiFunctions.hpp:11065
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:11068
Definition async.hpp:45
AsyncHandle * handle
Definition async.hpp:47
ContinueFunction start
Definition async.hpp:52
ContinueFunction end
Definition async.hpp:53
MPI_Request request
Definition async.hpp:46
ContinueFunction func
Definition async.hpp:48
Definition ampiFunctions.hpp:2662
MPI_Comm comm
Definition ampiFunctions.hpp:2673
int count
Definition ampiFunctions.hpp:2669
int bufCountVec
Definition ampiFunctions.hpp:2668
DATATYPE * datatype
Definition ampiFunctions.hpp:2670
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:2664
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:2665
~AMPI_Rsend_AdjointHandle()
Definition ampiFunctions.hpp:2675
int tag
Definition ampiFunctions.hpp:2672
int bufTotalSize
Definition ampiFunctions.hpp:2663
int bufCount
Definition ampiFunctions.hpp:2667
void * bufAdjoints
Definition ampiFunctions.hpp:2666
int dest
Definition ampiFunctions.hpp:2671
Definition ampiFunctions.hpp:2825
DATATYPE * datatype
Definition ampiFunctions.hpp:2829
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:2827
int tag
Definition ampiFunctions.hpp:2831
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:2826
MPI_Comm comm
Definition ampiFunctions.hpp:2832
AMPI_Request * request
Definition ampiFunctions.hpp:2833
int count
Definition ampiFunctions.hpp:2828
int dest
Definition ampiFunctions.hpp:2830
Definition ampiFunctions.hpp:11382
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:11384
void * sendbufAdjoints
Definition ampiFunctions.hpp:11386
int recvbufTotalSize
Definition ampiFunctions.hpp:11391
RECVTYPE * recvtype
Definition ampiFunctions.hpp:11399
int sendbufCountVec
Definition ampiFunctions.hpp:11388
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:11392
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:11394
void * recvbufAdjoints
Definition ampiFunctions.hpp:11395
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:11385
int recvbufCountVec
Definition ampiFunctions.hpp:11397
int sendbufTotalSize
Definition ampiFunctions.hpp:11383
SENDTYPE * sendtype
Definition ampiFunctions.hpp:11390
int recvcount
Definition ampiFunctions.hpp:11398
int root
Definition ampiFunctions.hpp:11400
~AMPI_Scatter_AdjointHandle()
Definition ampiFunctions.hpp:11403
int recvbufCount
Definition ampiFunctions.hpp:11396
int sendcount
Definition ampiFunctions.hpp:11389
int sendbufCount
Definition ampiFunctions.hpp:11387
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:11393
MPI_Comm comm
Definition ampiFunctions.hpp:11401
Definition ampiFunctions.hpp:11682
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:11696
int root
Definition ampiFunctions.hpp:11702
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:11684
int recvcount
Definition ampiFunctions.hpp:11700
void * recvbufAdjoints
Definition ampiFunctions.hpp:11697
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:11694
RECVTYPE * recvtype
Definition ampiFunctions.hpp:11701
~AMPI_Scatterv_AdjointHandle()
Definition ampiFunctions.hpp:11705
const int * sendcounts
Definition ampiFunctions.hpp:11690
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:11685
SENDTYPE * sendtype
Definition ampiFunctions.hpp:11692
int recvbufTotalSize
Definition ampiFunctions.hpp:11693
int recvbufCountVec
Definition ampiFunctions.hpp:11699
int * sendbufCountVec
Definition ampiFunctions.hpp:11688
MPI_Comm comm
Definition ampiFunctions.hpp:11703
int * sendbufDisplsVec
Definition ampiFunctions.hpp:11689
int * sendbufCount
Definition ampiFunctions.hpp:11687
int recvbufCount
Definition ampiFunctions.hpp:11698
int sendbufTotalSize
Definition ampiFunctions.hpp:11683
void * sendbufAdjoints
Definition ampiFunctions.hpp:11686
const int * displs
Definition ampiFunctions.hpp:11691
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:11695
Definition ampiFunctions.hpp:3052
~AMPI_Send_AdjointHandle()
Definition ampiFunctions.hpp:3065
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:3055
void * bufAdjoints
Definition ampiFunctions.hpp:3056
MPI_Comm comm
Definition ampiFunctions.hpp:3063
DATATYPE * datatype
Definition ampiFunctions.hpp:3060
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:3054
int dest
Definition ampiFunctions.hpp:3061
int bufTotalSize
Definition ampiFunctions.hpp:3053
int count
Definition ampiFunctions.hpp:3059
int bufCount
Definition ampiFunctions.hpp:3057
int bufCountVec
Definition ampiFunctions.hpp:3058
int tag
Definition ampiFunctions.hpp:3062
Definition ampiFunctions.hpp:3215
DATATYPE * datatype
Definition ampiFunctions.hpp:3219
MPI_Comm comm
Definition ampiFunctions.hpp:3222
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:3216
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:3217
AMPI_Request * request
Definition ampiFunctions.hpp:3223
int tag
Definition ampiFunctions.hpp:3221
int count
Definition ampiFunctions.hpp:3218
int dest
Definition ampiFunctions.hpp:3220
Definition ampiFunctions.hpp:3442
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:3444
void * sendbufAdjoints
Definition ampiFunctions.hpp:3446
int sendcount
Definition ampiFunctions.hpp:3449
int recvbufCountVec
Definition ampiFunctions.hpp:3459
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:3445
int source
Definition ampiFunctions.hpp:3462
int recvcount
Definition ampiFunctions.hpp:3460
MPI_Comm comm
Definition ampiFunctions.hpp:3464
RECVTYPE * recvtype
Definition ampiFunctions.hpp:3461
int recvbufTotalSize
Definition ampiFunctions.hpp:3453
~AMPI_Sendrecv_AdjointHandle()
Definition ampiFunctions.hpp:3466
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:3454
int recvbufCount
Definition ampiFunctions.hpp:3458
int recvtag
Definition ampiFunctions.hpp:3463
SENDTYPE * sendtype
Definition ampiFunctions.hpp:3450
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:3456
int sendbufCountVec
Definition ampiFunctions.hpp:3448
int sendbufTotalSize
Definition ampiFunctions.hpp:3443
int sendtag
Definition ampiFunctions.hpp:3452
void * recvbufAdjoints
Definition ampiFunctions.hpp:3457
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:3455
int dest
Definition ampiFunctions.hpp:3451
int sendbufCount
Definition ampiFunctions.hpp:3447
Definition ampiFunctions.hpp:3699
MPI_Comm comm
Definition ampiFunctions.hpp:3710
int count
Definition ampiFunctions.hpp:3706
DATATYPE * datatype
Definition ampiFunctions.hpp:3707
void * bufAdjoints
Definition ampiFunctions.hpp:3703
int tag
Definition ampiFunctions.hpp:3709
int bufCount
Definition ampiFunctions.hpp:3704
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:3702
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:3701
int bufCountVec
Definition ampiFunctions.hpp:3705
int bufTotalSize
Definition ampiFunctions.hpp:3700
~AMPI_Ssend_AdjointHandle()
Definition ampiFunctions.hpp:3712
int dest
Definition ampiFunctions.hpp:3708
Definition ampiFunctions.hpp:3862
int dest
Definition ampiFunctions.hpp:3867
AMPI_Request * request
Definition ampiFunctions.hpp:3870
int tag
Definition ampiFunctions.hpp:3868
MPI_Comm comm
Definition ampiFunctions.hpp:3869
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:3864
DATATYPE * datatype
Definition ampiFunctions.hpp:3866
int count
Definition ampiFunctions.hpp:3865
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:3863
AMPI_Request requestReverse
Definition async.hpp:95
AsyncAdjointHandle()
Definition async.hpp:97
AsyncAdjointHandle * toolHandle
Definition async.hpp:103
AsyncHandle()
Definition async.hpp:105
Definition typeDefinitions.h:54
PrimalFunction funcPrimal
Definition typeDefinitions.h:61
ReverseFunction funcReverse
Definition typeDefinitions.h:59
HandleBase()
Definition typeDefinitions.h:64
ForwardFunction funcForward
Definition typeDefinitions.h:60
Definition async.hpp:111