MeDiPack  1.4.0
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-2026 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 void AMPI_Bsend_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
127 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
128 (void)adType;
129
130 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
131 }
132
133 template<typename DATATYPE>
134 void AMPI_Bsend_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
136 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
137 (void)adType;
138
139 }
140
141 template<typename DATATYPE>
142 int AMPI_Bsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
143 AMPI_Comm comm) {
144 int rStatus;
145 ADToolInterface const* adType = selectADTool(datatype->getADTool());
146
147 if(!adType->isActiveType()) {
148 // call the regular function if the type is not active
149 rStatus = MPI_Bsend(buf, count, datatype->getMpiType(), dest, tag, comm);
150 } else {
151
152 // the type is an AD type so handle the buffers
154 typename DATATYPE::ModifiedType* bufMod = nullptr;
155 int bufElements = 0;
156
157 // compute the total size of the buffer
158 bufElements = count;
159
160 if(datatype->isModifiedBufferRequired() ) {
161 datatype->createModifiedTypeBuffer(bufMod, bufElements);
162 } else {
163 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
164 }
165
166 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
167 if(adType->isHandleRequired()) {
169 }
170 adType->startAssembly(h);
171 if(datatype->isModifiedBufferRequired()) {
172 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
173 }
174
175 if(nullptr != h) {
176 // gather the information for the reverse sweep
177
178 // create the index buffers
179 h->bufCount = datatype->computeActiveElements(count);
180 h->bufTotalSize = datatype->computeActiveElements(bufElements);
181 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
182
183
184
185
186 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
187
188
189 // pack all the variables in the handle
195 h->count = count;
196 h->datatype = datatype;
197 h->dest = dest;
198 h->tag = tag;
199 h->comm = comm;
200 }
201
202
203 rStatus = MPI_Bsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
204 adType->addToolAction(h);
205
206
207 if(nullptr != h) {
208 // handle the recv buffers
209 }
210
211 adType->stopAssembly(h);
212
213 if(datatype->isModifiedBufferRequired() ) {
214 datatype->deleteModifiedTypeBuffer(bufMod);
215 }
216
217 // handle is deleted by the AD tool
218 }
219
220 return rStatus;
221 }
222
223#endif
224#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
225 template<typename DATATYPE>
228 typename DATATYPE::IndexType* bufIndices;
229 typename DATATYPE::PrimalType* bufPrimals;
230 /* required for async */ void* bufAdjoints;
233 int count;
234 DATATYPE* datatype;
235 int dest;
236 int tag;
238
240 if(nullptr != bufIndices) {
241 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
242 bufIndices = nullptr;
243 }
244 if(nullptr != bufPrimals) {
245 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
246 bufPrimals = nullptr;
247 }
248 }
249 };
250
251 template<typename DATATYPE>
253 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
254 typename DATATYPE::ModifiedType* bufMod;
255 int count;
256 DATATYPE* datatype;
257 int dest;
258 int tag;
261 };
262
263 template<typename DATATYPE>
264 void AMPI_Ibsend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
266 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
267 (void)adType;
268
269 h->bufAdjoints = nullptr;
270 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
271 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
272 // Primal buffers are always linear in space so we can accesses them in one sweep
273 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
274
275
277 &h->requestReverse);
278
279 }
280
281 template<typename DATATYPE>
282 void AMPI_Ibsend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
283
285 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
286 (void)adType;
287 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
288
289 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
290 }
291
292 template<typename DATATYPE>
293 void AMPI_Ibsend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
295 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
296 (void)adType;
297
298 h->bufAdjoints = nullptr;
299 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
300 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
301 // Adjoint buffers are always linear in space so we can accesses them in one sweep
302 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
303
304
306 &h->requestReverse);
307
308 }
309
310 template<typename DATATYPE>
311 void AMPI_Ibsend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
312
314 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
315 (void)adType;
316 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
317
318 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
319 }
320
321 template<typename DATATYPE>
322 void AMPI_Ibsend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
324 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
325 (void)adType;
326
327 h->bufAdjoints = nullptr;
328 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
329 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
330
332 &h->requestReverse);
333
334 }
335
336 template<typename DATATYPE>
337 void AMPI_Ibsend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
338
340 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
341 (void)adType;
342 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
343
344 // Adjoint buffers are always linear in space so we can accesses them in one sweep
345 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
346 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
347 }
348
349 template<typename DATATYPE>
350 void AMPI_Ibsend_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
352 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
353 (void)adType;
354
355 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
356 }
357
358 template<typename DATATYPE>
359 void AMPI_Ibsend_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
361 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
362 (void)adType;
363
364 }
365
366 template<typename DATATYPE>
367 int AMPI_Ibsend_finish(HandleBase* handle);
368 template<typename DATATYPE>
369 int AMPI_Ibsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
370 AMPI_Comm comm, AMPI_Request* request) {
371 int rStatus;
372 ADToolInterface const* adType = selectADTool(datatype->getADTool());
373
374 if(!adType->isActiveType()) {
375 // call the regular function if the type is not active
376 rStatus = MPI_Ibsend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
377 } else {
378
379 // the type is an AD type so handle the buffers
381 typename DATATYPE::ModifiedType* bufMod = nullptr;
382 int bufElements = 0;
383
384 // compute the total size of the buffer
385 bufElements = count;
386
387 if(datatype->isModifiedBufferRequired() ) {
388 datatype->createModifiedTypeBuffer(bufMod, bufElements);
389 } else {
390 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
391 }
392
393 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
394 if(adType->isHandleRequired()) {
396 }
397 adType->startAssembly(h);
398 if(datatype->isModifiedBufferRequired()) {
399 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
400 }
401
402 if(nullptr != h) {
403 // gather the information for the reverse sweep
404
405 // create the index buffers
406 h->bufCount = datatype->computeActiveElements(count);
407 h->bufTotalSize = datatype->computeActiveElements(bufElements);
408 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
409
410
411
412
413 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
414
415
416 // pack all the variables in the handle
422 h->count = count;
423 h->datatype = datatype;
424 h->dest = dest;
425 h->tag = tag;
426 h->comm = comm;
427 }
428
429
430 rStatus = MPI_Ibsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
431
433 asyncHandle->buf = buf;
434 asyncHandle->bufMod = bufMod;
435 asyncHandle->count = count;
436 asyncHandle->datatype = datatype;
437 asyncHandle->dest = dest;
438 asyncHandle->tag = tag;
439 asyncHandle->comm = comm;
440 asyncHandle->toolHandle = h;
441 request->handle = asyncHandle;
443
444 // create adjoint wait
445 if(nullptr != h) {
448 adType->addToolAction(waitH);
449 }
450 }
451
452 return rStatus;
453 }
454
455 template<typename DATATYPE>
457 int rStatus = 0;
458
459 AMPI_Ibsend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Ibsend_AsyncHandle<DATATYPE>*>(handle);
460 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
461 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
462 int count = asyncHandle->count;
463 DATATYPE* datatype = asyncHandle->datatype;
464 int dest = asyncHandle->dest;
465 int tag = asyncHandle->tag;
466 AMPI_Comm comm = asyncHandle->comm;
467 AMPI_Request* request = asyncHandle->request;
469 ADToolInterface const* adType = selectADTool(datatype->getADTool());
470 MEDI_UNUSED(h); // Unused generated to ignore warnings
471 MEDI_UNUSED(buf); // Unused generated to ignore warnings
472 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
473 MEDI_UNUSED(count); // Unused generated to ignore warnings
474 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
475 MEDI_UNUSED(dest); // Unused generated to ignore warnings
476 MEDI_UNUSED(tag); // Unused generated to ignore warnings
477 MEDI_UNUSED(comm); // Unused generated to ignore warnings
478 MEDI_UNUSED(request); // Unused generated to ignore warnings
479
480 delete asyncHandle;
481
482 if(adType->isActiveType()) {
483
484 adType->addToolAction(h);
485
486
487 if(nullptr != h) {
488 // handle the recv buffers
489 }
490
491 adType->stopAssembly(h);
492
493 if(datatype->isModifiedBufferRequired() ) {
494 datatype->deleteModifiedTypeBuffer(bufMod);
495 }
496
497 // handle is deleted by the AD tool
498 }
499
500 return rStatus;
501 }
502
503#endif
504#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
505
506 template<typename DATATYPE>
508 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
509 typename DATATYPE::ModifiedType* bufMod;
510 int count;
511 DATATYPE* datatype;
512 int dest;
513 int tag;
516 };
517
518
519 template<typename DATATYPE>
520 void AMPI_Bsend_init_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
522 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
523 (void)adType;
524
525 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
526 }
527
528 template<typename DATATYPE>
529 void AMPI_Bsend_init_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
531 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
532 (void)adType;
533
534 }
535
536 template<typename DATATYPE>
537 int AMPI_Bsend_init_preStart(HandleBase* handle);
538 template<typename DATATYPE>
539 int AMPI_Bsend_init_finish(HandleBase* handle);
540 template<typename DATATYPE>
541 int AMPI_Bsend_init_postEnd(HandleBase* handle);
542 template<typename DATATYPE>
543 int AMPI_Bsend_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
544 AMPI_Comm comm, AMPI_Request* request) {
545 int rStatus;
546 ADToolInterface const* adType = selectADTool(datatype->getADTool());
547
548 if(!adType->isActiveType()) {
549 // call the regular function if the type is not active
550 rStatus = MPI_Bsend_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
551 } else {
552
553 // the type is an AD type so handle the buffers
555 typename DATATYPE::ModifiedType* bufMod = nullptr;
556 int bufElements = 0;
557
558 // compute the total size of the buffer
559 bufElements = count;
560
561 if(datatype->isModifiedBufferRequired() ) {
562 datatype->createModifiedTypeBuffer(bufMod, bufElements);
563 } else {
564 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
565 }
566
567 rStatus = MPI_Bsend_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
568
570 asyncHandle->buf = buf;
571 asyncHandle->bufMod = bufMod;
572 asyncHandle->count = count;
573 asyncHandle->datatype = datatype;
574 asyncHandle->dest = dest;
575 asyncHandle->tag = tag;
576 asyncHandle->comm = comm;
577 asyncHandle->toolHandle = h;
578 request->handle = asyncHandle;
582 }
583
584 return rStatus;
585 }
586
587 template<typename DATATYPE>
589 int rStatus = 0;
590
592 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
593 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
594 int count = asyncHandle->count;
595 DATATYPE* datatype = asyncHandle->datatype;
596 int dest = asyncHandle->dest;
597 int tag = asyncHandle->tag;
598 AMPI_Comm comm = asyncHandle->comm;
599 AMPI_Request* request = asyncHandle->request;
601 ADToolInterface const* adType = selectADTool(datatype->getADTool());
602 MEDI_UNUSED(h); // Unused generated to ignore warnings
603 MEDI_UNUSED(buf); // Unused generated to ignore warnings
604 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
605 MEDI_UNUSED(count); // Unused generated to ignore warnings
606 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
607 MEDI_UNUSED(dest); // Unused generated to ignore warnings
608 MEDI_UNUSED(tag); // Unused generated to ignore warnings
609 MEDI_UNUSED(comm); // Unused generated to ignore warnings
610 MEDI_UNUSED(request); // Unused generated to ignore warnings
611
612
613 if(adType->isActiveType()) {
614
615 int bufElements = 0;
616
617 // recompute the total size of the buffer
618 bufElements = count;
619 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
620 if(adType->isHandleRequired()) {
622 }
623 adType->startAssembly(h);
624 if(datatype->isModifiedBufferRequired()) {
625 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
626 }
627
628 if(nullptr != h) {
629 // gather the information for the reverse sweep
630
631 // create the index buffers
632 h->bufCount = datatype->computeActiveElements(count);
633 h->bufTotalSize = datatype->computeActiveElements(bufElements);
634 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
635
636
637
638
639 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
640
641
642 // pack all the variables in the handle
648 h->count = count;
649 h->datatype = datatype;
650 h->dest = dest;
651 h->tag = tag;
652 h->comm = comm;
653 }
654
655
656 asyncHandle->toolHandle = h;
657
658 // create adjoint wait
659 if(nullptr != h) {
662 adType->addToolAction(waitH);
663 }
664 }
665
666 return rStatus;
667 }
668
669 template<typename DATATYPE>
671 int rStatus = 0;
672
674 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
675 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
676 int count = asyncHandle->count;
677 DATATYPE* datatype = asyncHandle->datatype;
678 int dest = asyncHandle->dest;
679 int tag = asyncHandle->tag;
680 AMPI_Comm comm = asyncHandle->comm;
681 AMPI_Request* request = asyncHandle->request;
683 ADToolInterface const* adType = selectADTool(datatype->getADTool());
684 MEDI_UNUSED(h); // Unused generated to ignore warnings
685 MEDI_UNUSED(buf); // Unused generated to ignore warnings
686 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
687 MEDI_UNUSED(count); // Unused generated to ignore warnings
688 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
689 MEDI_UNUSED(dest); // Unused generated to ignore warnings
690 MEDI_UNUSED(tag); // Unused generated to ignore warnings
691 MEDI_UNUSED(comm); // Unused generated to ignore warnings
692 MEDI_UNUSED(request); // Unused generated to ignore warnings
693
694
695 if(adType->isActiveType()) {
696
697 adType->addToolAction(h);
698
699
700 if(nullptr != h) {
701 // handle the recv buffers
702 }
703
704 adType->stopAssembly(h);
705 }
706
707 return rStatus;
708 }
709
710 template<typename DATATYPE>
712 int rStatus = 0;
713
715 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
716 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
717 int count = asyncHandle->count;
718 DATATYPE* datatype = asyncHandle->datatype;
719 int dest = asyncHandle->dest;
720 int tag = asyncHandle->tag;
721 AMPI_Comm comm = asyncHandle->comm;
722 AMPI_Request* request = asyncHandle->request;
724 ADToolInterface const* adType = selectADTool(datatype->getADTool());
725 MEDI_UNUSED(h); // Unused generated to ignore warnings
726 MEDI_UNUSED(buf); // Unused generated to ignore warnings
727 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
728 MEDI_UNUSED(count); // Unused generated to ignore warnings
729 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
730 MEDI_UNUSED(dest); // Unused generated to ignore warnings
731 MEDI_UNUSED(tag); // Unused generated to ignore warnings
732 MEDI_UNUSED(comm); // Unused generated to ignore warnings
733 MEDI_UNUSED(request); // Unused generated to ignore warnings
734
735 delete asyncHandle;
736
737 if(adType->isActiveType()) {
738
739
740 if(datatype->isModifiedBufferRequired() ) {
741 datatype->deleteModifiedTypeBuffer(bufMod);
742 }
743
744 // handle is deleted by the AD tool
745 }
746
747 return rStatus;
748 }
749
750#endif
751#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
752 template<typename DATATYPE>
755 typename DATATYPE::IndexType* bufIndices;
756 typename DATATYPE::PrimalType* bufPrimals;
757 typename DATATYPE::PrimalType* bufOldPrimals;
758 /* required for async */ void* bufAdjoints;
761 int count;
762 DATATYPE* datatype;
765
767 if(nullptr != bufIndices) {
768 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
769 bufIndices = nullptr;
770 }
771 if(nullptr != bufPrimals) {
772 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
773 bufPrimals = nullptr;
774 }
775 if(nullptr != bufOldPrimals) {
776 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
777 bufOldPrimals = nullptr;
778 }
779 }
780 };
781
782 template<typename DATATYPE>
784 typename DATATYPE::Type* buf;
785 typename DATATYPE::ModifiedType* bufMod;
786 int count;
787 DATATYPE* datatype;
791 };
792
793 template<typename DATATYPE>
794 void AMPI_Imrecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
796 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
797 (void)adType;
798
799 h->bufAdjoints = nullptr;
800 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
801 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
802
804 h->reverse_send);
805
806 }
807
808 template<typename DATATYPE>
809 void AMPI_Imrecv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
810
812 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
813 (void)adType;
814 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
815
816 if(adType->isOldPrimalsRequired()) {
817 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
818 }
819 // Primal buffers are always linear in space so we can accesses them in one sweep
820 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
821 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
822 }
823
824 template<typename DATATYPE>
825 void AMPI_Imrecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
827 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
828 (void)adType;
829
830 h->bufAdjoints = nullptr;
831 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
832 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
833
835 h->reverse_send);
836
837 }
838
839 template<typename DATATYPE>
840 void AMPI_Imrecv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
841
843 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
844 (void)adType;
845 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
846
847 // Adjoint buffers are always linear in space so we can accesses them in one sweep
848 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
849 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
850 }
851
852 template<typename DATATYPE>
853 void AMPI_Imrecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
855 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
856 (void)adType;
857
858 h->bufAdjoints = nullptr;
859 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
860 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
861 // Adjoint buffers are always linear in space so we can accesses them in one sweep
862 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
863
864 if(adType->isOldPrimalsRequired()) {
865 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
866 }
867
869 h->reverse_send);
870
871 }
872
873 template<typename DATATYPE>
874 void AMPI_Imrecv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
875
877 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
878 (void)adType;
879 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
880
881 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
882 }
883
884 template<typename DATATYPE>
885 void AMPI_Imrecv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
887 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
888 (void)adType;
889
890 }
891
892 template<typename DATATYPE>
893 void AMPI_Imrecv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
895 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
896 (void)adType;
897
898 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
899 }
900
901 template<typename DATATYPE>
902 int AMPI_Imrecv_finish(HandleBase* handle);
903 template<typename DATATYPE>
904 int AMPI_Imrecv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, AMPI_Message* message,
905 AMPI_Request* request, IrecvAdjCall reverse_send = IrecvAdjCall::Isend) {
906 int rStatus;
907 ADToolInterface const* adType = selectADTool(datatype->getADTool());
908
909 if(!adType->isActiveType()) {
910 // call the regular function if the type is not active
911 rStatus = MPI_Imrecv(buf, count, datatype->getMpiType(), &message->message, &request->request);
912 } else {
913
914 // the type is an AD type so handle the buffers
916 typename DATATYPE::ModifiedType* bufMod = nullptr;
917 int bufElements = 0;
918
919 // compute the total size of the buffer
920 bufElements = count;
921
922 if(datatype->isModifiedBufferRequired() ) {
923 datatype->createModifiedTypeBuffer(bufMod, bufElements);
924 } else {
925 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
926 }
927
928 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
929 if(adType->isHandleRequired()) {
931 }
932 adType->startAssembly(h);
933
934 if(nullptr != h) {
935 // gather the information for the reverse sweep
936
937 // create the index buffers
938 h->bufCount = datatype->computeActiveElements(count);
939 h->bufTotalSize = datatype->computeActiveElements(bufElements);
940 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
941
942
943 // extract the old primal values from the recv buffer if the AD tool
944 // needs the primal values reset
945 if(adType->isOldPrimalsRequired()) {
946 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
947 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
948 }
949
950
951
952 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
953
954 // pack all the variables in the handle
960 h->count = count;
961 h->datatype = datatype;
962 h->message = *message;
963 h->reverse_send = reverse_send;
964 }
965
966 if(!datatype->isModifiedBufferRequired()) {
967 datatype->clearIndices(buf, 0, count);
968 }
969
970 rStatus = MPI_Imrecv(bufMod, count, datatype->getModifiedMpiType(), &message->message, &request->request);
971
973 asyncHandle->buf = buf;
974 asyncHandle->bufMod = bufMod;
975 asyncHandle->count = count;
976 asyncHandle->datatype = datatype;
977 asyncHandle->message = message;
978 asyncHandle->reverse_send = reverse_send;
979 asyncHandle->toolHandle = h;
980 request->handle = asyncHandle;
982
983 // create adjoint wait
984 if(nullptr != h) {
987 adType->addToolAction(waitH);
988 }
989 }
990
991 return rStatus;
992 }
993
994 template<typename DATATYPE>
996 int rStatus = 0;
997
998 AMPI_Imrecv_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Imrecv_AsyncHandle<DATATYPE>*>(handle);
999 typename DATATYPE::Type* buf = asyncHandle->buf;
1000 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1001 int count = asyncHandle->count;
1002 DATATYPE* datatype = asyncHandle->datatype;
1003 AMPI_Message* message = asyncHandle->message;
1004 AMPI_Request* request = asyncHandle->request;
1005 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
1007 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1008 MEDI_UNUSED(h); // Unused generated to ignore warnings
1009 MEDI_UNUSED(buf); // Unused generated to ignore warnings
1010 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
1011 MEDI_UNUSED(count); // Unused generated to ignore warnings
1012 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
1013 MEDI_UNUSED(message); // Unused generated to ignore warnings
1014 MEDI_UNUSED(request); // Unused generated to ignore warnings
1015 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
1016
1017 delete asyncHandle;
1018
1019 if(adType->isActiveType()) {
1020
1021 adType->addToolAction(h);
1022
1023 if(datatype->isModifiedBufferRequired()) {
1024 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
1025 }
1026
1027 if(nullptr != h) {
1028 // handle the recv buffers
1029 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
1030 }
1031
1032 adType->stopAssembly(h);
1033
1034 if(datatype->isModifiedBufferRequired() ) {
1035 datatype->deleteModifiedTypeBuffer(bufMod);
1036 }
1037
1038 // handle is deleted by the AD tool
1039 }
1040
1041 return rStatus;
1042 }
1043
1044#endif
1045#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
1046 template<typename DATATYPE>
1049 typename DATATYPE::IndexType* bufIndices;
1050 typename DATATYPE::PrimalType* bufPrimals;
1051 typename DATATYPE::PrimalType* bufOldPrimals;
1052 /* required for async */ void* bufAdjoints;
1056 DATATYPE* datatype;
1058 int tag;
1061
1063 if(nullptr != bufIndices) {
1064 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
1065 bufIndices = nullptr;
1066 }
1067 if(nullptr != bufPrimals) {
1068 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
1069 bufPrimals = nullptr;
1070 }
1071 if(nullptr != bufOldPrimals) {
1072 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
1073 bufOldPrimals = nullptr;
1074 }
1075 }
1076 };
1077
1078 template<typename DATATYPE>
1080 typename DATATYPE::Type* buf;
1081 typename DATATYPE::ModifiedType* bufMod;
1083 DATATYPE* datatype;
1085 int tag;
1089 };
1090
1091 template<typename DATATYPE>
1092 void AMPI_Irecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1094 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1095 (void)adType;
1096
1097 h->bufAdjoints = nullptr;
1098 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1099 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1100
1103
1104 }
1105
1106 template<typename DATATYPE>
1107 void AMPI_Irecv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1108
1110 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1111 (void)adType;
1112 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1113
1114 if(adType->isOldPrimalsRequired()) {
1115 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
1116 }
1117 // Primal buffers are always linear in space so we can accesses them in one sweep
1118 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1119 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1120 }
1121
1122 template<typename DATATYPE>
1123 void AMPI_Irecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1125 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1126 (void)adType;
1127
1128 h->bufAdjoints = nullptr;
1129 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1130 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1131
1134
1135 }
1136
1137 template<typename DATATYPE>
1138 void AMPI_Irecv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1139
1141 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1142 (void)adType;
1143 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1144
1145 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1146 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1147 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1148 }
1149
1150 template<typename DATATYPE>
1151 void AMPI_Irecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
1153 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1154 (void)adType;
1155
1156 h->bufAdjoints = nullptr;
1157 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1158 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1159 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1160 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1161
1162 if(adType->isOldPrimalsRequired()) {
1163 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
1164 }
1165
1168
1169 }
1170
1171 template<typename DATATYPE>
1172 void AMPI_Irecv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1173
1175 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1176 (void)adType;
1177 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1178
1179 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1180 }
1181
1182 template<typename DATATYPE>
1183 void AMPI_Irecv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
1185 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1186 (void)adType;
1187
1188 }
1189
1190 template<typename DATATYPE>
1191 void AMPI_Irecv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
1193 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1194 (void)adType;
1195
1196 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
1197 }
1198
1199 template<typename DATATYPE>
1200 int AMPI_Irecv_finish(HandleBase* handle);
1201 template<typename DATATYPE>
1202 int AMPI_Irecv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int source, int tag, AMPI_Comm comm,
1203 AMPI_Request* request, IrecvAdjCall reverse_send = IrecvAdjCall::Isend) {
1204 int rStatus;
1205 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1206
1207 if(!adType->isActiveType()) {
1208 // call the regular function if the type is not active
1209 rStatus = MPI_Irecv(buf, count, datatype->getMpiType(), source, tag, comm, &request->request);
1210 } else {
1211
1212 // the type is an AD type so handle the buffers
1214 typename DATATYPE::ModifiedType* bufMod = nullptr;
1215 int bufElements = 0;
1216
1217 // compute the total size of the buffer
1218 bufElements = count;
1219
1220 if(datatype->isModifiedBufferRequired() ) {
1221 datatype->createModifiedTypeBuffer(bufMod, bufElements);
1222 } else {
1223 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
1224 }
1225
1226 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
1227 if(adType->isHandleRequired()) {
1229 }
1230 adType->startAssembly(h);
1231
1232 if(nullptr != h) {
1233 // gather the information for the reverse sweep
1234
1235 // create the index buffers
1236 h->bufCount = datatype->computeActiveElements(count);
1237 h->bufTotalSize = datatype->computeActiveElements(bufElements);
1238 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
1239
1240
1241 // extract the old primal values from the recv buffer if the AD tool
1242 // needs the primal values reset
1243 if(adType->isOldPrimalsRequired()) {
1244 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
1245 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
1246 }
1247
1248
1249
1250 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
1251
1252 // pack all the variables in the handle
1258 h->count = count;
1259 h->datatype = datatype;
1260 h->source = source;
1261 h->tag = tag;
1262 h->comm = comm;
1263 h->reverse_send = reverse_send;
1264 }
1265
1266 if(!datatype->isModifiedBufferRequired()) {
1267 datatype->clearIndices(buf, 0, count);
1268 }
1269
1270 rStatus = MPI_Irecv(bufMod, count, datatype->getModifiedMpiType(), source, tag, comm, &request->request);
1271
1273 asyncHandle->buf = buf;
1274 asyncHandle->bufMod = bufMod;
1275 asyncHandle->count = count;
1276 asyncHandle->datatype = datatype;
1277 asyncHandle->source = source;
1278 asyncHandle->tag = tag;
1279 asyncHandle->comm = comm;
1280 asyncHandle->reverse_send = reverse_send;
1281 asyncHandle->toolHandle = h;
1282 request->handle = asyncHandle;
1284
1285 // create adjoint wait
1286 if(nullptr != h) {
1289 adType->addToolAction(waitH);
1290 }
1291 }
1292
1293 return rStatus;
1294 }
1295
1296 template<typename DATATYPE>
1298 int rStatus = 0;
1299
1300 AMPI_Irecv_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Irecv_AsyncHandle<DATATYPE>*>(handle);
1301 typename DATATYPE::Type* buf = asyncHandle->buf;
1302 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1303 int count = asyncHandle->count;
1304 DATATYPE* datatype = asyncHandle->datatype;
1305 int source = asyncHandle->source;
1306 int tag = asyncHandle->tag;
1307 AMPI_Comm comm = asyncHandle->comm;
1308 AMPI_Request* request = asyncHandle->request;
1309 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
1311 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1312 MEDI_UNUSED(h); // Unused generated to ignore warnings
1313 MEDI_UNUSED(buf); // Unused generated to ignore warnings
1314 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
1315 MEDI_UNUSED(count); // Unused generated to ignore warnings
1316 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
1317 MEDI_UNUSED(source); // Unused generated to ignore warnings
1318 MEDI_UNUSED(tag); // Unused generated to ignore warnings
1319 MEDI_UNUSED(comm); // Unused generated to ignore warnings
1320 MEDI_UNUSED(request); // Unused generated to ignore warnings
1321 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
1322
1323 delete asyncHandle;
1324
1325 if(adType->isActiveType()) {
1326
1327 adType->addToolAction(h);
1328
1329 if(datatype->isModifiedBufferRequired()) {
1330 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
1331 }
1332
1333 if(nullptr != h) {
1334 // handle the recv buffers
1335 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
1336 }
1337
1338 adType->stopAssembly(h);
1339
1340 if(datatype->isModifiedBufferRequired() ) {
1341 datatype->deleteModifiedTypeBuffer(bufMod);
1342 }
1343
1344 // handle is deleted by the AD tool
1345 }
1346
1347 return rStatus;
1348 }
1349
1350#endif
1351#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
1352 template<typename DATATYPE>
1355 typename DATATYPE::IndexType* bufIndices;
1356 typename DATATYPE::PrimalType* bufPrimals;
1357 /* required for async */ void* bufAdjoints;
1361 DATATYPE* datatype;
1362 int dest;
1363 int tag;
1365
1367 if(nullptr != bufIndices) {
1368 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
1369 bufIndices = nullptr;
1370 }
1371 if(nullptr != bufPrimals) {
1372 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
1373 bufPrimals = nullptr;
1374 }
1375 }
1376 };
1377
1378 template<typename DATATYPE>
1380 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
1381 typename DATATYPE::ModifiedType* bufMod;
1383 DATATYPE* datatype;
1384 int dest;
1385 int tag;
1388 };
1389
1390 template<typename DATATYPE>
1391 void AMPI_Irsend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1393 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1394 (void)adType;
1395
1396 h->bufAdjoints = nullptr;
1397 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1398 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1399 // Primal buffers are always linear in space so we can accesses them in one sweep
1400 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1401
1402
1404 &h->requestReverse);
1405
1406 }
1407
1408 template<typename DATATYPE>
1409 void AMPI_Irsend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1410
1412 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1413 (void)adType;
1414 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1415
1416 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1417 }
1418
1419 template<typename DATATYPE>
1420 void AMPI_Irsend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1422 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1423 (void)adType;
1424
1425 h->bufAdjoints = nullptr;
1426 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1427 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1428 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1429 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1430
1431
1433 &h->requestReverse);
1434
1435 }
1436
1437 template<typename DATATYPE>
1438 void AMPI_Irsend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1439
1441 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1442 (void)adType;
1443 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1444
1445 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1446 }
1447
1448 template<typename DATATYPE>
1449 void AMPI_Irsend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
1451 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1452 (void)adType;
1453
1454 h->bufAdjoints = nullptr;
1455 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1456 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1457
1459 &h->requestReverse);
1460
1461 }
1462
1463 template<typename DATATYPE>
1464 void AMPI_Irsend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1465
1467 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1468 (void)adType;
1469 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1470
1471 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1472 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1473 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1474 }
1475
1476 template<typename DATATYPE>
1477 void AMPI_Irsend_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
1479 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1480 (void)adType;
1481
1482 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
1483 }
1484
1485 template<typename DATATYPE>
1486 void AMPI_Irsend_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
1488 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1489 (void)adType;
1490
1491 }
1492
1493 template<typename DATATYPE>
1494 int AMPI_Irsend_finish(HandleBase* handle);
1495 template<typename DATATYPE>
1496 int AMPI_Irsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
1497 AMPI_Comm comm, AMPI_Request* request) {
1498 int rStatus;
1499 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1500
1501 if(!adType->isActiveType()) {
1502 // call the regular function if the type is not active
1503 rStatus = MPI_Irsend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
1504 } else {
1505
1506 // the type is an AD type so handle the buffers
1508 typename DATATYPE::ModifiedType* bufMod = nullptr;
1509 int bufElements = 0;
1510
1511 // compute the total size of the buffer
1512 bufElements = count;
1513
1514 if(datatype->isModifiedBufferRequired() ) {
1515 datatype->createModifiedTypeBuffer(bufMod, bufElements);
1516 } else {
1517 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
1518 }
1519
1520 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
1521 if(adType->isHandleRequired()) {
1523 }
1524 adType->startAssembly(h);
1525 if(datatype->isModifiedBufferRequired()) {
1526 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
1527 }
1528
1529 if(nullptr != h) {
1530 // gather the information for the reverse sweep
1531
1532 // create the index buffers
1533 h->bufCount = datatype->computeActiveElements(count);
1534 h->bufTotalSize = datatype->computeActiveElements(bufElements);
1535 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
1536
1537
1538
1539
1540 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
1541
1542
1543 // pack all the variables in the handle
1549 h->count = count;
1550 h->datatype = datatype;
1551 h->dest = dest;
1552 h->tag = tag;
1553 h->comm = comm;
1554 }
1555
1556
1557 rStatus = MPI_Irsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
1558
1560 asyncHandle->buf = buf;
1561 asyncHandle->bufMod = bufMod;
1562 asyncHandle->count = count;
1563 asyncHandle->datatype = datatype;
1564 asyncHandle->dest = dest;
1565 asyncHandle->tag = tag;
1566 asyncHandle->comm = comm;
1567 asyncHandle->toolHandle = h;
1568 request->handle = asyncHandle;
1570
1571 // create adjoint wait
1572 if(nullptr != h) {
1575 adType->addToolAction(waitH);
1576 }
1577 }
1578
1579 return rStatus;
1580 }
1581
1582 template<typename DATATYPE>
1584 int rStatus = 0;
1585
1586 AMPI_Irsend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Irsend_AsyncHandle<DATATYPE>*>(handle);
1587 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
1588 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1589 int count = asyncHandle->count;
1590 DATATYPE* datatype = asyncHandle->datatype;
1591 int dest = asyncHandle->dest;
1592 int tag = asyncHandle->tag;
1593 AMPI_Comm comm = asyncHandle->comm;
1594 AMPI_Request* request = asyncHandle->request;
1596 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1597 MEDI_UNUSED(h); // Unused generated to ignore warnings
1598 MEDI_UNUSED(buf); // Unused generated to ignore warnings
1599 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
1600 MEDI_UNUSED(count); // Unused generated to ignore warnings
1601 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
1602 MEDI_UNUSED(dest); // Unused generated to ignore warnings
1603 MEDI_UNUSED(tag); // Unused generated to ignore warnings
1604 MEDI_UNUSED(comm); // Unused generated to ignore warnings
1605 MEDI_UNUSED(request); // Unused generated to ignore warnings
1606
1607 delete asyncHandle;
1608
1609 if(adType->isActiveType()) {
1610
1611 adType->addToolAction(h);
1612
1613
1614 if(nullptr != h) {
1615 // handle the recv buffers
1616 }
1617
1618 adType->stopAssembly(h);
1619
1620 if(datatype->isModifiedBufferRequired() ) {
1621 datatype->deleteModifiedTypeBuffer(bufMod);
1622 }
1623
1624 // handle is deleted by the AD tool
1625 }
1626
1627 return rStatus;
1628 }
1629
1630#endif
1631#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
1632 template<typename DATATYPE>
1635 typename DATATYPE::IndexType* bufIndices;
1636 typename DATATYPE::PrimalType* bufPrimals;
1637 /* required for async */ void* bufAdjoints;
1641 DATATYPE* datatype;
1642 int dest;
1643 int tag;
1645
1647 if(nullptr != bufIndices) {
1648 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
1649 bufIndices = nullptr;
1650 }
1651 if(nullptr != bufPrimals) {
1652 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
1653 bufPrimals = nullptr;
1654 }
1655 }
1656 };
1657
1658 template<typename DATATYPE>
1660 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
1661 typename DATATYPE::ModifiedType* bufMod;
1663 DATATYPE* datatype;
1664 int dest;
1665 int tag;
1668 };
1669
1670 template<typename DATATYPE>
1671 void AMPI_Isend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1673 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1674 (void)adType;
1675
1676 h->bufAdjoints = nullptr;
1677 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1678 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1679 // Primal buffers are always linear in space so we can accesses them in one sweep
1680 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1681
1682
1684 &h->requestReverse);
1685
1686 }
1687
1688 template<typename DATATYPE>
1689 void AMPI_Isend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1690
1692 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1693 (void)adType;
1694 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1695
1696 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1697 }
1698
1699 template<typename DATATYPE>
1700 void AMPI_Isend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1702 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1703 (void)adType;
1704
1705 h->bufAdjoints = nullptr;
1706 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1707 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1708 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1709 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1710
1711
1713 &h->requestReverse);
1714
1715 }
1716
1717 template<typename DATATYPE>
1718 void AMPI_Isend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1719
1721 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1722 (void)adType;
1723 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1724
1725 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1726 }
1727
1728 template<typename DATATYPE>
1729 void AMPI_Isend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
1731 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1732 (void)adType;
1733
1734 h->bufAdjoints = nullptr;
1735 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1736 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1737
1739 &h->requestReverse);
1740
1741 }
1742
1743 template<typename DATATYPE>
1744 void AMPI_Isend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1745
1747 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1748 (void)adType;
1749 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1750
1751 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1752 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1753 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
1754 }
1755
1756 template<typename DATATYPE>
1757 void AMPI_Isend_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
1759 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1760 (void)adType;
1761
1762 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
1763 }
1764
1765 template<typename DATATYPE>
1766 void AMPI_Isend_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
1768 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1769 (void)adType;
1770
1771 }
1772
1773 template<typename DATATYPE>
1774 int AMPI_Isend_finish(HandleBase* handle);
1775 template<typename DATATYPE>
1776 int AMPI_Isend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
1777 AMPI_Comm comm, AMPI_Request* request) {
1778 int rStatus;
1779 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1780
1781 if(!adType->isActiveType()) {
1782 // call the regular function if the type is not active
1783 rStatus = MPI_Isend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
1784 } else {
1785
1786 // the type is an AD type so handle the buffers
1788 typename DATATYPE::ModifiedType* bufMod = nullptr;
1789 int bufElements = 0;
1790
1791 // compute the total size of the buffer
1792 bufElements = count;
1793
1794 if(datatype->isModifiedBufferRequired() ) {
1795 datatype->createModifiedTypeBuffer(bufMod, bufElements);
1796 } else {
1797 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
1798 }
1799
1800 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
1801 if(adType->isHandleRequired()) {
1803 }
1804 adType->startAssembly(h);
1805 if(datatype->isModifiedBufferRequired()) {
1806 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
1807 }
1808
1809 if(nullptr != h) {
1810 // gather the information for the reverse sweep
1811
1812 // create the index buffers
1813 h->bufCount = datatype->computeActiveElements(count);
1814 h->bufTotalSize = datatype->computeActiveElements(bufElements);
1815 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
1816
1817
1818
1819
1820 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
1821
1822
1823 // pack all the variables in the handle
1829 h->count = count;
1830 h->datatype = datatype;
1831 h->dest = dest;
1832 h->tag = tag;
1833 h->comm = comm;
1834 }
1835
1836
1837 rStatus = MPI_Isend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
1838
1840 asyncHandle->buf = buf;
1841 asyncHandle->bufMod = bufMod;
1842 asyncHandle->count = count;
1843 asyncHandle->datatype = datatype;
1844 asyncHandle->dest = dest;
1845 asyncHandle->tag = tag;
1846 asyncHandle->comm = comm;
1847 asyncHandle->toolHandle = h;
1848 request->handle = asyncHandle;
1850
1851 // create adjoint wait
1852 if(nullptr != h) {
1855 adType->addToolAction(waitH);
1856 }
1857 }
1858
1859 return rStatus;
1860 }
1861
1862 template<typename DATATYPE>
1864 int rStatus = 0;
1865
1866 AMPI_Isend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Isend_AsyncHandle<DATATYPE>*>(handle);
1867 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
1868 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
1869 int count = asyncHandle->count;
1870 DATATYPE* datatype = asyncHandle->datatype;
1871 int dest = asyncHandle->dest;
1872 int tag = asyncHandle->tag;
1873 AMPI_Comm comm = asyncHandle->comm;
1874 AMPI_Request* request = asyncHandle->request;
1876 ADToolInterface const* adType = selectADTool(datatype->getADTool());
1877 MEDI_UNUSED(h); // Unused generated to ignore warnings
1878 MEDI_UNUSED(buf); // Unused generated to ignore warnings
1879 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
1880 MEDI_UNUSED(count); // Unused generated to ignore warnings
1881 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
1882 MEDI_UNUSED(dest); // Unused generated to ignore warnings
1883 MEDI_UNUSED(tag); // Unused generated to ignore warnings
1884 MEDI_UNUSED(comm); // Unused generated to ignore warnings
1885 MEDI_UNUSED(request); // Unused generated to ignore warnings
1886
1887 delete asyncHandle;
1888
1889 if(adType->isActiveType()) {
1890
1891 adType->addToolAction(h);
1892
1893
1894 if(nullptr != h) {
1895 // handle the recv buffers
1896 }
1897
1898 adType->stopAssembly(h);
1899
1900 if(datatype->isModifiedBufferRequired() ) {
1901 datatype->deleteModifiedTypeBuffer(bufMod);
1902 }
1903
1904 // handle is deleted by the AD tool
1905 }
1906
1907 return rStatus;
1908 }
1909
1910#endif
1911#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
1912 template<typename DATATYPE>
1915 typename DATATYPE::IndexType* bufIndices;
1916 typename DATATYPE::PrimalType* bufPrimals;
1917 /* required for async */ void* bufAdjoints;
1921 DATATYPE* datatype;
1922 int dest;
1923 int tag;
1925
1927 if(nullptr != bufIndices) {
1928 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
1929 bufIndices = nullptr;
1930 }
1931 if(nullptr != bufPrimals) {
1932 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
1933 bufPrimals = nullptr;
1934 }
1935 }
1936 };
1937
1938 template<typename DATATYPE>
1940 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
1941 typename DATATYPE::ModifiedType* bufMod;
1943 DATATYPE* datatype;
1944 int dest;
1945 int tag;
1948 };
1949
1950 template<typename DATATYPE>
1951 void AMPI_Issend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
1953 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1954 (void)adType;
1955
1956 h->bufAdjoints = nullptr;
1957 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1958 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
1959 // Primal buffers are always linear in space so we can accesses them in one sweep
1960 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
1961
1962
1964 &h->requestReverse);
1965
1966 }
1967
1968 template<typename DATATYPE>
1969 void AMPI_Issend_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1970
1972 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1973 (void)adType;
1974 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
1975
1976 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
1977 }
1978
1979 template<typename DATATYPE>
1980 void AMPI_Issend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
1982 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
1983 (void)adType;
1984
1985 h->bufAdjoints = nullptr;
1986 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
1987 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
1988 // Adjoint buffers are always linear in space so we can accesses them in one sweep
1989 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
1990
1991
1993 &h->requestReverse);
1994
1995 }
1996
1997 template<typename DATATYPE>
1998 void AMPI_Issend_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
1999
2001 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2002 (void)adType;
2003 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
2004
2005 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2006 }
2007
2008 template<typename DATATYPE>
2009 void AMPI_Issend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
2011 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2012 (void)adType;
2013
2014 h->bufAdjoints = nullptr;
2015 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2016 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2017
2019 &h->requestReverse);
2020
2021 }
2022
2023 template<typename DATATYPE>
2024 void AMPI_Issend_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
2025
2027 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2028 (void)adType;
2029 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
2030
2031 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2032 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2033 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2034 }
2035
2036 template<typename DATATYPE>
2037 void AMPI_Issend_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
2039 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2040 (void)adType;
2041
2042 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
2043 }
2044
2045 template<typename DATATYPE>
2046 void AMPI_Issend_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
2048 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2049 (void)adType;
2050
2051 }
2052
2053 template<typename DATATYPE>
2054 int AMPI_Issend_finish(HandleBase* handle);
2055 template<typename DATATYPE>
2056 int AMPI_Issend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
2057 AMPI_Comm comm, AMPI_Request* request) {
2058 int rStatus;
2059 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2060
2061 if(!adType->isActiveType()) {
2062 // call the regular function if the type is not active
2063 rStatus = MPI_Issend(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
2064 } else {
2065
2066 // the type is an AD type so handle the buffers
2068 typename DATATYPE::ModifiedType* bufMod = nullptr;
2069 int bufElements = 0;
2070
2071 // compute the total size of the buffer
2072 bufElements = count;
2073
2074 if(datatype->isModifiedBufferRequired() ) {
2075 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2076 } else {
2077 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2078 }
2079
2080 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2081 if(adType->isHandleRequired()) {
2083 }
2084 adType->startAssembly(h);
2085 if(datatype->isModifiedBufferRequired()) {
2086 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
2087 }
2088
2089 if(nullptr != h) {
2090 // gather the information for the reverse sweep
2091
2092 // create the index buffers
2093 h->bufCount = datatype->computeActiveElements(count);
2094 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2095 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2096
2097
2098
2099
2100 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
2101
2102
2103 // pack all the variables in the handle
2109 h->count = count;
2110 h->datatype = datatype;
2111 h->dest = dest;
2112 h->tag = tag;
2113 h->comm = comm;
2114 }
2115
2116
2117 rStatus = MPI_Issend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
2118
2120 asyncHandle->buf = buf;
2121 asyncHandle->bufMod = bufMod;
2122 asyncHandle->count = count;
2123 asyncHandle->datatype = datatype;
2124 asyncHandle->dest = dest;
2125 asyncHandle->tag = tag;
2126 asyncHandle->comm = comm;
2127 asyncHandle->toolHandle = h;
2128 request->handle = asyncHandle;
2130
2131 // create adjoint wait
2132 if(nullptr != h) {
2135 adType->addToolAction(waitH);
2136 }
2137 }
2138
2139 return rStatus;
2140 }
2141
2142 template<typename DATATYPE>
2144 int rStatus = 0;
2145
2146 AMPI_Issend_AsyncHandle<DATATYPE>* asyncHandle = static_cast<AMPI_Issend_AsyncHandle<DATATYPE>*>(handle);
2147 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
2148 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2149 int count = asyncHandle->count;
2150 DATATYPE* datatype = asyncHandle->datatype;
2151 int dest = asyncHandle->dest;
2152 int tag = asyncHandle->tag;
2153 AMPI_Comm comm = asyncHandle->comm;
2154 AMPI_Request* request = asyncHandle->request;
2156 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2157 MEDI_UNUSED(h); // Unused generated to ignore warnings
2158 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2159 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2160 MEDI_UNUSED(count); // Unused generated to ignore warnings
2161 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2162 MEDI_UNUSED(dest); // Unused generated to ignore warnings
2163 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2164 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2165 MEDI_UNUSED(request); // Unused generated to ignore warnings
2166
2167 delete asyncHandle;
2168
2169 if(adType->isActiveType()) {
2170
2171 adType->addToolAction(h);
2172
2173
2174 if(nullptr != h) {
2175 // handle the recv buffers
2176 }
2177
2178 adType->stopAssembly(h);
2179
2180 if(datatype->isModifiedBufferRequired() ) {
2181 datatype->deleteModifiedTypeBuffer(bufMod);
2182 }
2183
2184 // handle is deleted by the AD tool
2185 }
2186
2187 return rStatus;
2188 }
2189
2190#endif
2191#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
2192 template<typename DATATYPE>
2195 typename DATATYPE::IndexType* bufIndices;
2196 typename DATATYPE::PrimalType* bufPrimals;
2197 typename DATATYPE::PrimalType* bufOldPrimals;
2198 /* required for async */ void* bufAdjoints;
2202 DATATYPE* datatype;
2206
2208 if(nullptr != bufIndices) {
2209 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
2210 bufIndices = nullptr;
2211 }
2212 if(nullptr != bufPrimals) {
2213 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
2214 bufPrimals = nullptr;
2215 }
2216 if(nullptr != bufOldPrimals) {
2217 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
2218 bufOldPrimals = nullptr;
2219 }
2220 }
2221 };
2222
2223
2224 template<typename DATATYPE>
2225 void AMPI_Mrecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
2227 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2228 (void)adType;
2229
2230 h->bufAdjoints = nullptr;
2231 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2232 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
2233
2235
2236 if(adType->isOldPrimalsRequired()) {
2237 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2238 }
2239 // Primal buffers are always linear in space so we can accesses them in one sweep
2240 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
2241 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
2242 }
2243
2244 template<typename DATATYPE>
2245 void AMPI_Mrecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
2247 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2248 (void)adType;
2249
2250 h->bufAdjoints = nullptr;
2251 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2252 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2253
2255 h->reverse_send);
2256
2257 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2258 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2259 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2260 }
2261
2262 template<typename DATATYPE>
2263 void AMPI_Mrecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
2265 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2266 (void)adType;
2267
2268 h->bufAdjoints = nullptr;
2269 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2270 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2271 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2272 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2273
2274 if(adType->isOldPrimalsRequired()) {
2275 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2276 }
2277
2279 h->reverse_send);
2280
2281 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2282 }
2283
2284 template<typename DATATYPE>
2285 void AMPI_Mrecv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
2287 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2288 (void)adType;
2289
2290 }
2291
2292 template<typename DATATYPE>
2293 void AMPI_Mrecv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
2295 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2296 (void)adType;
2297
2298 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
2299 }
2300
2301 template<typename DATATYPE>
2302 int AMPI_Mrecv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, AMPI_Message* message, AMPI_Status* status,
2303 RecvAdjCall reverse_send = RecvAdjCall::Send) {
2304 int rStatus;
2305 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2306
2307 if(!adType->isActiveType()) {
2308 // call the regular function if the type is not active
2309 rStatus = MPI_Mrecv(buf, count, datatype->getMpiType(), &message->message, status);
2310 } else {
2311
2312 // the type is an AD type so handle the buffers
2314 typename DATATYPE::ModifiedType* bufMod = nullptr;
2315 int bufElements = 0;
2316
2317 // compute the total size of the buffer
2318 bufElements = count;
2319
2320 if(datatype->isModifiedBufferRequired() ) {
2321 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2322 } else {
2323 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2324 }
2325
2326 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2327 if(adType->isHandleRequired()) {
2329 }
2330 adType->startAssembly(h);
2331
2332 if(nullptr != h) {
2333 // gather the information for the reverse sweep
2334
2335 // create the index buffers
2336 h->bufCount = datatype->computeActiveElements(count);
2337 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2338 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2339
2340
2341 // extract the old primal values from the recv buffer if the AD tool
2342 // needs the primal values reset
2343 if(adType->isOldPrimalsRequired()) {
2344 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
2345 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
2346 }
2347
2348
2349
2350 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
2351
2352 // pack all the variables in the handle
2358 h->count = count;
2359 h->datatype = datatype;
2360 h->message = *message;
2361 h->status = status;
2362 h->reverse_send = reverse_send;
2363 }
2364
2365 if(!datatype->isModifiedBufferRequired()) {
2366 datatype->clearIndices(buf, 0, count);
2367 }
2368
2369 rStatus = MPI_Mrecv(bufMod, count, datatype->getModifiedMpiType(), &message->message, status);
2370 adType->addToolAction(h);
2371
2372 if(datatype->isModifiedBufferRequired()) {
2373 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
2374 }
2375
2376 if(nullptr != h) {
2377 // handle the recv buffers
2378 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
2379 }
2380
2381 adType->stopAssembly(h);
2382
2383 if(datatype->isModifiedBufferRequired() ) {
2384 datatype->deleteModifiedTypeBuffer(bufMod);
2385 }
2386
2387 // handle is deleted by the AD tool
2388 }
2389
2390 return rStatus;
2391 }
2392
2393#endif
2394#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
2395 template<typename DATATYPE>
2398 typename DATATYPE::IndexType* bufIndices;
2399 typename DATATYPE::PrimalType* bufPrimals;
2400 typename DATATYPE::PrimalType* bufOldPrimals;
2401 /* required for async */ void* bufAdjoints;
2405 DATATYPE* datatype;
2407 int tag;
2410
2412 if(nullptr != bufIndices) {
2413 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
2414 bufIndices = nullptr;
2415 }
2416 if(nullptr != bufPrimals) {
2417 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
2418 bufPrimals = nullptr;
2419 }
2420 if(nullptr != bufOldPrimals) {
2421 datatype->getADTool().deletePrimalTypeBuffer(bufOldPrimals);
2422 bufOldPrimals = nullptr;
2423 }
2424 }
2425 };
2426
2427
2428 template<typename DATATYPE>
2429 void AMPI_Recv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
2431 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2432 (void)adType;
2433
2434 MPI_Status status;
2435 h->bufAdjoints = nullptr;
2436 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2437 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
2438
2439 AMPI_Recv_pri<DATATYPE>(h->bufPrimals, h->bufCountVec, h->count, h->datatype, h->source, h->tag, h->comm, &status,
2440 h->reverse_send);
2441
2442 if(adType->isOldPrimalsRequired()) {
2443 adjointInterface->getPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2444 }
2445 // Primal buffers are always linear in space so we can accesses them in one sweep
2446 adjointInterface->setPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
2447 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
2448 }
2449
2450 template<typename DATATYPE>
2451 void AMPI_Recv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
2453 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2454 (void)adType;
2455
2456 MPI_Status status;
2457 h->bufAdjoints = nullptr;
2458 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2459 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2460
2461 AMPI_Recv_fwd<DATATYPE>(h->bufAdjoints, h->bufCountVec, h->count, h->datatype, h->source, h->tag, h->comm, &status,
2462 h->reverse_send);
2463
2464 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2465 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2466 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2467 }
2468
2469 template<typename DATATYPE>
2470 void AMPI_Recv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
2472 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2473 (void)adType;
2474
2475 MPI_Status status;
2476 h->bufAdjoints = nullptr;
2477 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2478 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2479 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2480 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2481
2482 if(adType->isOldPrimalsRequired()) {
2483 adjointInterface->setPrimals(h->bufIndices, h->bufOldPrimals, h->bufTotalSize);
2484 }
2485
2486 AMPI_Recv_adj<DATATYPE>(h->bufAdjoints, h->bufCountVec, h->count, h->datatype, h->source, h->tag, h->comm, &status,
2487 h->reverse_send);
2488
2489 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2490 }
2491
2492 template<typename DATATYPE>
2493 void AMPI_Recv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
2495 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2496 (void)adType;
2497
2498 }
2499
2500 template<typename DATATYPE>
2501 void AMPI_Recv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
2503 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2504 (void)adType;
2505
2506 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
2507 }
2508
2509 template<typename DATATYPE>
2510 int AMPI_Recv(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int source, int tag, AMPI_Comm comm,
2511 AMPI_Status* status, RecvAdjCall reverse_send = RecvAdjCall::Send) {
2512 int rStatus;
2513 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2514
2515 if(!adType->isActiveType()) {
2516 // call the regular function if the type is not active
2517 rStatus = MPI_Recv(buf, count, datatype->getMpiType(), source, tag, comm, status);
2518 } else {
2519
2520 // the type is an AD type so handle the buffers
2522 typename DATATYPE::ModifiedType* bufMod = nullptr;
2523 int bufElements = 0;
2524
2525 // compute the total size of the buffer
2526 bufElements = count;
2527
2528 if(datatype->isModifiedBufferRequired() ) {
2529 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2530 } else {
2531 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2532 }
2533
2534 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2535 if(adType->isHandleRequired()) {
2537 }
2538 adType->startAssembly(h);
2539
2540 if(nullptr != h) {
2541 // gather the information for the reverse sweep
2542
2543 // create the index buffers
2544 h->bufCount = datatype->computeActiveElements(count);
2545 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2546 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2547
2548
2549 // extract the old primal values from the recv buffer if the AD tool
2550 // needs the primal values reset
2551 if(adType->isOldPrimalsRequired()) {
2552 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
2553 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
2554 }
2555
2556
2557
2558 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
2559
2560 // pack all the variables in the handle
2566 h->count = count;
2567 h->datatype = datatype;
2568 h->source = source;
2569 h->tag = tag;
2570 h->comm = comm;
2571 h->reverse_send = reverse_send;
2572 }
2573
2574 if(!datatype->isModifiedBufferRequired()) {
2575 datatype->clearIndices(buf, 0, count);
2576 }
2577
2578 rStatus = MPI_Recv(bufMod, count, datatype->getModifiedMpiType(), source, tag, comm, status);
2579 adType->addToolAction(h);
2580
2581 if(datatype->isModifiedBufferRequired()) {
2582 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
2583 }
2584
2585 if(nullptr != h) {
2586 // handle the recv buffers
2587 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
2588 }
2589
2590 adType->stopAssembly(h);
2591
2592 if(datatype->isModifiedBufferRequired() ) {
2593 datatype->deleteModifiedTypeBuffer(bufMod);
2594 }
2595
2596 // handle is deleted by the AD tool
2597 }
2598
2599 return rStatus;
2600 }
2601
2602#endif
2603#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
2604
2605 template<typename DATATYPE>
2607 typename DATATYPE::Type* buf;
2608 typename DATATYPE::ModifiedType* bufMod;
2610 DATATYPE* datatype;
2612 int tag;
2616 };
2617
2618
2619 template<typename DATATYPE>
2620 void AMPI_Recv_init_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
2622 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2623 (void)adType;
2624
2625 }
2626
2627 template<typename DATATYPE>
2628 void AMPI_Recv_init_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
2630 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2631 (void)adType;
2632
2633 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
2634 }
2635
2636 template<typename DATATYPE>
2637 int AMPI_Recv_init_preStart(HandleBase* handle);
2638 template<typename DATATYPE>
2639 int AMPI_Recv_init_finish(HandleBase* handle);
2640 template<typename DATATYPE>
2641 int AMPI_Recv_init_postEnd(HandleBase* handle);
2642 template<typename DATATYPE>
2643 int AMPI_Recv_init(typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int source, int tag, AMPI_Comm comm,
2644 AMPI_Request* request, IrecvAdjCall reverse_send = IrecvAdjCall::Isend) {
2645 int rStatus;
2646 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2647
2648 if(!adType->isActiveType()) {
2649 // call the regular function if the type is not active
2650 rStatus = MPI_Recv_init(buf, count, datatype->getMpiType(), source, tag, comm, &request->request);
2651 } else {
2652
2653 // the type is an AD type so handle the buffers
2655 typename DATATYPE::ModifiedType* bufMod = nullptr;
2656 int bufElements = 0;
2657
2658 // compute the total size of the buffer
2659 bufElements = count;
2660
2661 if(datatype->isModifiedBufferRequired() ) {
2662 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2663 } else {
2664 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2665 }
2666
2667 rStatus = MPI_Recv_init(bufMod, count, datatype->getModifiedMpiType(), source, tag, comm, &request->request);
2668
2670 asyncHandle->buf = buf;
2671 asyncHandle->bufMod = bufMod;
2672 asyncHandle->count = count;
2673 asyncHandle->datatype = datatype;
2674 asyncHandle->source = source;
2675 asyncHandle->tag = tag;
2676 asyncHandle->comm = comm;
2677 asyncHandle->reverse_send = reverse_send;
2678 asyncHandle->toolHandle = h;
2679 request->handle = asyncHandle;
2683 }
2684
2685 return rStatus;
2686 }
2687
2688 template<typename DATATYPE>
2690 int rStatus = 0;
2691
2693 typename DATATYPE::Type* buf = asyncHandle->buf;
2694 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2695 int count = asyncHandle->count;
2696 DATATYPE* datatype = asyncHandle->datatype;
2697 int source = asyncHandle->source;
2698 int tag = asyncHandle->tag;
2699 AMPI_Comm comm = asyncHandle->comm;
2700 AMPI_Request* request = asyncHandle->request;
2701 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
2703 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2704 MEDI_UNUSED(h); // Unused generated to ignore warnings
2705 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2706 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2707 MEDI_UNUSED(count); // Unused generated to ignore warnings
2708 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2709 MEDI_UNUSED(source); // Unused generated to ignore warnings
2710 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2711 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2712 MEDI_UNUSED(request); // Unused generated to ignore warnings
2713 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
2714
2715
2716 if(adType->isActiveType()) {
2717
2718 int bufElements = 0;
2719
2720 // recompute the total size of the buffer
2721 bufElements = count;
2722 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2723 if(adType->isHandleRequired()) {
2725 }
2726 adType->startAssembly(h);
2727
2728 if(nullptr != h) {
2729 // gather the information for the reverse sweep
2730
2731 // create the index buffers
2732 h->bufCount = datatype->computeActiveElements(count);
2733 h->bufTotalSize = datatype->computeActiveElements(bufElements);
2734 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
2735
2736
2737 // extract the old primal values from the recv buffer if the AD tool
2738 // needs the primal values reset
2739 if(adType->isOldPrimalsRequired()) {
2740 datatype->getADTool().createPrimalTypeBuffer(h->bufOldPrimals, h->bufTotalSize);
2741 datatype->getValues(buf, 0, h->bufOldPrimals, 0, count);
2742 }
2743
2744
2745
2746 datatype->createIndices(buf, 0, h->bufIndices, 0, count);
2747
2748 // pack all the variables in the handle
2754 h->count = count;
2755 h->datatype = datatype;
2756 h->source = source;
2757 h->tag = tag;
2758 h->comm = comm;
2759 h->reverse_send = reverse_send;
2760 }
2761
2762 if(!datatype->isModifiedBufferRequired()) {
2763 datatype->clearIndices(buf, 0, count);
2764 }
2765
2766 asyncHandle->toolHandle = h;
2767
2768 // create adjoint wait
2769 if(nullptr != h) {
2772 adType->addToolAction(waitH);
2773 }
2774 }
2775
2776 return rStatus;
2777 }
2778
2779 template<typename DATATYPE>
2781 int rStatus = 0;
2782
2784 typename DATATYPE::Type* buf = asyncHandle->buf;
2785 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2786 int count = asyncHandle->count;
2787 DATATYPE* datatype = asyncHandle->datatype;
2788 int source = asyncHandle->source;
2789 int tag = asyncHandle->tag;
2790 AMPI_Comm comm = asyncHandle->comm;
2791 AMPI_Request* request = asyncHandle->request;
2792 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
2794 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2795 MEDI_UNUSED(h); // Unused generated to ignore warnings
2796 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2797 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2798 MEDI_UNUSED(count); // Unused generated to ignore warnings
2799 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2800 MEDI_UNUSED(source); // Unused generated to ignore warnings
2801 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2802 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2803 MEDI_UNUSED(request); // Unused generated to ignore warnings
2804 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
2805
2806
2807 if(adType->isActiveType()) {
2808
2809 adType->addToolAction(h);
2810
2811 if(datatype->isModifiedBufferRequired()) {
2812 datatype->copyFromModifiedBuffer(buf, 0, bufMod, 0, count);
2813 }
2814
2815 if(nullptr != h) {
2816 // handle the recv buffers
2817 datatype->registerValue(buf, 0, h->bufIndices, h->bufOldPrimals, 0, count);
2818 }
2819
2820 adType->stopAssembly(h);
2821 }
2822
2823 return rStatus;
2824 }
2825
2826 template<typename DATATYPE>
2828 int rStatus = 0;
2829
2831 typename DATATYPE::Type* buf = asyncHandle->buf;
2832 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
2833 int count = asyncHandle->count;
2834 DATATYPE* datatype = asyncHandle->datatype;
2835 int source = asyncHandle->source;
2836 int tag = asyncHandle->tag;
2837 AMPI_Comm comm = asyncHandle->comm;
2838 AMPI_Request* request = asyncHandle->request;
2839 IrecvAdjCall reverse_send = asyncHandle->reverse_send;
2841 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2842 MEDI_UNUSED(h); // Unused generated to ignore warnings
2843 MEDI_UNUSED(buf); // Unused generated to ignore warnings
2844 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
2845 MEDI_UNUSED(count); // Unused generated to ignore warnings
2846 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
2847 MEDI_UNUSED(source); // Unused generated to ignore warnings
2848 MEDI_UNUSED(tag); // Unused generated to ignore warnings
2849 MEDI_UNUSED(comm); // Unused generated to ignore warnings
2850 MEDI_UNUSED(request); // Unused generated to ignore warnings
2851 MEDI_UNUSED(reverse_send); // Unused generated to ignore warnings
2852
2853 delete asyncHandle;
2854
2855 if(adType->isActiveType()) {
2856
2857
2858 if(datatype->isModifiedBufferRequired() ) {
2859 datatype->deleteModifiedTypeBuffer(bufMod);
2860 }
2861
2862 // handle is deleted by the AD tool
2863 }
2864
2865 return rStatus;
2866 }
2867
2868#endif
2869#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
2870 template<typename DATATYPE>
2873 typename DATATYPE::IndexType* bufIndices;
2874 typename DATATYPE::PrimalType* bufPrimals;
2875 /* required for async */ void* bufAdjoints;
2879 DATATYPE* datatype;
2880 int dest;
2881 int tag;
2883
2885 if(nullptr != bufIndices) {
2886 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
2887 bufIndices = nullptr;
2888 }
2889 if(nullptr != bufPrimals) {
2890 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
2891 bufPrimals = nullptr;
2892 }
2893 }
2894 };
2895
2896
2897 template<typename DATATYPE>
2898 void AMPI_Rsend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
2900 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2901 (void)adType;
2902
2903 h->bufAdjoints = nullptr;
2904 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2905 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
2906 // Primal buffers are always linear in space so we can accesses them in one sweep
2907 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
2908
2909
2911
2912 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
2913 }
2914
2915 template<typename DATATYPE>
2916 void AMPI_Rsend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
2918 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2919 (void)adType;
2920
2921 h->bufAdjoints = nullptr;
2922 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2923 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2924 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2925 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2926
2927
2929
2930 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2931 }
2932
2933 template<typename DATATYPE>
2934 void AMPI_Rsend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
2936 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2937 (void)adType;
2938
2939 h->bufAdjoints = nullptr;
2940 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
2941 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
2942
2944
2945 // Adjoint buffers are always linear in space so we can accesses them in one sweep
2946 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
2947 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
2948 }
2949
2950 template<typename DATATYPE>
2951 void AMPI_Rsend_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
2953 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2954 (void)adType;
2955
2956 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
2957 }
2958
2959 template<typename DATATYPE>
2960 void AMPI_Rsend_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
2962 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
2963 (void)adType;
2964
2965 }
2966
2967 template<typename DATATYPE>
2968 int AMPI_Rsend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
2969 AMPI_Comm comm) {
2970 int rStatus;
2971 ADToolInterface const* adType = selectADTool(datatype->getADTool());
2972
2973 if(!adType->isActiveType()) {
2974 // call the regular function if the type is not active
2975 rStatus = MPI_Rsend(buf, count, datatype->getMpiType(), dest, tag, comm);
2976 } else {
2977
2978 // the type is an AD type so handle the buffers
2980 typename DATATYPE::ModifiedType* bufMod = nullptr;
2981 int bufElements = 0;
2982
2983 // compute the total size of the buffer
2984 bufElements = count;
2985
2986 if(datatype->isModifiedBufferRequired() ) {
2987 datatype->createModifiedTypeBuffer(bufMod, bufElements);
2988 } else {
2989 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
2990 }
2991
2992 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
2993 if(adType->isHandleRequired()) {
2995 }
2996 adType->startAssembly(h);
2997 if(datatype->isModifiedBufferRequired()) {
2998 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
2999 }
3000
3001 if(nullptr != h) {
3002 // gather the information for the reverse sweep
3003
3004 // create the index buffers
3005 h->bufCount = datatype->computeActiveElements(count);
3006 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3007 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3008
3009
3010
3011
3012 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3013
3014
3015 // pack all the variables in the handle
3021 h->count = count;
3022 h->datatype = datatype;
3023 h->dest = dest;
3024 h->tag = tag;
3025 h->comm = comm;
3026 }
3027
3028
3029 rStatus = MPI_Rsend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
3030 adType->addToolAction(h);
3031
3032
3033 if(nullptr != h) {
3034 // handle the recv buffers
3035 }
3036
3037 adType->stopAssembly(h);
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
3052 template<typename DATATYPE>
3054 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
3055 typename DATATYPE::ModifiedType* bufMod;
3057 DATATYPE* datatype;
3058 int dest;
3059 int tag;
3062 };
3063
3064
3065 template<typename DATATYPE>
3066 void AMPI_Rsend_init_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
3068 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3069 (void)adType;
3070
3071 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
3072 }
3073
3074 template<typename DATATYPE>
3075 void AMPI_Rsend_init_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
3077 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3078 (void)adType;
3079
3080 }
3081
3082 template<typename DATATYPE>
3083 int AMPI_Rsend_init_preStart(HandleBase* handle);
3084 template<typename DATATYPE>
3085 int AMPI_Rsend_init_finish(HandleBase* handle);
3086 template<typename DATATYPE>
3087 int AMPI_Rsend_init_postEnd(HandleBase* handle);
3088 template<typename DATATYPE>
3089 int AMPI_Rsend_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
3090 AMPI_Comm comm, AMPI_Request* request) {
3091 int rStatus;
3092 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3093
3094 if(!adType->isActiveType()) {
3095 // call the regular function if the type is not active
3096 rStatus = MPI_Rsend_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
3097 } else {
3098
3099 // the type is an AD type so handle the buffers
3101 typename DATATYPE::ModifiedType* bufMod = nullptr;
3102 int bufElements = 0;
3103
3104 // compute the total size of the buffer
3105 bufElements = count;
3106
3107 if(datatype->isModifiedBufferRequired() ) {
3108 datatype->createModifiedTypeBuffer(bufMod, bufElements);
3109 } else {
3110 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
3111 }
3112
3113 rStatus = MPI_Rsend_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
3114
3116 asyncHandle->buf = buf;
3117 asyncHandle->bufMod = bufMod;
3118 asyncHandle->count = count;
3119 asyncHandle->datatype = datatype;
3120 asyncHandle->dest = dest;
3121 asyncHandle->tag = tag;
3122 asyncHandle->comm = comm;
3123 asyncHandle->toolHandle = h;
3124 request->handle = asyncHandle;
3128 }
3129
3130 return rStatus;
3131 }
3132
3133 template<typename DATATYPE>
3135 int rStatus = 0;
3136
3138 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3139 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3140 int count = asyncHandle->count;
3141 DATATYPE* datatype = asyncHandle->datatype;
3142 int dest = asyncHandle->dest;
3143 int tag = asyncHandle->tag;
3144 AMPI_Comm comm = asyncHandle->comm;
3145 AMPI_Request* request = asyncHandle->request;
3147 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3148 MEDI_UNUSED(h); // Unused generated to ignore warnings
3149 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3150 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3151 MEDI_UNUSED(count); // Unused generated to ignore warnings
3152 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3153 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3154 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3155 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3156 MEDI_UNUSED(request); // Unused generated to ignore warnings
3157
3158
3159 if(adType->isActiveType()) {
3160
3161 int bufElements = 0;
3162
3163 // recompute the total size of the buffer
3164 bufElements = count;
3165 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3166 if(adType->isHandleRequired()) {
3168 }
3169 adType->startAssembly(h);
3170 if(datatype->isModifiedBufferRequired()) {
3171 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
3172 }
3173
3174 if(nullptr != h) {
3175 // gather the information for the reverse sweep
3176
3177 // create the index buffers
3178 h->bufCount = datatype->computeActiveElements(count);
3179 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3180 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3181
3182
3183
3184
3185 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3186
3187
3188 // pack all the variables in the handle
3194 h->count = count;
3195 h->datatype = datatype;
3196 h->dest = dest;
3197 h->tag = tag;
3198 h->comm = comm;
3199 }
3200
3201
3202 asyncHandle->toolHandle = h;
3203
3204 // create adjoint wait
3205 if(nullptr != h) {
3208 adType->addToolAction(waitH);
3209 }
3210 }
3211
3212 return rStatus;
3213 }
3214
3215 template<typename DATATYPE>
3217 int rStatus = 0;
3218
3220 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3221 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3222 int count = asyncHandle->count;
3223 DATATYPE* datatype = asyncHandle->datatype;
3224 int dest = asyncHandle->dest;
3225 int tag = asyncHandle->tag;
3226 AMPI_Comm comm = asyncHandle->comm;
3227 AMPI_Request* request = asyncHandle->request;
3229 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3230 MEDI_UNUSED(h); // Unused generated to ignore warnings
3231 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3232 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3233 MEDI_UNUSED(count); // Unused generated to ignore warnings
3234 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3235 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3236 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3237 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3238 MEDI_UNUSED(request); // Unused generated to ignore warnings
3239
3240
3241 if(adType->isActiveType()) {
3242
3243 adType->addToolAction(h);
3244
3245
3246 if(nullptr != h) {
3247 // handle the recv buffers
3248 }
3249
3250 adType->stopAssembly(h);
3251 }
3252
3253 return rStatus;
3254 }
3255
3256 template<typename DATATYPE>
3258 int rStatus = 0;
3259
3261 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3262 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3263 int count = asyncHandle->count;
3264 DATATYPE* datatype = asyncHandle->datatype;
3265 int dest = asyncHandle->dest;
3266 int tag = asyncHandle->tag;
3267 AMPI_Comm comm = asyncHandle->comm;
3268 AMPI_Request* request = asyncHandle->request;
3270 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3271 MEDI_UNUSED(h); // Unused generated to ignore warnings
3272 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3273 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3274 MEDI_UNUSED(count); // Unused generated to ignore warnings
3275 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3276 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3277 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3278 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3279 MEDI_UNUSED(request); // Unused generated to ignore warnings
3280
3281 delete asyncHandle;
3282
3283 if(adType->isActiveType()) {
3284
3285
3286 if(datatype->isModifiedBufferRequired() ) {
3287 datatype->deleteModifiedTypeBuffer(bufMod);
3288 }
3289
3290 // handle is deleted by the AD tool
3291 }
3292
3293 return rStatus;
3294 }
3295
3296#endif
3297#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3298 template<typename DATATYPE>
3301 typename DATATYPE::IndexType* bufIndices;
3302 typename DATATYPE::PrimalType* bufPrimals;
3303 /* required for async */ void* bufAdjoints;
3307 DATATYPE* datatype;
3308 int dest;
3309 int tag;
3311
3313 if(nullptr != bufIndices) {
3314 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
3315 bufIndices = nullptr;
3316 }
3317 if(nullptr != bufPrimals) {
3318 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
3319 bufPrimals = nullptr;
3320 }
3321 }
3322 };
3323
3324
3325 template<typename DATATYPE>
3326 void AMPI_Send_p(HandleBase* handle, AdjointInterface* adjointInterface) {
3328 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3329 (void)adType;
3330
3331 h->bufAdjoints = nullptr;
3332 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3333 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
3334 // Primal buffers are always linear in space so we can accesses them in one sweep
3335 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
3336
3337
3339
3340 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
3341 }
3342
3343 template<typename DATATYPE>
3344 void AMPI_Send_d(HandleBase* handle, AdjointInterface* adjointInterface) {
3346 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3347 (void)adType;
3348
3349 h->bufAdjoints = nullptr;
3350 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3351 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
3352 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3353 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
3354
3355
3357
3358 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
3359 }
3360
3361 template<typename DATATYPE>
3362 void AMPI_Send_b(HandleBase* handle, AdjointInterface* adjointInterface) {
3364 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3365 (void)adType;
3366
3367 h->bufAdjoints = nullptr;
3368 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
3369 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
3370
3372
3373 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3374 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
3375 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
3376 }
3377
3378 template<typename DATATYPE>
3379 void AMPI_Send_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
3381 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3382 (void)adType;
3383
3384 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
3385 }
3386
3387 template<typename DATATYPE>
3388 void AMPI_Send_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
3390 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3391 (void)adType;
3392
3393 }
3394
3395 template<typename DATATYPE>
3396 int AMPI_Send(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
3397 AMPI_Comm comm) {
3398 int rStatus;
3399 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3400
3401 if(!adType->isActiveType()) {
3402 // call the regular function if the type is not active
3403 rStatus = MPI_Send(buf, count, datatype->getMpiType(), dest, tag, comm);
3404 } else {
3405
3406 // the type is an AD type so handle the buffers
3408 typename DATATYPE::ModifiedType* bufMod = nullptr;
3409 int bufElements = 0;
3410
3411 // compute the total size of the buffer
3412 bufElements = count;
3413
3414 if(datatype->isModifiedBufferRequired() ) {
3415 datatype->createModifiedTypeBuffer(bufMod, bufElements);
3416 } else {
3417 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
3418 }
3419
3420 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3421 if(adType->isHandleRequired()) {
3423 }
3424 adType->startAssembly(h);
3425 if(datatype->isModifiedBufferRequired()) {
3426 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
3427 }
3428
3429 if(nullptr != h) {
3430 // gather the information for the reverse sweep
3431
3432 // create the index buffers
3433 h->bufCount = datatype->computeActiveElements(count);
3434 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3435 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3436
3437
3438
3439
3440 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3441
3442
3443 // pack all the variables in the handle
3449 h->count = count;
3450 h->datatype = datatype;
3451 h->dest = dest;
3452 h->tag = tag;
3453 h->comm = comm;
3454 }
3455
3456
3457 rStatus = MPI_Send(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
3458 adType->addToolAction(h);
3459
3460
3461 if(nullptr != h) {
3462 // handle the recv buffers
3463 }
3464
3465 adType->stopAssembly(h);
3466
3467 if(datatype->isModifiedBufferRequired() ) {
3468 datatype->deleteModifiedTypeBuffer(bufMod);
3469 }
3470
3471 // handle is deleted by the AD tool
3472 }
3473
3474 return rStatus;
3475 }
3476
3477#endif
3478#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3479
3480 template<typename DATATYPE>
3482 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
3483 typename DATATYPE::ModifiedType* bufMod;
3485 DATATYPE* datatype;
3486 int dest;
3487 int tag;
3490 };
3491
3492
3493 template<typename DATATYPE>
3494 void AMPI_Send_init_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
3496 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3497 (void)adType;
3498
3499 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
3500 }
3501
3502 template<typename DATATYPE>
3503 void AMPI_Send_init_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
3505 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
3506 (void)adType;
3507
3508 }
3509
3510 template<typename DATATYPE>
3511 int AMPI_Send_init_preStart(HandleBase* handle);
3512 template<typename DATATYPE>
3513 int AMPI_Send_init_finish(HandleBase* handle);
3514 template<typename DATATYPE>
3515 int AMPI_Send_init_postEnd(HandleBase* handle);
3516 template<typename DATATYPE>
3517 int AMPI_Send_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
3518 AMPI_Comm comm, AMPI_Request* request) {
3519 int rStatus;
3520 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3521
3522 if(!adType->isActiveType()) {
3523 // call the regular function if the type is not active
3524 rStatus = MPI_Send_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
3525 } else {
3526
3527 // the type is an AD type so handle the buffers
3529 typename DATATYPE::ModifiedType* bufMod = nullptr;
3530 int bufElements = 0;
3531
3532 // compute the total size of the buffer
3533 bufElements = count;
3534
3535 if(datatype->isModifiedBufferRequired() ) {
3536 datatype->createModifiedTypeBuffer(bufMod, bufElements);
3537 } else {
3538 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
3539 }
3540
3541 rStatus = MPI_Send_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
3542
3544 asyncHandle->buf = buf;
3545 asyncHandle->bufMod = bufMod;
3546 asyncHandle->count = count;
3547 asyncHandle->datatype = datatype;
3548 asyncHandle->dest = dest;
3549 asyncHandle->tag = tag;
3550 asyncHandle->comm = comm;
3551 asyncHandle->toolHandle = h;
3552 request->handle = asyncHandle;
3556 }
3557
3558 return rStatus;
3559 }
3560
3561 template<typename DATATYPE>
3563 int rStatus = 0;
3564
3566 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3567 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3568 int count = asyncHandle->count;
3569 DATATYPE* datatype = asyncHandle->datatype;
3570 int dest = asyncHandle->dest;
3571 int tag = asyncHandle->tag;
3572 AMPI_Comm comm = asyncHandle->comm;
3573 AMPI_Request* request = asyncHandle->request;
3575 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3576 MEDI_UNUSED(h); // Unused generated to ignore warnings
3577 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3578 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3579 MEDI_UNUSED(count); // Unused generated to ignore warnings
3580 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3581 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3582 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3583 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3584 MEDI_UNUSED(request); // Unused generated to ignore warnings
3585
3586
3587 if(adType->isActiveType()) {
3588
3589 int bufElements = 0;
3590
3591 // recompute the total size of the buffer
3592 bufElements = count;
3593 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3594 if(adType->isHandleRequired()) {
3596 }
3597 adType->startAssembly(h);
3598 if(datatype->isModifiedBufferRequired()) {
3599 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
3600 }
3601
3602 if(nullptr != h) {
3603 // gather the information for the reverse sweep
3604
3605 // create the index buffers
3606 h->bufCount = datatype->computeActiveElements(count);
3607 h->bufTotalSize = datatype->computeActiveElements(bufElements);
3608 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
3609
3610
3611
3612
3613 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
3614
3615
3616 // pack all the variables in the handle
3622 h->count = count;
3623 h->datatype = datatype;
3624 h->dest = dest;
3625 h->tag = tag;
3626 h->comm = comm;
3627 }
3628
3629
3630 asyncHandle->toolHandle = h;
3631
3632 // create adjoint wait
3633 if(nullptr != h) {
3636 adType->addToolAction(waitH);
3637 }
3638 }
3639
3640 return rStatus;
3641 }
3642
3643 template<typename DATATYPE>
3645 int rStatus = 0;
3646
3648 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3649 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3650 int count = asyncHandle->count;
3651 DATATYPE* datatype = asyncHandle->datatype;
3652 int dest = asyncHandle->dest;
3653 int tag = asyncHandle->tag;
3654 AMPI_Comm comm = asyncHandle->comm;
3655 AMPI_Request* request = asyncHandle->request;
3657 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3658 MEDI_UNUSED(h); // Unused generated to ignore warnings
3659 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3660 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3661 MEDI_UNUSED(count); // Unused generated to ignore warnings
3662 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3663 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3664 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3665 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3666 MEDI_UNUSED(request); // Unused generated to ignore warnings
3667
3668
3669 if(adType->isActiveType()) {
3670
3671 adType->addToolAction(h);
3672
3673
3674 if(nullptr != h) {
3675 // handle the recv buffers
3676 }
3677
3678 adType->stopAssembly(h);
3679 }
3680
3681 return rStatus;
3682 }
3683
3684 template<typename DATATYPE>
3686 int rStatus = 0;
3687
3689 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
3690 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
3691 int count = asyncHandle->count;
3692 DATATYPE* datatype = asyncHandle->datatype;
3693 int dest = asyncHandle->dest;
3694 int tag = asyncHandle->tag;
3695 AMPI_Comm comm = asyncHandle->comm;
3696 AMPI_Request* request = asyncHandle->request;
3698 ADToolInterface const* adType = selectADTool(datatype->getADTool());
3699 MEDI_UNUSED(h); // Unused generated to ignore warnings
3700 MEDI_UNUSED(buf); // Unused generated to ignore warnings
3701 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
3702 MEDI_UNUSED(count); // Unused generated to ignore warnings
3703 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
3704 MEDI_UNUSED(dest); // Unused generated to ignore warnings
3705 MEDI_UNUSED(tag); // Unused generated to ignore warnings
3706 MEDI_UNUSED(comm); // Unused generated to ignore warnings
3707 MEDI_UNUSED(request); // Unused generated to ignore warnings
3708
3709 delete asyncHandle;
3710
3711 if(adType->isActiveType()) {
3712
3713
3714 if(datatype->isModifiedBufferRequired() ) {
3715 datatype->deleteModifiedTypeBuffer(bufMod);
3716 }
3717
3718 // handle is deleted by the AD tool
3719 }
3720
3721 return rStatus;
3722 }
3723
3724#endif
3725#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
3726 template<typename SENDTYPE, typename RECVTYPE>
3729 typename SENDTYPE::IndexType* sendbufIndices;
3730 typename SENDTYPE::PrimalType* sendbufPrimals;
3731 /* required for async */ void* sendbufAdjoints;
3735 SENDTYPE* sendtype;
3736 int dest;
3739 typename RECVTYPE::IndexType* recvbufIndices;
3740 typename RECVTYPE::PrimalType* recvbufPrimals;
3741 typename RECVTYPE::PrimalType* recvbufOldPrimals;
3742 /* required for async */ void* recvbufAdjoints;
3746 RECVTYPE* recvtype;
3750
3752 if(nullptr != sendbufIndices) {
3753 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
3754 sendbufIndices = nullptr;
3755 }
3756 if(nullptr != sendbufPrimals) {
3757 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
3758 sendbufPrimals = nullptr;
3759 }
3760 if(nullptr != recvbufIndices) {
3761 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
3762 recvbufIndices = nullptr;
3763 }
3764 if(nullptr != recvbufPrimals) {
3765 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
3766 recvbufPrimals = nullptr;
3767 }
3768 if(nullptr != recvbufOldPrimals) {
3769 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
3770 recvbufOldPrimals = nullptr;
3771 }
3772 }
3773 };
3774
3775
3776 template<typename SENDTYPE, typename RECVTYPE>
3777 void AMPI_Sendrecv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
3779 (handle);
3780 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3781 (void)adType;
3782
3783 MPI_Status status;
3784 h->recvbufAdjoints = nullptr;
3785 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
3786 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
3787 h->sendbufAdjoints = nullptr;
3788 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
3789 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
3790 // Primal buffers are always linear in space so we can accesses them in one sweep
3791 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
3792
3793
3795 h->sendtag, h->recvbufPrimals, h->recvbufCountVec, h->recvcount, h->recvtype, h->source, h->recvtag, h->comm, &status);
3796
3797 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
3798 if(adType->isOldPrimalsRequired()) {
3799 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
3800 }
3801 // Primal buffers are always linear in space so we can accesses them in one sweep
3802 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
3803 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
3804 }
3805
3806 template<typename SENDTYPE, typename RECVTYPE>
3807 void AMPI_Sendrecv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
3809 (handle);
3810 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3811 (void)adType;
3812
3813 MPI_Status status;
3814 h->recvbufAdjoints = nullptr;
3815 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
3816 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
3817 h->sendbufAdjoints = nullptr;
3818 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
3819 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
3820 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3821 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
3822
3823
3825 h->sendtag, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->source, h->recvtag, h->comm, &status);
3826
3827 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
3828 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3829 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
3830 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
3831 }
3832
3833 template<typename SENDTYPE, typename RECVTYPE>
3834 void AMPI_Sendrecv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
3836 (handle);
3837 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3838 (void)adType;
3839
3840 MPI_Status status;
3841 h->recvbufAdjoints = nullptr;
3842 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
3843 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
3844 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3845 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
3846
3847 if(adType->isOldPrimalsRequired()) {
3848 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
3849 }
3850 h->sendbufAdjoints = nullptr;
3851 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
3852 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
3853
3855 h->sendtag, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->source, h->recvtag, h->comm, &status);
3856
3857 // Adjoint buffers are always linear in space so we can accesses them in one sweep
3858 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
3859 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
3860 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
3861 }
3862
3863 template<typename SENDTYPE, typename RECVTYPE>
3864 void AMPI_Sendrecv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
3866 (handle);
3867 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3868 (void)adType;
3869
3870 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
3871 }
3872
3873 template<typename SENDTYPE, typename RECVTYPE>
3874 void AMPI_Sendrecv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
3876 (handle);
3877 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
3878 (void)adType;
3879
3880 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
3881 }
3882
3883 template<typename SENDTYPE, typename RECVTYPE>
3884 int AMPI_Sendrecv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype, int dest,
3885 int sendtag, typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int source, int recvtag,
3886 AMPI_Comm comm, AMPI_Status* status) {
3887 int rStatus;
3888 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
3889
3890 if(!adType->isActiveType()) {
3891 // call the regular function if the type is not active
3892 rStatus = MPI_Sendrecv(sendbuf, sendcount, sendtype->getMpiType(), dest, sendtag, recvbuf, recvcount,
3893 recvtype->getMpiType(), source, recvtag, comm, status);
3894 } else {
3895
3896 // the type is an AD type so handle the buffers
3898 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
3899 int sendbufElements = 0;
3900
3901 // compute the total size of the buffer
3902 sendbufElements = sendcount;
3903
3904 if(sendtype->isModifiedBufferRequired() ) {
3905 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
3906 } else {
3907 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
3908 }
3909 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
3910 int recvbufElements = 0;
3911
3912 // compute the total size of the buffer
3913 recvbufElements = recvcount;
3914
3915 if(recvtype->isModifiedBufferRequired() ) {
3916 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
3917 } else {
3918 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
3919 }
3920
3921 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
3922 if(adType->isHandleRequired()) {
3924 }
3925 adType->startAssembly(h);
3926 if(sendtype->isModifiedBufferRequired()) {
3927 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
3928 }
3929
3930 if(nullptr != h) {
3931 // gather the information for the reverse sweep
3932
3933 // create the index buffers
3934 h->sendbufCount = sendtype->computeActiveElements(sendcount);
3935 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
3936 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
3937 h->recvbufCount = recvtype->computeActiveElements(recvcount);
3938 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
3939 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
3940
3941
3942 // extract the old primal values from the recv buffer if the AD tool
3943 // needs the primal values reset
3944 if(adType->isOldPrimalsRequired()) {
3945 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
3946 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
3947 }
3948
3949
3950 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
3951
3952 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
3953
3954 // pack all the variables in the handle
3960 h->sendcount = sendcount;
3961 h->sendtype = sendtype;
3962 h->dest = dest;
3963 h->sendtag = sendtag;
3964 h->recvcount = recvcount;
3965 h->recvtype = recvtype;
3966 h->source = source;
3967 h->recvtag = recvtag;
3968 h->comm = comm;
3969 }
3970
3971 if(!recvtype->isModifiedBufferRequired()) {
3972 recvtype->clearIndices(recvbuf, 0, recvcount);
3973 }
3974
3975 rStatus = MPI_Sendrecv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), dest, sendtag, recvbufMod, recvcount,
3976 recvtype->getModifiedMpiType(), source, recvtag, comm, status);
3977 adType->addToolAction(h);
3978
3979 if(recvtype->isModifiedBufferRequired()) {
3980 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
3981 }
3982
3983 if(nullptr != h) {
3984 // handle the recv buffers
3985 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
3986 }
3987
3988 adType->stopAssembly(h);
3989
3990 if(sendtype->isModifiedBufferRequired() ) {
3991 sendtype->deleteModifiedTypeBuffer(sendbufMod);
3992 }
3993 if(recvtype->isModifiedBufferRequired() ) {
3994 recvtype->deleteModifiedTypeBuffer(recvbufMod);
3995 }
3996
3997 // handle is deleted by the AD tool
3998 }
3999
4000 return rStatus;
4001 }
4002
4003#endif
4004#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4005 template<typename DATATYPE>
4008 typename DATATYPE::IndexType* bufIndices;
4009 typename DATATYPE::PrimalType* bufPrimals;
4010 /* required for async */ void* bufAdjoints;
4014 DATATYPE* datatype;
4015 int dest;
4016 int tag;
4018
4020 if(nullptr != bufIndices) {
4021 datatype->getADTool().deleteIndexTypeBuffer(bufIndices);
4022 bufIndices = nullptr;
4023 }
4024 if(nullptr != bufPrimals) {
4025 datatype->getADTool().deletePrimalTypeBuffer(bufPrimals);
4026 bufPrimals = nullptr;
4027 }
4028 }
4029 };
4030
4031
4032 template<typename DATATYPE>
4033 void AMPI_Ssend_p(HandleBase* handle, AdjointInterface* adjointInterface) {
4035 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4036 (void)adType;
4037
4038 h->bufAdjoints = nullptr;
4039 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
4040 adjointInterface->createPrimalTypeBuffer((void*&)h->bufPrimals, h->bufTotalSize );
4041 // Primal buffers are always linear in space so we can accesses them in one sweep
4042 adjointInterface->getPrimals(h->bufIndices, h->bufPrimals, h->bufTotalSize);
4043
4044
4046
4047 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufPrimals);
4048 }
4049
4050 template<typename DATATYPE>
4051 void AMPI_Ssend_d(HandleBase* handle, AdjointInterface* adjointInterface) {
4053 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4054 (void)adType;
4055
4056 h->bufAdjoints = nullptr;
4057 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
4058 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
4059 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4060 adjointInterface->getAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
4061
4062
4064
4065 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
4066 }
4067
4068 template<typename DATATYPE>
4069 void AMPI_Ssend_b(HandleBase* handle, AdjointInterface* adjointInterface) {
4071 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4072 (void)adType;
4073
4074 h->bufAdjoints = nullptr;
4075 h->bufCountVec = adjointInterface->getVectorSize() * h->bufCount;
4076 adjointInterface->createAdjointTypeBuffer(h->bufAdjoints, h->bufTotalSize );
4077
4079
4080 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4081 adjointInterface->updateAdjoints(h->bufIndices, h->bufAdjoints, h->bufTotalSize);
4082 adjointInterface->deleteAdjointTypeBuffer(h->bufAdjoints);
4083 }
4084
4085 template<typename DATATYPE>
4086 void AMPI_Ssend_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
4088 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4089 (void)adType;
4090
4091 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
4092 }
4093
4094 template<typename DATATYPE>
4095 void AMPI_Ssend_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
4097 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4098 (void)adType;
4099
4100 }
4101
4102 template<typename DATATYPE>
4103 int AMPI_Ssend(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
4104 AMPI_Comm comm) {
4105 int rStatus;
4106 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4107
4108 if(!adType->isActiveType()) {
4109 // call the regular function if the type is not active
4110 rStatus = MPI_Ssend(buf, count, datatype->getMpiType(), dest, tag, comm);
4111 } else {
4112
4113 // the type is an AD type so handle the buffers
4115 typename DATATYPE::ModifiedType* bufMod = nullptr;
4116 int bufElements = 0;
4117
4118 // compute the total size of the buffer
4119 bufElements = count;
4120
4121 if(datatype->isModifiedBufferRequired() ) {
4122 datatype->createModifiedTypeBuffer(bufMod, bufElements);
4123 } else {
4124 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
4125 }
4126
4127 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
4128 if(adType->isHandleRequired()) {
4130 }
4131 adType->startAssembly(h);
4132 if(datatype->isModifiedBufferRequired()) {
4133 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
4134 }
4135
4136 if(nullptr != h) {
4137 // gather the information for the reverse sweep
4138
4139 // create the index buffers
4140 h->bufCount = datatype->computeActiveElements(count);
4141 h->bufTotalSize = datatype->computeActiveElements(bufElements);
4142 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
4143
4144
4145
4146
4147 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
4148
4149
4150 // pack all the variables in the handle
4156 h->count = count;
4157 h->datatype = datatype;
4158 h->dest = dest;
4159 h->tag = tag;
4160 h->comm = comm;
4161 }
4162
4163
4164 rStatus = MPI_Ssend(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm);
4165 adType->addToolAction(h);
4166
4167
4168 if(nullptr != h) {
4169 // handle the recv buffers
4170 }
4171
4172 adType->stopAssembly(h);
4173
4174 if(datatype->isModifiedBufferRequired() ) {
4175 datatype->deleteModifiedTypeBuffer(bufMod);
4176 }
4177
4178 // handle is deleted by the AD tool
4179 }
4180
4181 return rStatus;
4182 }
4183
4184#endif
4185#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4186
4187 template<typename DATATYPE>
4189 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf;
4190 typename DATATYPE::ModifiedType* bufMod;
4192 DATATYPE* datatype;
4193 int dest;
4194 int tag;
4197 };
4198
4199
4200 template<typename DATATYPE>
4201 void AMPI_Ssend_init_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
4203 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4204 (void)adType;
4205
4206 adType->iterateIdentifiers(h->bufIndices, h->bufTotalSize, func, userData);
4207 }
4208
4209 template<typename DATATYPE>
4210 void AMPI_Ssend_init_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
4212 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
4213 (void)adType;
4214
4215 }
4216
4217 template<typename DATATYPE>
4218 int AMPI_Ssend_init_preStart(HandleBase* handle);
4219 template<typename DATATYPE>
4220 int AMPI_Ssend_init_finish(HandleBase* handle);
4221 template<typename DATATYPE>
4222 int AMPI_Ssend_init_postEnd(HandleBase* handle);
4223 template<typename DATATYPE>
4224 int AMPI_Ssend_init(MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf, int count, DATATYPE* datatype, int dest, int tag,
4225 AMPI_Comm comm, AMPI_Request* request) {
4226 int rStatus;
4227 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4228
4229 if(!adType->isActiveType()) {
4230 // call the regular function if the type is not active
4231 rStatus = MPI_Ssend_init(buf, count, datatype->getMpiType(), dest, tag, comm, &request->request);
4232 } else {
4233
4234 // the type is an AD type so handle the buffers
4236 typename DATATYPE::ModifiedType* bufMod = nullptr;
4237 int bufElements = 0;
4238
4239 // compute the total size of the buffer
4240 bufElements = count;
4241
4242 if(datatype->isModifiedBufferRequired() ) {
4243 datatype->createModifiedTypeBuffer(bufMod, bufElements);
4244 } else {
4245 bufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(buf));
4246 }
4247
4248 rStatus = MPI_Ssend_init(bufMod, count, datatype->getModifiedMpiType(), dest, tag, comm, &request->request);
4249
4251 asyncHandle->buf = buf;
4252 asyncHandle->bufMod = bufMod;
4253 asyncHandle->count = count;
4254 asyncHandle->datatype = datatype;
4255 asyncHandle->dest = dest;
4256 asyncHandle->tag = tag;
4257 asyncHandle->comm = comm;
4258 asyncHandle->toolHandle = h;
4259 request->handle = asyncHandle;
4263 }
4264
4265 return rStatus;
4266 }
4267
4268 template<typename DATATYPE>
4270 int rStatus = 0;
4271
4273 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
4274 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
4275 int count = asyncHandle->count;
4276 DATATYPE* datatype = asyncHandle->datatype;
4277 int dest = asyncHandle->dest;
4278 int tag = asyncHandle->tag;
4279 AMPI_Comm comm = asyncHandle->comm;
4280 AMPI_Request* request = asyncHandle->request;
4282 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4283 MEDI_UNUSED(h); // Unused generated to ignore warnings
4284 MEDI_UNUSED(buf); // Unused generated to ignore warnings
4285 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
4286 MEDI_UNUSED(count); // Unused generated to ignore warnings
4287 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
4288 MEDI_UNUSED(dest); // Unused generated to ignore warnings
4289 MEDI_UNUSED(tag); // Unused generated to ignore warnings
4290 MEDI_UNUSED(comm); // Unused generated to ignore warnings
4291 MEDI_UNUSED(request); // Unused generated to ignore warnings
4292
4293
4294 if(adType->isActiveType()) {
4295
4296 int bufElements = 0;
4297
4298 // recompute the total size of the buffer
4299 bufElements = count;
4300 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
4301 if(adType->isHandleRequired()) {
4303 }
4304 adType->startAssembly(h);
4305 if(datatype->isModifiedBufferRequired()) {
4306 datatype->copyIntoModifiedBuffer(buf, 0, bufMod, 0, count);
4307 }
4308
4309 if(nullptr != h) {
4310 // gather the information for the reverse sweep
4311
4312 // create the index buffers
4313 h->bufCount = datatype->computeActiveElements(count);
4314 h->bufTotalSize = datatype->computeActiveElements(bufElements);
4315 datatype->getADTool().createIndexTypeBuffer(h->bufIndices, h->bufTotalSize);
4316
4317
4318
4319
4320 datatype->getIndices(buf, 0, h->bufIndices, 0, count);
4321
4322
4323 // pack all the variables in the handle
4329 h->count = count;
4330 h->datatype = datatype;
4331 h->dest = dest;
4332 h->tag = tag;
4333 h->comm = comm;
4334 }
4335
4336
4337 asyncHandle->toolHandle = h;
4338
4339 // create adjoint wait
4340 if(nullptr != h) {
4343 adType->addToolAction(waitH);
4344 }
4345 }
4346
4347 return rStatus;
4348 }
4349
4350 template<typename DATATYPE>
4352 int rStatus = 0;
4353
4355 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
4356 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
4357 int count = asyncHandle->count;
4358 DATATYPE* datatype = asyncHandle->datatype;
4359 int dest = asyncHandle->dest;
4360 int tag = asyncHandle->tag;
4361 AMPI_Comm comm = asyncHandle->comm;
4362 AMPI_Request* request = asyncHandle->request;
4364 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4365 MEDI_UNUSED(h); // Unused generated to ignore warnings
4366 MEDI_UNUSED(buf); // Unused generated to ignore warnings
4367 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
4368 MEDI_UNUSED(count); // Unused generated to ignore warnings
4369 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
4370 MEDI_UNUSED(dest); // Unused generated to ignore warnings
4371 MEDI_UNUSED(tag); // Unused generated to ignore warnings
4372 MEDI_UNUSED(comm); // Unused generated to ignore warnings
4373 MEDI_UNUSED(request); // Unused generated to ignore warnings
4374
4375
4376 if(adType->isActiveType()) {
4377
4378 adType->addToolAction(h);
4379
4380
4381 if(nullptr != h) {
4382 // handle the recv buffers
4383 }
4384
4385 adType->stopAssembly(h);
4386 }
4387
4388 return rStatus;
4389 }
4390
4391 template<typename DATATYPE>
4393 int rStatus = 0;
4394
4396 MEDI_OPTIONAL_CONST typename DATATYPE::Type* buf = asyncHandle->buf;
4397 typename DATATYPE::ModifiedType* bufMod = asyncHandle->bufMod;
4398 int count = asyncHandle->count;
4399 DATATYPE* datatype = asyncHandle->datatype;
4400 int dest = asyncHandle->dest;
4401 int tag = asyncHandle->tag;
4402 AMPI_Comm comm = asyncHandle->comm;
4403 AMPI_Request* request = asyncHandle->request;
4405 ADToolInterface const* adType = selectADTool(datatype->getADTool());
4406 MEDI_UNUSED(h); // Unused generated to ignore warnings
4407 MEDI_UNUSED(buf); // Unused generated to ignore warnings
4408 MEDI_UNUSED(bufMod); // Unused generated to ignore warnings
4409 MEDI_UNUSED(count); // Unused generated to ignore warnings
4410 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
4411 MEDI_UNUSED(dest); // Unused generated to ignore warnings
4412 MEDI_UNUSED(tag); // Unused generated to ignore warnings
4413 MEDI_UNUSED(comm); // Unused generated to ignore warnings
4414 MEDI_UNUSED(request); // Unused generated to ignore warnings
4415
4416 delete asyncHandle;
4417
4418 if(adType->isActiveType()) {
4419
4420
4421 if(datatype->isModifiedBufferRequired() ) {
4422 datatype->deleteModifiedTypeBuffer(bufMod);
4423 }
4424
4425 // handle is deleted by the AD tool
4426 }
4427
4428 return rStatus;
4429 }
4430
4431#endif
4432#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4433 template<typename SENDTYPE, typename RECVTYPE>
4436 typename SENDTYPE::IndexType* sendbufIndices;
4437 typename SENDTYPE::PrimalType* sendbufPrimals;
4438 /* required for async */ void* sendbufAdjoints;
4442 SENDTYPE* sendtype;
4444 typename RECVTYPE::IndexType* recvbufIndices;
4445 typename RECVTYPE::PrimalType* recvbufPrimals;
4446 typename RECVTYPE::PrimalType* recvbufOldPrimals;
4447 /* required for async */ void* recvbufAdjoints;
4451 RECVTYPE* recvtype;
4453
4455 if(nullptr != sendbufIndices) {
4456 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
4457 sendbufIndices = nullptr;
4458 }
4459 if(nullptr != sendbufPrimals) {
4460 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
4461 sendbufPrimals = nullptr;
4462 }
4463 if(nullptr != recvbufIndices) {
4464 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
4465 recvbufIndices = nullptr;
4466 }
4467 if(nullptr != recvbufPrimals) {
4468 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
4469 recvbufPrimals = nullptr;
4470 }
4471 if(nullptr != recvbufOldPrimals) {
4472 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
4473 recvbufOldPrimals = nullptr;
4474 }
4475 }
4476 };
4477
4478
4479 template<typename SENDTYPE, typename RECVTYPE>
4480 void AMPI_Allgather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
4482 (handle);
4483 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4484 (void)adType;
4485
4486 h->recvbufAdjoints = nullptr;
4487 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4488 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
4489 h->sendbufAdjoints = nullptr;
4490 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4491 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
4492 // Primal buffers are always linear in space so we can accesses them in one sweep
4493 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
4494
4495
4498
4499 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
4500 if(adType->isOldPrimalsRequired()) {
4501 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4502 }
4503 // Primal buffers are always linear in space so we can accesses them in one sweep
4504 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
4505 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
4506 }
4507
4508 template<typename SENDTYPE, typename RECVTYPE>
4509 void AMPI_Allgather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
4511 (handle);
4512 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4513 (void)adType;
4514
4515 h->recvbufAdjoints = nullptr;
4516 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4517 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4518 h->sendbufAdjoints = nullptr;
4519 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4520 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
4521 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4522 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4523
4524
4527
4528 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4529 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4530 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4531 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4532 }
4533
4534 template<typename SENDTYPE, typename RECVTYPE>
4535 void AMPI_Allgather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
4537 (handle);
4538 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4539 (void)adType;
4540
4541 h->recvbufAdjoints = nullptr;
4542 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
4543 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4544 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4545 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4546
4547 if(adType->isOldPrimalsRequired()) {
4548 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4549 }
4550 h->sendbufAdjoints = nullptr;
4551 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4553
4556
4557 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
4558 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4559 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4560 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4561 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4562 }
4563
4564 template<typename SENDTYPE, typename RECVTYPE>
4565 void AMPI_Allgather_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
4567 (handle);
4568 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4569 (void)adType;
4570
4571 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
4572 }
4573
4574 template<typename SENDTYPE, typename RECVTYPE>
4575 void AMPI_Allgather_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
4577 (handle);
4578 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4579 (void)adType;
4580
4581 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
4582 }
4583
4584 template<typename SENDTYPE, typename RECVTYPE>
4585 int AMPI_Allgather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
4586 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm) {
4587 int rStatus;
4588 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
4589
4590 if(!adType->isActiveType()) {
4591 // call the regular function if the type is not active
4592 rStatus = MPI_Allgather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm);
4593 } else {
4594
4595 // the type is an AD type so handle the buffers
4597 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
4598 int sendbufElements = 0;
4599
4600 // compute the total size of the buffer
4601 if(AMPI_IN_PLACE != sendbuf) {
4602 sendbufElements = sendcount;
4603 } else {
4604 sendbufElements = recvcount;
4605 }
4606
4607 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4608 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
4609 } else {
4610 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
4611 }
4612 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
4613 int recvbufElements = 0;
4614
4615 // compute the total size of the buffer
4616 recvbufElements = recvcount * getCommSize(comm);
4617
4618 if(recvtype->isModifiedBufferRequired() ) {
4619 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
4620 } else {
4621 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
4622 }
4623
4624 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
4625 if(adType->isHandleRequired()) {
4627 }
4628 adType->startAssembly(h);
4629 if(sendtype->isModifiedBufferRequired()) {
4630 if(AMPI_IN_PLACE != sendbuf) {
4631 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
4632 } else {
4633 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
4634 recvcount);
4635 }
4636 }
4637
4638 if(nullptr != h) {
4639 // gather the information for the reverse sweep
4640
4641 // create the index buffers
4642 if(AMPI_IN_PLACE != sendbuf) {
4643 h->sendbufCount = sendtype->computeActiveElements(sendcount);
4644 } else {
4645 h->sendbufCount = recvtype->computeActiveElements(recvcount);
4646 }
4647 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
4648 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
4649 h->recvbufCount = recvtype->computeActiveElements(recvcount);
4650 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
4651 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
4652
4653
4654 // extract the old primal values from the recv buffer if the AD tool
4655 // needs the primal values reset
4656 if(adType->isOldPrimalsRequired()) {
4657 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
4658 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
4659 }
4660
4661
4662 if(AMPI_IN_PLACE != sendbuf) {
4663 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
4664 } else {
4665 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
4666 }
4667
4668 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
4669
4670 // pack all the variables in the handle
4676 h->sendcount = sendcount;
4677 h->sendtype = sendtype;
4678 h->recvcount = recvcount;
4679 h->recvtype = recvtype;
4680 h->comm = comm;
4681 }
4682
4683 if(!recvtype->isModifiedBufferRequired()) {
4684 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
4685 }
4686
4687 rStatus = MPI_Allgather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
4688 recvtype->getModifiedMpiType(), comm);
4689 adType->addToolAction(h);
4690
4691 if(recvtype->isModifiedBufferRequired()) {
4692 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
4693 }
4694
4695 if(nullptr != h) {
4696 // handle the recv buffers
4697 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
4698 }
4699
4700 adType->stopAssembly(h);
4701
4702 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4703 sendtype->deleteModifiedTypeBuffer(sendbufMod);
4704 }
4705 if(recvtype->isModifiedBufferRequired() ) {
4706 recvtype->deleteModifiedTypeBuffer(recvbufMod);
4707 }
4708
4709 // handle is deleted by the AD tool
4710 }
4711
4712 return rStatus;
4713 }
4714
4715#endif
4716#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
4717 template<typename SENDTYPE, typename RECVTYPE>
4720 typename SENDTYPE::IndexType* sendbufIndices;
4721 typename SENDTYPE::PrimalType* sendbufPrimals;
4722 /* required for async */ void* sendbufAdjoints;
4726 SENDTYPE* sendtype;
4728 typename RECVTYPE::IndexType* recvbufIndices;
4729 typename RECVTYPE::PrimalType* recvbufPrimals;
4730 typename RECVTYPE::PrimalType* recvbufOldPrimals;
4731 /* required for async */ void* recvbufAdjoints;
4733 /* required for async */ int* recvbufCountVec;
4734 /* required for async */ int* recvbufDisplsVec;
4737 RECVTYPE* recvtype;
4739
4741 if(nullptr != sendbufIndices) {
4742 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
4743 sendbufIndices = nullptr;
4744 }
4745 if(nullptr != sendbufPrimals) {
4746 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
4747 sendbufPrimals = nullptr;
4748 }
4749 if(nullptr != recvbufIndices) {
4750 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
4751 recvbufIndices = nullptr;
4752 }
4753 if(nullptr != recvbufPrimals) {
4754 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
4755 recvbufPrimals = nullptr;
4756 }
4757 if(nullptr != recvbufOldPrimals) {
4758 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
4759 recvbufOldPrimals = nullptr;
4760 }
4761 if(nullptr != recvbufCount) {
4762 delete [] recvbufCount;
4763 recvbufCount = nullptr;
4764 }
4765 }
4766 };
4767
4768
4769 template<typename SENDTYPE, typename RECVTYPE>
4770 void AMPI_Allgatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
4772 (handle);
4773 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4774 (void)adType;
4775
4776 h->recvbufAdjoints = nullptr;
4778 adjointInterface->getVectorSize());
4779 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
4780 h->sendbufAdjoints = nullptr;
4781 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4782 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
4783 // Primal buffers are always linear in space so we can accesses them in one sweep
4784 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
4785
4786
4789
4790 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
4791 if(adType->isOldPrimalsRequired()) {
4792 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4793 }
4794 // Primal buffers are always linear in space so we can accesses them in one sweep
4795 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
4796 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
4797 delete [] h->recvbufCountVec;
4798 delete [] h->recvbufDisplsVec;
4799 }
4800
4801 template<typename SENDTYPE, typename RECVTYPE>
4802 void AMPI_Allgatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
4804 (handle);
4805 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4806 (void)adType;
4807
4808 h->recvbufAdjoints = nullptr;
4810 adjointInterface->getVectorSize());
4811 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4812 h->sendbufAdjoints = nullptr;
4813 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4814 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
4815 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4816 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4817
4818
4821
4822 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4823 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4824 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4825 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4826 delete [] h->recvbufCountVec;
4827 delete [] h->recvbufDisplsVec;
4828 }
4829
4830 template<typename SENDTYPE, typename RECVTYPE>
4831 void AMPI_Allgatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
4833 (handle);
4834 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4835 (void)adType;
4836
4837 h->recvbufAdjoints = nullptr;
4839 adjointInterface->getVectorSize());
4840 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
4841 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4842 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
4843
4844 if(adType->isOldPrimalsRequired()) {
4845 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
4846 }
4847 h->sendbufAdjoints = nullptr;
4848 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
4850
4853
4854 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
4855 // Adjoint buffers are always linear in space so we can accesses them in one sweep
4856 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
4857 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
4858 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
4859 delete [] h->recvbufCountVec;
4860 delete [] h->recvbufDisplsVec;
4861 }
4862
4863 template<typename SENDTYPE, typename RECVTYPE>
4864 void AMPI_Allgatherv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
4866 (handle);
4867 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4868 (void)adType;
4869
4870 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
4871 }
4872
4873 template<typename SENDTYPE, typename RECVTYPE>
4874 void AMPI_Allgatherv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
4876 (handle);
4877 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
4878 (void)adType;
4879
4880 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
4881 }
4882
4883 template<typename SENDTYPE, typename RECVTYPE>
4884 int AMPI_Allgatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
4885 typename RECVTYPE::Type* recvbuf, MEDI_OPTIONAL_CONST int* recvcounts, MEDI_OPTIONAL_CONST int* displs,
4886 RECVTYPE* recvtype, AMPI_Comm comm) {
4887 int rStatus;
4888 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
4889
4890 if(!adType->isActiveType()) {
4891 // call the regular function if the type is not active
4892 rStatus = MPI_Allgatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs,
4893 recvtype->getMpiType(), comm);
4894 } else {
4895
4896 // the type is an AD type so handle the buffers
4898 MEDI_OPTIONAL_CONST int* displsMod = displs;
4899 int displsTotalSize = 0;
4900 if(nullptr != displs) {
4901 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
4902 if(recvtype->isModifiedBufferRequired()) {
4903 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
4904 }
4905 }
4906 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
4907 int sendbufElements = 0;
4908
4909 // compute the total size of the buffer
4910 if(AMPI_IN_PLACE != sendbuf) {
4911 sendbufElements = sendcount;
4912 } else {
4913 sendbufElements = recvcounts[getCommRank(comm)];
4914 }
4915
4916 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
4917 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
4918 } else {
4919 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
4920 }
4921 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
4922 int recvbufElements = 0;
4923
4924 // compute the total size of the buffer
4925 recvbufElements = displsTotalSize;
4926
4927 if(recvtype->isModifiedBufferRequired() ) {
4928 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
4929 } else {
4930 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
4931 }
4932
4933 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
4934 if(adType->isHandleRequired()) {
4936 }
4937 adType->startAssembly(h);
4938 if(sendtype->isModifiedBufferRequired()) {
4939 if(AMPI_IN_PLACE != sendbuf) {
4940 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
4941 } else {
4942 {
4943 const int rank = getCommRank(comm);
4944 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
4945 }
4946 }
4947 }
4948
4949 if(nullptr != h) {
4950 // gather the information for the reverse sweep
4951
4952 // create the index buffers
4953 if(AMPI_IN_PLACE != sendbuf) {
4954 h->sendbufCount = sendtype->computeActiveElements(sendcount);
4955 } else {
4956 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
4957 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
4958 }
4959 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
4960 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
4961 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
4962 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
4963 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
4964
4965
4966 // extract the old primal values from the recv buffer if the AD tool
4967 // needs the primal values reset
4968 if(adType->isOldPrimalsRequired()) {
4969 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
4970 for(int i = 0; i < getCommSize(comm); ++i) {
4971 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
4972 }
4973 }
4974
4975
4976 if(AMPI_IN_PLACE != sendbuf) {
4977 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
4978 } else {
4979 {
4980 const int rank = getCommRank(comm);
4981 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
4982 }
4983 }
4984
4985 for(int i = 0; i < getCommSize(comm); ++i) {
4986 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
4987 }
4988
4989 // pack all the variables in the handle
4995 h->sendcount = sendcount;
4996 h->sendtype = sendtype;
4997 h->recvcounts = recvcounts;
4998 h->displs = displs;
4999 h->recvtype = recvtype;
5000 h->comm = comm;
5001 }
5002
5003 if(!recvtype->isModifiedBufferRequired()) {
5004 for(int i = 0; i < getCommSize(comm); ++i) {
5005 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
5006 }
5007 }
5008
5009 rStatus = MPI_Allgatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
5010 recvtype->getModifiedMpiType(), comm);
5011 adType->addToolAction(h);
5012
5013 if(recvtype->isModifiedBufferRequired()) {
5014 for(int i = 0; i < getCommSize(comm); ++i) {
5015 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
5016 }
5017 }
5018
5019 if(nullptr != h) {
5020 // handle the recv buffers
5021 for(int i = 0; i < getCommSize(comm); ++i) {
5022 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
5023 }
5024 }
5025
5026 adType->stopAssembly(h);
5027 if(recvtype->isModifiedBufferRequired()) {
5028 delete [] displsMod;
5029 }
5030
5031 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5032 sendtype->deleteModifiedTypeBuffer(sendbufMod);
5033 }
5034 if(recvtype->isModifiedBufferRequired() ) {
5035 recvtype->deleteModifiedTypeBuffer(recvbufMod);
5036 }
5037
5038 // handle is deleted by the AD tool
5039 }
5040
5041 return rStatus;
5042 }
5043
5044#endif
5045#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
5046 template<typename DATATYPE>
5049 typename DATATYPE::IndexType* sendbufIndices;
5050 typename DATATYPE::PrimalType* sendbufPrimals;
5051 /* required for async */ void* sendbufAdjoints;
5055 typename DATATYPE::IndexType* recvbufIndices;
5056 typename DATATYPE::PrimalType* recvbufPrimals;
5057 typename DATATYPE::PrimalType* recvbufOldPrimals;
5058 /* required for async */ void* recvbufAdjoints;
5062 DATATYPE* datatype;
5065
5067 if(nullptr != sendbufIndices) {
5068 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
5069 sendbufIndices = nullptr;
5070 }
5071 if(nullptr != sendbufPrimals) {
5072 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
5073 sendbufPrimals = nullptr;
5074 }
5075 if(nullptr != recvbufIndices) {
5076 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
5077 recvbufIndices = nullptr;
5078 }
5079 if(nullptr != recvbufPrimals) {
5080 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
5081 recvbufPrimals = nullptr;
5082 }
5083 if(nullptr != recvbufOldPrimals) {
5084 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
5085 recvbufOldPrimals = nullptr;
5086 }
5087 }
5088 };
5089
5090
5091 template<typename DATATYPE>
5092 void AMPI_Allreduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
5094 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5095 (void)adType;
5096
5097 AMPI_Op convOp = adType->convertOperator(h->op);
5098 (void)convOp;
5099 h->recvbufAdjoints = nullptr;
5100 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5101 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
5102 h->sendbufAdjoints = nullptr;
5103 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5104 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
5105 // Primal buffers are always linear in space so we can accesses them in one sweep
5106 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
5107
5108
5110 h->count, h->datatype, h->op, h->comm);
5111
5112 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
5113 if(adType->isOldPrimalsRequired()) {
5114 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5115 }
5116 // Primal buffers are always linear in space so we can accesses them in one sweep
5117 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
5118 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
5119 }
5120
5121 template<typename DATATYPE>
5122 void AMPI_Allreduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
5124 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5125 (void)adType;
5126
5127 AMPI_Op convOp = adType->convertOperator(h->op);
5128 (void)convOp;
5129 h->recvbufAdjoints = nullptr;
5130 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5131 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5132 h->sendbufAdjoints = nullptr;
5133 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5134 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5135 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5136 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5137
5138
5140 h->count, h->datatype, h->op, h->comm);
5141
5142 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5143 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5144 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5145 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5146 }
5147
5148 template<typename DATATYPE>
5149 void AMPI_Allreduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
5151 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5152 (void)adType;
5153
5154 AMPI_Op convOp = adType->convertOperator(h->op);
5155 (void)convOp;
5156 h->recvbufAdjoints = nullptr;
5157 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5158 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5159 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5160 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5161
5162 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
5163 if(adType->isOldPrimalsRequired()) {
5164 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5165 }
5166 h->sendbufAdjoints = nullptr;
5167 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5169
5171 h->count, h->datatype, h->op, h->comm);
5172
5173 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
5174 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
5175 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
5177 adjointInterface->getVectorSize());
5178 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5179 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5180 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5181 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5182 }
5183
5184 template<typename DATATYPE>
5185 void AMPI_Allreduce_global_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
5187 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5188 (void)adType;
5189
5190 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
5191 }
5192
5193 template<typename DATATYPE>
5194 void AMPI_Allreduce_global_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
5196 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
5197 (void)adType;
5198
5199 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
5200 }
5201
5202 template<typename DATATYPE>
5203 int AMPI_Allreduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
5204 int count, DATATYPE* datatype, AMPI_Op op, AMPI_Comm comm) {
5205 int rStatus;
5206 ADToolInterface const* adType = selectADTool(datatype->getADTool());
5207 AMPI_Op convOp = adType->convertOperator(op);
5208 (void)convOp;
5209
5210 if(!adType->isActiveType()) {
5211 // call the regular function if the type is not active
5212 rStatus = MPI_Allreduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, comm);
5213 } else {
5214
5215 // the type is an AD type so handle the buffers
5217 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
5218 int sendbufElements = 0;
5219
5220 // compute the total size of the buffer
5221 if(AMPI_IN_PLACE != sendbuf) {
5222 sendbufElements = count;
5223 } else {
5224 sendbufElements = count;
5225 }
5226
5227 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5228 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
5229 } else {
5230 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
5231 }
5232 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
5233 int recvbufElements = 0;
5234
5235 // compute the total size of the buffer
5236 recvbufElements = count;
5237
5238 if(datatype->isModifiedBufferRequired() ) {
5239 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
5240 } else {
5241 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
5242 }
5243
5244 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
5245 if(adType->isHandleRequired()) {
5247 }
5248 adType->startAssembly(h);
5249 if(datatype->isModifiedBufferRequired()) {
5250 if(AMPI_IN_PLACE != sendbuf) {
5251 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
5252 } else {
5253 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
5254 }
5255 }
5256
5257 if(nullptr != h) {
5258 // gather the information for the reverse sweep
5259
5260 // create the index buffers
5261 if(AMPI_IN_PLACE != sendbuf) {
5262 h->sendbufCount = datatype->computeActiveElements(count);
5263 } else {
5264 h->sendbufCount = datatype->computeActiveElements(count);
5265 }
5266 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
5267 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
5268 h->recvbufCount = datatype->computeActiveElements(count);
5269 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
5270 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
5271
5272 // extract the primal values for the operator if required
5273 if(convOp.requiresPrimal) {
5274 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
5275 if(AMPI_IN_PLACE != sendbuf) {
5276 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
5277 } else {
5278 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
5279 }
5280 }
5281
5282 // extract the old primal values from the recv buffer if the AD tool
5283 // needs the primal values reset
5284 if(adType->isOldPrimalsRequired()) {
5285 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
5286 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
5287 }
5288
5289
5290 if(AMPI_IN_PLACE != sendbuf) {
5291 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
5292 } else {
5293 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
5294 }
5295
5296 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
5297
5298 // pack all the variables in the handle
5304 h->count = count;
5305 h->datatype = datatype;
5306 h->op = op;
5307 h->comm = comm;
5308 }
5309
5310 if(!datatype->isModifiedBufferRequired()) {
5311 datatype->clearIndices(recvbuf, 0, count);
5312 }
5313
5314 rStatus = MPI_Allreduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction,
5315 comm);
5316 adType->addToolAction(h);
5317
5318 if(datatype->isModifiedBufferRequired()) {
5319 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
5320 }
5321
5322 if(nullptr != h) {
5323 // handle the recv buffers
5324 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
5325 }
5326 // extract the primal values for the operator if required
5327 if(nullptr != h && convOp.requiresPrimal) {
5328 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
5329 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
5330 }
5331
5332 adType->stopAssembly(h);
5333
5334 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5335 datatype->deleteModifiedTypeBuffer(sendbufMod);
5336 }
5337 if(datatype->isModifiedBufferRequired() ) {
5338 datatype->deleteModifiedTypeBuffer(recvbufMod);
5339 }
5340
5341 // handle is deleted by the AD tool
5342 }
5343
5344 return rStatus;
5345 }
5346
5347#endif
5348#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
5349 template<typename SENDTYPE, typename RECVTYPE>
5352 typename SENDTYPE::IndexType* sendbufIndices;
5353 typename SENDTYPE::PrimalType* sendbufPrimals;
5354 /* required for async */ void* sendbufAdjoints;
5358 SENDTYPE* sendtype;
5360 typename RECVTYPE::IndexType* recvbufIndices;
5361 typename RECVTYPE::PrimalType* recvbufPrimals;
5362 typename RECVTYPE::PrimalType* recvbufOldPrimals;
5363 /* required for async */ void* recvbufAdjoints;
5367 RECVTYPE* recvtype;
5369
5371 if(nullptr != sendbufIndices) {
5372 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
5373 sendbufIndices = nullptr;
5374 }
5375 if(nullptr != sendbufPrimals) {
5376 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
5377 sendbufPrimals = nullptr;
5378 }
5379 if(nullptr != recvbufIndices) {
5380 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
5381 recvbufIndices = nullptr;
5382 }
5383 if(nullptr != recvbufPrimals) {
5384 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
5385 recvbufPrimals = nullptr;
5386 }
5387 if(nullptr != recvbufOldPrimals) {
5388 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
5389 recvbufOldPrimals = nullptr;
5390 }
5391 }
5392 };
5393
5394
5395 template<typename SENDTYPE, typename RECVTYPE>
5396 void AMPI_Alltoall_p(HandleBase* handle, AdjointInterface* adjointInterface) {
5398 (handle);
5399 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5400 (void)adType;
5401
5402 h->recvbufAdjoints = nullptr;
5403 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5404 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
5405 h->sendbufAdjoints = nullptr;
5406 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5407 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
5408 // Primal buffers are always linear in space so we can accesses them in one sweep
5409 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
5410
5411
5414
5415 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
5416 if(adType->isOldPrimalsRequired()) {
5417 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5418 }
5419 // Primal buffers are always linear in space so we can accesses them in one sweep
5420 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
5421 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
5422 }
5423
5424 template<typename SENDTYPE, typename RECVTYPE>
5425 void AMPI_Alltoall_d(HandleBase* handle, AdjointInterface* adjointInterface) {
5427 (handle);
5428 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5429 (void)adType;
5430
5431 h->recvbufAdjoints = nullptr;
5432 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5433 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5434 h->sendbufAdjoints = nullptr;
5435 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5436 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5437 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5438 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5439
5440
5443
5444 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5445 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5446 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5447 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5448 }
5449
5450 template<typename SENDTYPE, typename RECVTYPE>
5451 void AMPI_Alltoall_b(HandleBase* handle, AdjointInterface* adjointInterface) {
5453 (handle);
5454 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5455 (void)adType;
5456
5457 h->recvbufAdjoints = nullptr;
5458 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
5459 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5460 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5461 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5462
5463 if(adType->isOldPrimalsRequired()) {
5464 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5465 }
5466 h->sendbufAdjoints = nullptr;
5467 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
5468 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5469
5472
5473 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5474 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5475 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5476 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5477 }
5478
5479 template<typename SENDTYPE, typename RECVTYPE>
5480 void AMPI_Alltoall_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
5482 (handle);
5483 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5484 (void)adType;
5485
5486 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
5487 }
5488
5489 template<typename SENDTYPE, typename RECVTYPE>
5490 void AMPI_Alltoall_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
5492 (handle);
5493 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5494 (void)adType;
5495
5496 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
5497 }
5498
5499 template<typename SENDTYPE, typename RECVTYPE>
5500 int AMPI_Alltoall(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
5501 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm) {
5502 int rStatus;
5503 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
5504
5505 if(!adType->isActiveType()) {
5506 // call the regular function if the type is not active
5507 rStatus = MPI_Alltoall(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm);
5508 } else {
5509
5510 // the type is an AD type so handle the buffers
5512 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
5513 int sendbufElements = 0;
5514
5515 // compute the total size of the buffer
5516 if(AMPI_IN_PLACE != sendbuf) {
5517 sendbufElements = sendcount * getCommSize(comm);
5518 } else {
5519 sendbufElements = recvcount * getCommSize(comm);
5520 }
5521
5522 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5523 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
5524 } else {
5525 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
5526 }
5527 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
5528 int recvbufElements = 0;
5529
5530 // compute the total size of the buffer
5531 recvbufElements = recvcount * getCommSize(comm);
5532
5533 if(recvtype->isModifiedBufferRequired() ) {
5534 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
5535 } else {
5536 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
5537 }
5538
5539 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
5540 if(adType->isHandleRequired()) {
5542 }
5543 adType->startAssembly(h);
5544 if(sendtype->isModifiedBufferRequired()) {
5545 if(AMPI_IN_PLACE != sendbuf) {
5546 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
5547 } else {
5548 recvtype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
5549 }
5550 }
5551
5552 if(nullptr != h) {
5553 // gather the information for the reverse sweep
5554
5555 // create the index buffers
5556 if(AMPI_IN_PLACE != sendbuf) {
5557 h->sendbufCount = sendtype->computeActiveElements(sendcount);
5558 } else {
5559 h->sendbufCount = recvtype->computeActiveElements(recvcount);
5560 }
5561 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
5562 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
5563 h->recvbufCount = recvtype->computeActiveElements(recvcount);
5564 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
5565 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
5566
5567
5568 // extract the old primal values from the recv buffer if the AD tool
5569 // needs the primal values reset
5570 if(adType->isOldPrimalsRequired()) {
5571 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
5572 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
5573 }
5574
5575
5576 if(AMPI_IN_PLACE != sendbuf) {
5577 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
5578 } else {
5579 recvtype->getIndices(recvbuf, 0, h->sendbufIndices, 0, recvcount * getCommSize(comm));
5580 }
5581
5582 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
5583
5584 // pack all the variables in the handle
5590 h->sendcount = sendcount;
5591 h->sendtype = sendtype;
5592 h->recvcount = recvcount;
5593 h->recvtype = recvtype;
5594 h->comm = comm;
5595 }
5596
5597 if(!recvtype->isModifiedBufferRequired()) {
5598 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
5599 }
5600
5601 rStatus = MPI_Alltoall(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
5602 recvtype->getModifiedMpiType(), comm);
5603 adType->addToolAction(h);
5604
5605 if(recvtype->isModifiedBufferRequired()) {
5606 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
5607 }
5608
5609 if(nullptr != h) {
5610 // handle the recv buffers
5611 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
5612 }
5613
5614 adType->stopAssembly(h);
5615
5616 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5617 sendtype->deleteModifiedTypeBuffer(sendbufMod);
5618 }
5619 if(recvtype->isModifiedBufferRequired() ) {
5620 recvtype->deleteModifiedTypeBuffer(recvbufMod);
5621 }
5622
5623 // handle is deleted by the AD tool
5624 }
5625
5626 return rStatus;
5627 }
5628
5629#endif
5630#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
5631 template<typename SENDTYPE, typename RECVTYPE>
5634 typename SENDTYPE::IndexType* sendbufIndices;
5635 typename SENDTYPE::PrimalType* sendbufPrimals;
5636 /* required for async */ void* sendbufAdjoints;
5638 /* required for async */ int* sendbufCountVec;
5639 /* required for async */ int* sendbufDisplsVec;
5642 SENDTYPE* sendtype;
5644 typename RECVTYPE::IndexType* recvbufIndices;
5645 typename RECVTYPE::PrimalType* recvbufPrimals;
5646 typename RECVTYPE::PrimalType* recvbufOldPrimals;
5647 /* required for async */ void* recvbufAdjoints;
5649 /* required for async */ int* recvbufCountVec;
5650 /* required for async */ int* recvbufDisplsVec;
5653 RECVTYPE* recvtype;
5655
5657 if(nullptr != sendbufIndices) {
5658 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
5659 sendbufIndices = nullptr;
5660 }
5661 if(nullptr != sendbufPrimals) {
5662 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
5663 sendbufPrimals = nullptr;
5664 }
5665 if(nullptr != sendbufCount) {
5666 delete [] sendbufCount;
5667 sendbufCount = nullptr;
5668 }
5669 if(nullptr != recvbufIndices) {
5670 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
5671 recvbufIndices = nullptr;
5672 }
5673 if(nullptr != recvbufPrimals) {
5674 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
5675 recvbufPrimals = nullptr;
5676 }
5677 if(nullptr != recvbufOldPrimals) {
5678 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
5679 recvbufOldPrimals = nullptr;
5680 }
5681 if(nullptr != recvbufCount) {
5682 delete [] recvbufCount;
5683 recvbufCount = nullptr;
5684 }
5685 }
5686 };
5687
5688
5689 template<typename SENDTYPE, typename RECVTYPE>
5690 void AMPI_Alltoallv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
5692 (handle);
5693 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5694 (void)adType;
5695
5696 h->recvbufAdjoints = nullptr;
5698 adjointInterface->getVectorSize());
5699 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
5700 h->sendbufAdjoints = nullptr;
5702 adjointInterface->getVectorSize());
5703 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
5704 // Primal buffers are always linear in space so we can accesses them in one sweep
5705 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
5706
5707
5710 h->recvtype, h->comm);
5711
5712 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
5713 delete [] h->sendbufCountVec;
5714 delete [] h->sendbufDisplsVec;
5715 if(adType->isOldPrimalsRequired()) {
5716 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5717 }
5718 // Primal buffers are always linear in space so we can accesses them in one sweep
5719 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
5720 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
5721 delete [] h->recvbufCountVec;
5722 delete [] h->recvbufDisplsVec;
5723 }
5724
5725 template<typename SENDTYPE, typename RECVTYPE>
5726 void AMPI_Alltoallv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
5728 (handle);
5729 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5730 (void)adType;
5731
5732 h->recvbufAdjoints = nullptr;
5734 adjointInterface->getVectorSize());
5735 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5736 h->sendbufAdjoints = nullptr;
5738 adjointInterface->getVectorSize());
5739 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5740 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5741 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5742
5743
5746 h->recvtype, h->comm);
5747
5748 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5749 delete [] h->sendbufCountVec;
5750 delete [] h->sendbufDisplsVec;
5751 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5752 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5753 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5754 delete [] h->recvbufCountVec;
5755 delete [] h->recvbufDisplsVec;
5756 }
5757
5758 template<typename SENDTYPE, typename RECVTYPE>
5759 void AMPI_Alltoallv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
5761 (handle);
5762 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5763 (void)adType;
5764
5765 h->recvbufAdjoints = nullptr;
5767 adjointInterface->getVectorSize());
5768 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
5769 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5770 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
5771
5772 if(adType->isOldPrimalsRequired()) {
5773 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
5774 }
5775 h->sendbufAdjoints = nullptr;
5777 adjointInterface->getVectorSize());
5778 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
5779
5782 h->recvtype, h->comm);
5783
5784 // Adjoint buffers are always linear in space so we can accesses them in one sweep
5785 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
5786 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
5787 delete [] h->sendbufCountVec;
5788 delete [] h->sendbufDisplsVec;
5789 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
5790 delete [] h->recvbufCountVec;
5791 delete [] h->recvbufDisplsVec;
5792 }
5793
5794 template<typename SENDTYPE, typename RECVTYPE>
5795 void AMPI_Alltoallv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
5797 (handle);
5798 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5799 (void)adType;
5800
5801 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
5802 }
5803
5804 template<typename SENDTYPE, typename RECVTYPE>
5805 void AMPI_Alltoallv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
5807 (handle);
5808 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
5809 (void)adType;
5810
5811 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
5812 }
5813
5814 template<typename SENDTYPE, typename RECVTYPE>
5815 int AMPI_Alltoallv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, MEDI_OPTIONAL_CONST int* sendcounts,
5816 MEDI_OPTIONAL_CONST int* sdispls, SENDTYPE* sendtype, typename RECVTYPE::Type* recvbuf,
5817 MEDI_OPTIONAL_CONST int* recvcounts, MEDI_OPTIONAL_CONST int* rdispls, RECVTYPE* recvtype, AMPI_Comm comm) {
5818 int rStatus;
5819 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
5820
5821 if(!adType->isActiveType()) {
5822 // call the regular function if the type is not active
5823 rStatus = MPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype->getMpiType(), recvbuf, recvcounts, rdispls,
5824 recvtype->getMpiType(), comm);
5825 } else {
5826
5827 // the type is an AD type so handle the buffers
5829 MEDI_OPTIONAL_CONST int* sdisplsMod = sdispls;
5830 int sdisplsTotalSize = 0;
5831 if(nullptr != sdispls) {
5832 sdisplsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
5833 if(recvtype->isModifiedBufferRequired()) {
5834 sdisplsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
5835 }
5836 }
5837 MEDI_OPTIONAL_CONST int* rdisplsMod = rdispls;
5838 int rdisplsTotalSize = 0;
5839 if(nullptr != rdispls) {
5840 rdisplsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
5841 if(recvtype->isModifiedBufferRequired()) {
5842 rdisplsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
5843 }
5844 }
5845 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
5846 int sendbufElements = 0;
5847
5848 // compute the total size of the buffer
5849 if(AMPI_IN_PLACE != sendbuf) {
5850 sendbufElements = sdisplsTotalSize;
5851 } else {
5852 sendbufElements = rdisplsTotalSize;
5853 }
5854
5855 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5856 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
5857 } else {
5858 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
5859 }
5860 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
5861 int recvbufElements = 0;
5862
5863 // compute the total size of the buffer
5864 recvbufElements = rdisplsTotalSize;
5865
5866 if(recvtype->isModifiedBufferRequired() ) {
5867 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
5868 } else {
5869 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
5870 }
5871
5872 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
5873 if(adType->isHandleRequired()) {
5875 }
5876 adType->startAssembly(h);
5877 if(sendtype->isModifiedBufferRequired()) {
5878 if(AMPI_IN_PLACE != sendbuf) {
5879 for(int i = 0; i < getCommSize(comm); ++i) {
5880 sendtype->copyIntoModifiedBuffer(sendbuf, sdispls[i], sendbufMod, sdisplsMod[i], sendcounts[i]);
5881 }
5882 } else {
5883 for(int i = 0; i < getCommSize(comm); ++i) {
5884 recvtype->copyIntoModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
5885 }
5886 }
5887 }
5888
5889 if(nullptr != h) {
5890 // gather the information for the reverse sweep
5891
5892 // create the index buffers
5893 if(AMPI_IN_PLACE != sendbuf) {
5894 createLinearIndexCounts(h->sendbufCount, sendcounts, sdispls, getCommSize(comm), sendtype);
5895 } else {
5896 createLinearIndexCounts(h->sendbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
5897 }
5898 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
5899 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
5900 createLinearIndexCounts(h->recvbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
5901 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
5902 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
5903
5904
5905 // extract the old primal values from the recv buffer if the AD tool
5906 // needs the primal values reset
5907 if(adType->isOldPrimalsRequired()) {
5908 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
5909 for(int i = 0; i < getCommSize(comm); ++i) {
5910 recvtype->getValues(recvbuf, rdispls[i], h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
5911 }
5912 }
5913
5914
5915 if(AMPI_IN_PLACE != sendbuf) {
5916 for(int i = 0; i < getCommSize(comm); ++i) {
5917 sendtype->getIndices(sendbuf, sdispls[i], h->sendbufIndices, sdisplsMod[i], sendcounts[i]);
5918 }
5919 } else {
5920 for(int i = 0; i < getCommSize(comm); ++i) {
5921 recvtype->getIndices(recvbuf, rdispls[i], h->sendbufIndices, rdisplsMod[i], recvcounts[i]);
5922 }
5923 }
5924
5925 for(int i = 0; i < getCommSize(comm); ++i) {
5926 recvtype->createIndices(recvbuf, rdispls[i], h->recvbufIndices, rdisplsMod[i], recvcounts[i]);
5927 }
5928
5929 // pack all the variables in the handle
5935 h->sendcounts = sendcounts;
5936 h->sdispls = sdispls;
5937 h->sendtype = sendtype;
5938 h->recvcounts = recvcounts;
5939 h->rdispls = rdispls;
5940 h->recvtype = recvtype;
5941 h->comm = comm;
5942 }
5943
5944 if(!recvtype->isModifiedBufferRequired()) {
5945 for(int i = 0; i < getCommSize(comm); ++i) {
5946 recvtype->clearIndices(recvbuf, rdispls[i], recvcounts[i]);
5947 }
5948 }
5949
5950 rStatus = MPI_Alltoallv(sendbufMod, sendcounts, sdisplsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcounts,
5951 rdisplsMod, recvtype->getModifiedMpiType(), comm);
5952 adType->addToolAction(h);
5953
5954 if(recvtype->isModifiedBufferRequired()) {
5955 for(int i = 0; i < getCommSize(comm); ++i) {
5956 recvtype->copyFromModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
5957 }
5958 }
5959
5960 if(nullptr != h) {
5961 // handle the recv buffers
5962 for(int i = 0; i < getCommSize(comm); ++i) {
5963 recvtype->registerValue(recvbuf, rdispls[i], h->recvbufIndices, h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
5964 }
5965 }
5966
5967 adType->stopAssembly(h);
5968 if(recvtype->isModifiedBufferRequired()) {
5969 delete [] sdisplsMod;
5970 }
5971 if(recvtype->isModifiedBufferRequired()) {
5972 delete [] rdisplsMod;
5973 }
5974
5975 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
5976 sendtype->deleteModifiedTypeBuffer(sendbufMod);
5977 }
5978 if(recvtype->isModifiedBufferRequired() ) {
5979 recvtype->deleteModifiedTypeBuffer(recvbufMod);
5980 }
5981
5982 // handle is deleted by the AD tool
5983 }
5984
5985 return rStatus;
5986 }
5987
5988#endif
5989#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
5990 template<typename DATATYPE>
5993 typename DATATYPE::IndexType* bufferSendIndices;
5994 typename DATATYPE::PrimalType* bufferSendPrimals;
5995 /* required for async */ void* bufferSendAdjoints;
5999 typename DATATYPE::IndexType* bufferRecvIndices;
6000 typename DATATYPE::PrimalType* bufferRecvPrimals;
6001 typename DATATYPE::PrimalType* bufferRecvOldPrimals;
6002 /* required for async */ void* bufferRecvAdjoints;
6006 DATATYPE* datatype;
6007 int root;
6009
6011 if(nullptr != bufferSendIndices) {
6012 datatype->getADTool().deleteIndexTypeBuffer(bufferSendIndices);
6013 bufferSendIndices = nullptr;
6014 }
6015 if(nullptr != bufferSendPrimals) {
6016 datatype->getADTool().deletePrimalTypeBuffer(bufferSendPrimals);
6017 bufferSendPrimals = nullptr;
6018 }
6019 if(nullptr != bufferRecvIndices) {
6020 datatype->getADTool().deleteIndexTypeBuffer(bufferRecvIndices);
6021 bufferRecvIndices = nullptr;
6022 }
6023 if(nullptr != bufferRecvPrimals) {
6024 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvPrimals);
6025 bufferRecvPrimals = nullptr;
6026 }
6027 if(nullptr != bufferRecvOldPrimals) {
6028 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvOldPrimals);
6029 bufferRecvOldPrimals = nullptr;
6030 }
6031 }
6032 };
6033
6034
6035 template<typename DATATYPE>
6036 void AMPI_Bcast_wrap_p(HandleBase* handle, AdjointInterface* adjointInterface) {
6038 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
6039 (void)adType;
6040
6041 h->bufferRecvAdjoints = nullptr;
6042 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
6043 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferRecvPrimals, h->bufferRecvTotalSize );
6044 h->bufferSendAdjoints = nullptr;
6045 if(h->root == getCommRank(h->comm)) {
6046 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
6047 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferSendPrimals, h->bufferSendTotalSize );
6048 // Primal buffers are always linear in space so we can accesses them in one sweep
6050
6051 }
6052
6054 h->count, h->datatype, h->root, h->comm);
6055
6056 if(h->root == getCommRank(h->comm)) {
6057 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferSendPrimals);
6058 }
6059 if(adType->isOldPrimalsRequired()) {
6061 }
6062 // Primal buffers are always linear in space so we can accesses them in one sweep
6064 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferRecvPrimals);
6065 }
6066
6067 template<typename DATATYPE>
6068 void AMPI_Bcast_wrap_d(HandleBase* handle, AdjointInterface* adjointInterface) {
6070 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
6071 (void)adType;
6072
6073 h->bufferRecvAdjoints = nullptr;
6074 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
6076 h->bufferSendAdjoints = nullptr;
6077 if(h->root == getCommRank(h->comm)) {
6078 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
6080 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6082
6083 }
6084
6086 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm);
6087
6088 if(h->root == getCommRank(h->comm)) {
6089 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
6090 }
6091 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6093 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
6094 }
6095
6096 template<typename DATATYPE>
6097 void AMPI_Bcast_wrap_b(HandleBase* handle, AdjointInterface* adjointInterface) {
6099 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
6100 (void)adType;
6101
6102 h->bufferRecvAdjoints = nullptr;
6103 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
6105 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6107
6108 if(adType->isOldPrimalsRequired()) {
6110 }
6111 h->bufferSendAdjoints = nullptr;
6112 if(h->root == getCommRank(h->comm)) {
6113 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
6115 }
6116
6118 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm);
6119
6120 if(h->root == getCommRank(h->comm)) {
6122 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6124 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
6125 }
6126 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
6127 }
6128
6129 template<typename DATATYPE>
6130 void AMPI_Bcast_wrap_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
6132 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
6133 (void)adType;
6134
6135 if(h->root == getCommRank(h->comm)) {
6136 adType->iterateIdentifiers(h->bufferSendIndices, h->bufferSendTotalSize, func, userData);
6137 }
6138 }
6139
6140 template<typename DATATYPE>
6141 void AMPI_Bcast_wrap_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
6143 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
6144 (void)adType;
6145
6146 adType->iterateIdentifiers(h->bufferRecvIndices, h->bufferRecvTotalSize, func, userData);
6147 }
6148
6149 template<typename DATATYPE>
6150 int AMPI_Bcast_wrap(typename DATATYPE::Type* bufferSend, typename DATATYPE::Type* bufferRecv, int count,
6151 DATATYPE* datatype, int root, AMPI_Comm comm) {
6152 int rStatus;
6153 ADToolInterface const* adType = selectADTool(datatype->getADTool());
6154
6155 if(!adType->isActiveType()) {
6156 // call the regular function if the type is not active
6157 rStatus = MPI_Bcast_wrap(bufferSend, bufferRecv, count, datatype->getMpiType(), root, comm);
6158 } else {
6159
6160 // the type is an AD type so handle the buffers
6162 typename DATATYPE::ModifiedType* bufferSendMod = nullptr;
6163 int bufferSendElements = 0;
6164
6165 if(root == getCommRank(comm)) {
6166 // compute the total size of the buffer
6167 if(AMPI_IN_PLACE != bufferSend) {
6168 bufferSendElements = count;
6169 } else {
6170 bufferSendElements = count;
6171 }
6172
6173 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
6174 datatype->createModifiedTypeBuffer(bufferSendMod, bufferSendElements);
6175 } else {
6176 bufferSendMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferSend));
6177 }
6178 }
6179 typename DATATYPE::ModifiedType* bufferRecvMod = nullptr;
6180 int bufferRecvElements = 0;
6181
6182 // compute the total size of the buffer
6183 bufferRecvElements = count;
6184
6185 if(datatype->isModifiedBufferRequired() ) {
6186 datatype->createModifiedTypeBuffer(bufferRecvMod, bufferRecvElements);
6187 } else {
6188 bufferRecvMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferRecv));
6189 }
6190
6191 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
6192 if(adType->isHandleRequired()) {
6194 }
6195 adType->startAssembly(h);
6196 if(root == getCommRank(comm)) {
6197 if(datatype->isModifiedBufferRequired()) {
6198 if(AMPI_IN_PLACE != bufferSend) {
6199 datatype->copyIntoModifiedBuffer(bufferSend, 0, bufferSendMod, 0, count);
6200 } else {
6201 datatype->copyIntoModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
6202 }
6203 }
6204 }
6205
6206 if(nullptr != h) {
6207 // gather the information for the reverse sweep
6208
6209 // create the index buffers
6210 if(root == getCommRank(comm)) {
6211 if(AMPI_IN_PLACE != bufferSend) {
6212 h->bufferSendCount = datatype->computeActiveElements(count);
6213 } else {
6214 h->bufferSendCount = datatype->computeActiveElements(count);
6215 }
6216 h->bufferSendTotalSize = datatype->computeActiveElements(bufferSendElements);
6217 datatype->getADTool().createIndexTypeBuffer(h->bufferSendIndices, h->bufferSendTotalSize);
6218 }
6219 h->bufferRecvCount = datatype->computeActiveElements(count);
6220 h->bufferRecvTotalSize = datatype->computeActiveElements(bufferRecvElements);
6221 datatype->getADTool().createIndexTypeBuffer(h->bufferRecvIndices, h->bufferRecvTotalSize);
6222
6223
6224 // extract the old primal values from the recv buffer if the AD tool
6225 // needs the primal values reset
6226 if(adType->isOldPrimalsRequired()) {
6227 datatype->getADTool().createPrimalTypeBuffer(h->bufferRecvOldPrimals, h->bufferRecvTotalSize);
6228 datatype->getValues(bufferRecv, 0, h->bufferRecvOldPrimals, 0, count);
6229 }
6230
6231
6232 if(root == getCommRank(comm)) {
6233 if(AMPI_IN_PLACE != bufferSend) {
6234 datatype->getIndices(bufferSend, 0, h->bufferSendIndices, 0, count);
6235 } else {
6236 datatype->getIndices(bufferRecv, 0, h->bufferSendIndices, 0, count);
6237 }
6238 }
6239
6240 datatype->createIndices(bufferRecv, 0, h->bufferRecvIndices, 0, count);
6241
6242 // pack all the variables in the handle
6248 h->count = count;
6249 h->datatype = datatype;
6250 h->root = root;
6251 h->comm = comm;
6252 }
6253
6254 if(!datatype->isModifiedBufferRequired()) {
6255 datatype->clearIndices(bufferRecv, 0, count);
6256 }
6257
6258 rStatus = MPI_Bcast_wrap(bufferSendMod, bufferRecvMod, count, datatype->getModifiedMpiType(), root, comm);
6259 adType->addToolAction(h);
6260
6261 if(datatype->isModifiedBufferRequired()) {
6262 datatype->copyFromModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
6263 }
6264
6265 if(nullptr != h) {
6266 // handle the recv buffers
6267 datatype->registerValue(bufferRecv, 0, h->bufferRecvIndices, h->bufferRecvOldPrimals, 0, count);
6268 }
6269
6270 adType->stopAssembly(h);
6271
6272 if(root == getCommRank(comm)) {
6273 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
6274 datatype->deleteModifiedTypeBuffer(bufferSendMod);
6275 }
6276 }
6277 if(datatype->isModifiedBufferRequired() ) {
6278 datatype->deleteModifiedTypeBuffer(bufferRecvMod);
6279 }
6280
6281 // handle is deleted by the AD tool
6282 }
6283
6284 return rStatus;
6285 }
6286
6287#endif
6288#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
6289 template<typename SENDTYPE, typename RECVTYPE>
6292 typename SENDTYPE::IndexType* sendbufIndices;
6293 typename SENDTYPE::PrimalType* sendbufPrimals;
6294 /* required for async */ void* sendbufAdjoints;
6298 SENDTYPE* sendtype;
6300 typename RECVTYPE::IndexType* recvbufIndices;
6301 typename RECVTYPE::PrimalType* recvbufPrimals;
6302 typename RECVTYPE::PrimalType* recvbufOldPrimals;
6303 /* required for async */ void* recvbufAdjoints;
6307 RECVTYPE* recvtype;
6308 int root;
6310
6312 if(nullptr != sendbufIndices) {
6313 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
6314 sendbufIndices = nullptr;
6315 }
6316 if(nullptr != sendbufPrimals) {
6317 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
6318 sendbufPrimals = nullptr;
6319 }
6320 if(nullptr != recvbufIndices) {
6321 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
6322 recvbufIndices = nullptr;
6323 }
6324 if(nullptr != recvbufPrimals) {
6325 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
6326 recvbufPrimals = nullptr;
6327 }
6328 if(nullptr != recvbufOldPrimals) {
6329 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
6330 recvbufOldPrimals = nullptr;
6331 }
6332 }
6333 };
6334
6335
6336 template<typename SENDTYPE, typename RECVTYPE>
6337 void AMPI_Gather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
6339 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6340 (void)adType;
6341
6342 h->recvbufAdjoints = nullptr;
6343 if(h->root == getCommRank(h->comm)) {
6344 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
6345 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
6346 }
6347 h->sendbufAdjoints = nullptr;
6348 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6349 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
6350 // Primal buffers are always linear in space so we can accesses them in one sweep
6351 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
6352
6353
6355 h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
6356
6357 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
6358 if(adType->isOldPrimalsRequired()) {
6359 if(h->root == getCommRank(h->comm)) {
6360 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6361 }
6362 }
6363 if(h->root == getCommRank(h->comm)) {
6364 // Primal buffers are always linear in space so we can accesses them in one sweep
6365 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
6366 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
6367 }
6368 }
6369
6370 template<typename SENDTYPE, typename RECVTYPE>
6371 void AMPI_Gather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
6373 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6374 (void)adType;
6375
6376 h->recvbufAdjoints = nullptr;
6377 if(h->root == getCommRank(h->comm)) {
6378 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
6379 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6380 }
6381 h->sendbufAdjoints = nullptr;
6382 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6383 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6384 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6385 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6386
6387
6390
6391 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6392 if(h->root == getCommRank(h->comm)) {
6393 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6394 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6395 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6396 }
6397 }
6398
6399 template<typename SENDTYPE, typename RECVTYPE>
6400 void AMPI_Gather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
6402 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6403 (void)adType;
6404
6405 h->recvbufAdjoints = nullptr;
6406 if(h->root == getCommRank(h->comm)) {
6407 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
6408 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6409 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6410 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6411
6412 }
6413 if(adType->isOldPrimalsRequired()) {
6414 if(h->root == getCommRank(h->comm)) {
6415 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6416 }
6417 }
6418 h->sendbufAdjoints = nullptr;
6419 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6420 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6421
6424
6425 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6426 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6427 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6428 if(h->root == getCommRank(h->comm)) {
6429 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6430 }
6431 }
6432
6433 template<typename SENDTYPE, typename RECVTYPE>
6434 void AMPI_Gather_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
6436 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6437 (void)adType;
6438
6439 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
6440 }
6441
6442 template<typename SENDTYPE, typename RECVTYPE>
6443 void AMPI_Gather_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
6445 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6446 (void)adType;
6447
6448 if(h->root == getCommRank(h->comm)) {
6449 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
6450 }
6451 }
6452
6453 template<typename SENDTYPE, typename RECVTYPE>
6454 int AMPI_Gather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
6455 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm) {
6456 int rStatus;
6457 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
6458
6459 if(!adType->isActiveType()) {
6460 // call the regular function if the type is not active
6461 rStatus = MPI_Gather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
6462 comm);
6463 } else {
6464
6465 // the type is an AD type so handle the buffers
6467 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
6468 int sendbufElements = 0;
6469
6470 // compute the total size of the buffer
6471 if(AMPI_IN_PLACE != sendbuf) {
6472 sendbufElements = sendcount;
6473 } else {
6474 sendbufElements = recvcount;
6475 }
6476
6477 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6478 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
6479 } else {
6480 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
6481 }
6482 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
6483 int recvbufElements = 0;
6484
6485 if(root == getCommRank(comm)) {
6486 // compute the total size of the buffer
6487 recvbufElements = recvcount * getCommSize(comm);
6488
6489 if(recvtype->isModifiedBufferRequired() ) {
6490 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
6491 } else {
6492 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
6493 }
6494 }
6495
6496 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
6497 if(adType->isHandleRequired()) {
6499 }
6500 adType->startAssembly(h);
6501 if(sendtype->isModifiedBufferRequired()) {
6502 if(AMPI_IN_PLACE != sendbuf) {
6503 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
6504 } else {
6505 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
6506 recvcount);
6507 }
6508 }
6509
6510 if(nullptr != h) {
6511 // gather the information for the reverse sweep
6512
6513 // create the index buffers
6514 if(AMPI_IN_PLACE != sendbuf) {
6515 h->sendbufCount = sendtype->computeActiveElements(sendcount);
6516 } else {
6517 h->sendbufCount = recvtype->computeActiveElements(recvcount);
6518 }
6519 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
6520 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
6521 if(root == getCommRank(comm)) {
6522 h->recvbufCount = recvtype->computeActiveElements(recvcount);
6523 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
6524 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
6525 }
6526
6527
6528 // extract the old primal values from the recv buffer if the AD tool
6529 // needs the primal values reset
6530 if(adType->isOldPrimalsRequired()) {
6531 if(root == getCommRank(comm)) {
6532 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
6533 if(root == getCommRank(comm)) {
6534 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
6535 }
6536 }
6537 }
6538
6539
6540 if(AMPI_IN_PLACE != sendbuf) {
6541 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
6542 } else {
6543 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
6544 }
6545
6546 if(root == getCommRank(comm)) {
6547 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
6548 }
6549
6550 // pack all the variables in the handle
6556 h->sendcount = sendcount;
6557 h->sendtype = sendtype;
6558 h->recvcount = recvcount;
6559 h->recvtype = recvtype;
6560 h->root = root;
6561 h->comm = comm;
6562 }
6563
6564 if(root == getCommRank(comm)) {
6565 if(!recvtype->isModifiedBufferRequired()) {
6566 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
6567 }
6568 }
6569
6570 rStatus = MPI_Gather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
6571 recvtype->getModifiedMpiType(), root, comm);
6572 adType->addToolAction(h);
6573
6574 if(root == getCommRank(comm)) {
6575 if(recvtype->isModifiedBufferRequired()) {
6576 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
6577 }
6578 }
6579
6580 if(nullptr != h) {
6581 // handle the recv buffers
6582 if(root == getCommRank(comm)) {
6583 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
6584 }
6585 }
6586
6587 adType->stopAssembly(h);
6588
6589 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6590 sendtype->deleteModifiedTypeBuffer(sendbufMod);
6591 }
6592 if(root == getCommRank(comm)) {
6593 if(recvtype->isModifiedBufferRequired() ) {
6594 recvtype->deleteModifiedTypeBuffer(recvbufMod);
6595 }
6596 }
6597
6598 // handle is deleted by the AD tool
6599 }
6600
6601 return rStatus;
6602 }
6603
6604#endif
6605#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
6606 template<typename SENDTYPE, typename RECVTYPE>
6609 typename SENDTYPE::IndexType* sendbufIndices;
6610 typename SENDTYPE::PrimalType* sendbufPrimals;
6611 /* required for async */ void* sendbufAdjoints;
6615 SENDTYPE* sendtype;
6617 typename RECVTYPE::IndexType* recvbufIndices;
6618 typename RECVTYPE::PrimalType* recvbufPrimals;
6619 typename RECVTYPE::PrimalType* recvbufOldPrimals;
6620 /* required for async */ void* recvbufAdjoints;
6622 /* required for async */ int* recvbufCountVec;
6623 /* required for async */ int* recvbufDisplsVec;
6624 const int* recvcounts;
6625 const int* displs;
6626 RECVTYPE* recvtype;
6627 int root;
6629
6631 if(nullptr != sendbufIndices) {
6632 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
6633 sendbufIndices = nullptr;
6634 }
6635 if(nullptr != sendbufPrimals) {
6636 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
6637 sendbufPrimals = nullptr;
6638 }
6639 if(nullptr != recvbufIndices) {
6640 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
6641 recvbufIndices = nullptr;
6642 }
6643 if(nullptr != recvbufPrimals) {
6644 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
6645 recvbufPrimals = nullptr;
6646 }
6647 if(nullptr != recvbufOldPrimals) {
6648 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
6649 recvbufOldPrimals = nullptr;
6650 }
6651 if(nullptr != recvbufCount) {
6652 delete [] recvbufCount;
6653 recvbufCount = nullptr;
6654 }
6655 }
6656 };
6657
6658
6659 template<typename SENDTYPE, typename RECVTYPE>
6660 void AMPI_Gatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
6662 (handle);
6663 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6664 (void)adType;
6665
6666 h->recvbufAdjoints = nullptr;
6667 if(h->root == getCommRank(h->comm)) {
6669 adjointInterface->getVectorSize());
6670 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
6671 }
6672 h->sendbufAdjoints = nullptr;
6673 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6674 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
6675 // Primal buffers are always linear in space so we can accesses them in one sweep
6676 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
6677
6678
6681
6682 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
6683 if(adType->isOldPrimalsRequired()) {
6684 if(h->root == getCommRank(h->comm)) {
6685 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6686 }
6687 }
6688 if(h->root == getCommRank(h->comm)) {
6689 // Primal buffers are always linear in space so we can accesses them in one sweep
6690 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
6691 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
6692 delete [] h->recvbufCountVec;
6693 delete [] h->recvbufDisplsVec;
6694 }
6695 }
6696
6697 template<typename SENDTYPE, typename RECVTYPE>
6698 void AMPI_Gatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
6700 (handle);
6701 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6702 (void)adType;
6703
6704 h->recvbufAdjoints = nullptr;
6705 if(h->root == getCommRank(h->comm)) {
6707 adjointInterface->getVectorSize());
6708 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6709 }
6710 h->sendbufAdjoints = nullptr;
6711 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6712 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6713 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6714 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6715
6716
6719
6720 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6721 if(h->root == getCommRank(h->comm)) {
6722 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6723 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6724 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6725 delete [] h->recvbufCountVec;
6726 delete [] h->recvbufDisplsVec;
6727 }
6728 }
6729
6730 template<typename SENDTYPE, typename RECVTYPE>
6731 void AMPI_Gatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
6733 (handle);
6734 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6735 (void)adType;
6736
6737 h->recvbufAdjoints = nullptr;
6738 if(h->root == getCommRank(h->comm)) {
6740 adjointInterface->getVectorSize());
6741 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
6742 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6743 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
6744
6745 }
6746 if(adType->isOldPrimalsRequired()) {
6747 if(h->root == getCommRank(h->comm)) {
6748 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
6749 }
6750 }
6751 h->sendbufAdjoints = nullptr;
6752 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
6753 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
6754
6757
6758 // Adjoint buffers are always linear in space so we can accesses them in one sweep
6759 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
6760 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
6761 if(h->root == getCommRank(h->comm)) {
6762 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
6763 delete [] h->recvbufCountVec;
6764 delete [] h->recvbufDisplsVec;
6765 }
6766 }
6767
6768 template<typename SENDTYPE, typename RECVTYPE>
6769 void AMPI_Gatherv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
6771 (handle);
6772 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6773 (void)adType;
6774
6775 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
6776 }
6777
6778 template<typename SENDTYPE, typename RECVTYPE>
6779 void AMPI_Gatherv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
6781 (handle);
6782 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
6783 (void)adType;
6784
6785 if(h->root == getCommRank(h->comm)) {
6786 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
6787 }
6788 }
6789
6790 template<typename SENDTYPE, typename RECVTYPE>
6791 int AMPI_Gatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
6792 typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* displs, RECVTYPE* recvtype, int root,
6793 AMPI_Comm comm) {
6794 int rStatus;
6795 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
6796
6797 if(!adType->isActiveType()) {
6798 // call the regular function if the type is not active
6799 rStatus = MPI_Gatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs, recvtype->getMpiType(),
6800 root, comm);
6801 } else {
6802
6803 // the type is an AD type so handle the buffers
6805 MEDI_OPTIONAL_CONST int* displsMod = displs;
6806 int displsTotalSize = 0;
6807 if(nullptr != displs) {
6808 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
6809 if(recvtype->isModifiedBufferRequired()) {
6810 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
6811 }
6812 }
6813 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
6814 int sendbufElements = 0;
6815
6816 // compute the total size of the buffer
6817 if(AMPI_IN_PLACE != sendbuf) {
6818 sendbufElements = sendcount;
6819 } else {
6820 sendbufElements = recvcounts[getCommRank(comm)];
6821 }
6822
6823 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6824 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
6825 } else {
6826 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
6827 }
6828 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
6829 int recvbufElements = 0;
6830
6831 if(root == getCommRank(comm)) {
6832 // compute the total size of the buffer
6833 recvbufElements = displsTotalSize;
6834
6835 if(recvtype->isModifiedBufferRequired() ) {
6836 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
6837 } else {
6838 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
6839 }
6840 }
6841
6842 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
6843 if(adType->isHandleRequired()) {
6845 }
6846 adType->startAssembly(h);
6847 if(sendtype->isModifiedBufferRequired()) {
6848 if(AMPI_IN_PLACE != sendbuf) {
6849 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
6850 } else {
6851 {
6852 const int rank = getCommRank(comm);
6853 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
6854 }
6855 }
6856 }
6857
6858 if(nullptr != h) {
6859 // gather the information for the reverse sweep
6860
6861 // create the index buffers
6862 if(AMPI_IN_PLACE != sendbuf) {
6863 h->sendbufCount = sendtype->computeActiveElements(sendcount);
6864 } else {
6865 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
6866 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
6867 }
6868 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
6869 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
6870 if(root == getCommRank(comm)) {
6871 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
6872 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
6873 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
6874 }
6875
6876
6877 // extract the old primal values from the recv buffer if the AD tool
6878 // needs the primal values reset
6879 if(adType->isOldPrimalsRequired()) {
6880 if(root == getCommRank(comm)) {
6881 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
6882 if(root == getCommRank(comm)) {
6883 for(int i = 0; i < getCommSize(comm); ++i) {
6884 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
6885 }
6886 }
6887 }
6888 }
6889
6890
6891 if(AMPI_IN_PLACE != sendbuf) {
6892 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
6893 } else {
6894 {
6895 const int rank = getCommRank(comm);
6896 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
6897 }
6898 }
6899
6900 if(root == getCommRank(comm)) {
6901 for(int i = 0; i < getCommSize(comm); ++i) {
6902 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
6903 }
6904 }
6905
6906 // pack all the variables in the handle
6912 h->sendcount = sendcount;
6913 h->sendtype = sendtype;
6914 h->recvcounts = recvcounts;
6915 h->displs = displs;
6916 h->recvtype = recvtype;
6917 h->root = root;
6918 h->comm = comm;
6919 }
6920
6921 if(root == getCommRank(comm)) {
6922 if(!recvtype->isModifiedBufferRequired()) {
6923 for(int i = 0; i < getCommSize(comm); ++i) {
6924 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
6925 }
6926 }
6927 }
6928
6929 rStatus = MPI_Gatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
6930 recvtype->getModifiedMpiType(), root, comm);
6931 adType->addToolAction(h);
6932
6933 if(root == getCommRank(comm)) {
6934 if(recvtype->isModifiedBufferRequired()) {
6935 for(int i = 0; i < getCommSize(comm); ++i) {
6936 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
6937 }
6938 }
6939 }
6940
6941 if(nullptr != h) {
6942 // handle the recv buffers
6943 if(root == getCommRank(comm)) {
6944 for(int i = 0; i < getCommSize(comm); ++i) {
6945 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
6946 }
6947 }
6948 }
6949
6950 adType->stopAssembly(h);
6951 if(recvtype->isModifiedBufferRequired()) {
6952 delete [] displsMod;
6953 }
6954
6955 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
6956 sendtype->deleteModifiedTypeBuffer(sendbufMod);
6957 }
6958 if(root == getCommRank(comm)) {
6959 if(recvtype->isModifiedBufferRequired() ) {
6960 recvtype->deleteModifiedTypeBuffer(recvbufMod);
6961 }
6962 }
6963
6964 // handle is deleted by the AD tool
6965 }
6966
6967 return rStatus;
6968 }
6969
6970#endif
6971#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
6972 template<typename SENDTYPE, typename RECVTYPE>
6975 typename SENDTYPE::IndexType* sendbufIndices;
6976 typename SENDTYPE::PrimalType* sendbufPrimals;
6977 /* required for async */ void* sendbufAdjoints;
6981 SENDTYPE* sendtype;
6983 typename RECVTYPE::IndexType* recvbufIndices;
6984 typename RECVTYPE::PrimalType* recvbufPrimals;
6985 typename RECVTYPE::PrimalType* recvbufOldPrimals;
6986 /* required for async */ void* recvbufAdjoints;
6990 RECVTYPE* recvtype;
6992
6994 if(nullptr != sendbufIndices) {
6995 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
6996 sendbufIndices = nullptr;
6997 }
6998 if(nullptr != sendbufPrimals) {
6999 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
7000 sendbufPrimals = nullptr;
7001 }
7002 if(nullptr != recvbufIndices) {
7003 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
7004 recvbufIndices = nullptr;
7005 }
7006 if(nullptr != recvbufPrimals) {
7007 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
7008 recvbufPrimals = nullptr;
7009 }
7010 if(nullptr != recvbufOldPrimals) {
7011 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
7012 recvbufOldPrimals = nullptr;
7013 }
7014 }
7015 };
7016
7017 template<typename SENDTYPE, typename RECVTYPE>
7019 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
7020 typename SENDTYPE::ModifiedType* sendbufMod;
7022 SENDTYPE* sendtype;
7023 typename RECVTYPE::Type* recvbuf;
7024 typename RECVTYPE::ModifiedType* recvbufMod;
7026 RECVTYPE* recvtype;
7029 };
7030
7031 template<typename SENDTYPE, typename RECVTYPE>
7032 void AMPI_Iallgather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
7034 (handle);
7035 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7036 (void)adType;
7037
7038 h->recvbufAdjoints = nullptr;
7039 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7040 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
7041 h->sendbufAdjoints = nullptr;
7042 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7043 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
7044 // Primal buffers are always linear in space so we can accesses them in one sweep
7045 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
7046
7047
7050
7051 }
7052
7053 template<typename SENDTYPE, typename RECVTYPE>
7054 void AMPI_Iallgather_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7055
7057 (handle);
7058 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7059 (void)adType;
7060 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7061
7062 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
7063 if(adType->isOldPrimalsRequired()) {
7064 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7065 }
7066 // Primal buffers are always linear in space so we can accesses them in one sweep
7067 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
7068 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
7069 }
7070
7071 template<typename SENDTYPE, typename RECVTYPE>
7072 void AMPI_Iallgather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
7074 (handle);
7075 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7076 (void)adType;
7077
7078 h->recvbufAdjoints = nullptr;
7079 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7080 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7081 h->sendbufAdjoints = nullptr;
7082 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7083 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
7084 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7085 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7086
7087
7090
7091 }
7092
7093 template<typename SENDTYPE, typename RECVTYPE>
7094 void AMPI_Iallgather_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7095
7097 (handle);
7098 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7099 (void)adType;
7100 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7101
7102 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7103 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7104 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7105 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7106 }
7107
7108 template<typename SENDTYPE, typename RECVTYPE>
7109 void AMPI_Iallgather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
7111 (handle);
7112 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7113 (void)adType;
7114
7115 h->recvbufAdjoints = nullptr;
7116 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7117 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7118 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7119 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7120
7121 if(adType->isOldPrimalsRequired()) {
7122 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7123 }
7124 h->sendbufAdjoints = nullptr;
7125 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7127
7130
7131 }
7132
7133 template<typename SENDTYPE, typename RECVTYPE>
7134 void AMPI_Iallgather_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7135
7137 (handle);
7138 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7139 (void)adType;
7140 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7141
7142 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
7143 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7144 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7145 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7146 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7147 }
7148
7149 template<typename SENDTYPE, typename RECVTYPE>
7150 void AMPI_Iallgather_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
7152 (handle);
7153 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7154 (void)adType;
7155
7156 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
7157 }
7158
7159 template<typename SENDTYPE, typename RECVTYPE>
7160 void AMPI_Iallgather_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
7162 (handle);
7163 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7164 (void)adType;
7165
7166 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
7167 }
7168
7169 template<typename SENDTYPE, typename RECVTYPE>
7170 int AMPI_Iallgather_finish(HandleBase* handle);
7171 template<typename SENDTYPE, typename RECVTYPE>
7172 int AMPI_Iallgather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
7173 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm, AMPI_Request* request) {
7174 int rStatus;
7175 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7176
7177 if(!adType->isActiveType()) {
7178 // call the regular function if the type is not active
7179 rStatus = MPI_Iallgather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm,
7180 &request->request);
7181 } else {
7182
7183 // the type is an AD type so handle the buffers
7185 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
7186 int sendbufElements = 0;
7187
7188 // compute the total size of the buffer
7189 if(AMPI_IN_PLACE != sendbuf) {
7190 sendbufElements = sendcount;
7191 } else {
7192 sendbufElements = recvcount;
7193 }
7194
7195 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7196 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
7197 } else {
7198 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
7199 }
7200 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
7201 int recvbufElements = 0;
7202
7203 // compute the total size of the buffer
7204 recvbufElements = recvcount * getCommSize(comm);
7205
7206 if(recvtype->isModifiedBufferRequired() ) {
7207 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
7208 } else {
7209 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
7210 }
7211
7212 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
7213 if(adType->isHandleRequired()) {
7215 }
7216 adType->startAssembly(h);
7217 if(sendtype->isModifiedBufferRequired()) {
7218 if(AMPI_IN_PLACE != sendbuf) {
7219 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
7220 } else {
7221 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
7222 recvcount);
7223 }
7224 }
7225
7226 if(nullptr != h) {
7227 // gather the information for the reverse sweep
7228
7229 // create the index buffers
7230 if(AMPI_IN_PLACE != sendbuf) {
7231 h->sendbufCount = sendtype->computeActiveElements(sendcount);
7232 } else {
7233 h->sendbufCount = recvtype->computeActiveElements(recvcount);
7234 }
7235 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
7236 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
7237 h->recvbufCount = recvtype->computeActiveElements(recvcount);
7238 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
7239 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
7240
7241
7242 // extract the old primal values from the recv buffer if the AD tool
7243 // needs the primal values reset
7244 if(adType->isOldPrimalsRequired()) {
7245 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
7246 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
7247 }
7248
7249
7250 if(AMPI_IN_PLACE != sendbuf) {
7251 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
7252 } else {
7253 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
7254 }
7255
7256 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
7257
7258 // pack all the variables in the handle
7264 h->sendcount = sendcount;
7265 h->sendtype = sendtype;
7266 h->recvcount = recvcount;
7267 h->recvtype = recvtype;
7268 h->comm = comm;
7269 }
7270
7271 if(!recvtype->isModifiedBufferRequired()) {
7272 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
7273 }
7274
7275 rStatus = MPI_Iallgather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
7276 recvtype->getModifiedMpiType(), comm, &request->request);
7277
7279 asyncHandle->sendbuf = sendbuf;
7280 asyncHandle->sendbufMod = sendbufMod;
7281 asyncHandle->sendcount = sendcount;
7282 asyncHandle->sendtype = sendtype;
7283 asyncHandle->recvbuf = recvbuf;
7284 asyncHandle->recvbufMod = recvbufMod;
7285 asyncHandle->recvcount = recvcount;
7286 asyncHandle->recvtype = recvtype;
7287 asyncHandle->comm = comm;
7288 asyncHandle->toolHandle = h;
7289 request->handle = asyncHandle;
7291
7292 // create adjoint wait
7293 if(nullptr != h) {
7296 adType->addToolAction(waitH);
7297 }
7298 }
7299
7300 return rStatus;
7301 }
7302
7303 template<typename SENDTYPE, typename RECVTYPE>
7305 int rStatus = 0;
7306
7309 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
7310 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
7311 int sendcount = asyncHandle->sendcount;
7312 SENDTYPE* sendtype = asyncHandle->sendtype;
7313 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
7314 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
7315 int recvcount = asyncHandle->recvcount;
7316 RECVTYPE* recvtype = asyncHandle->recvtype;
7317 AMPI_Comm comm = asyncHandle->comm;
7318 AMPI_Request* request = asyncHandle->request;
7320 (asyncHandle->toolHandle);
7321 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7322 MEDI_UNUSED(h); // Unused generated to ignore warnings
7323 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
7324 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
7325 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
7326 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
7327 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
7328 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
7329 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
7330 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
7331 MEDI_UNUSED(comm); // Unused generated to ignore warnings
7332 MEDI_UNUSED(request); // Unused generated to ignore warnings
7333
7334 delete asyncHandle;
7335
7336 if(adType->isActiveType()) {
7337
7338 adType->addToolAction(h);
7339
7340 if(recvtype->isModifiedBufferRequired()) {
7341 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
7342 }
7343
7344 if(nullptr != h) {
7345 // handle the recv buffers
7346 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
7347 }
7348
7349 adType->stopAssembly(h);
7350
7351 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7352 sendtype->deleteModifiedTypeBuffer(sendbufMod);
7353 }
7354 if(recvtype->isModifiedBufferRequired() ) {
7355 recvtype->deleteModifiedTypeBuffer(recvbufMod);
7356 }
7357
7358 // handle is deleted by the AD tool
7359 }
7360
7361 return rStatus;
7362 }
7363
7364#endif
7365#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
7366 template<typename SENDTYPE, typename RECVTYPE>
7369 typename SENDTYPE::IndexType* sendbufIndices;
7370 typename SENDTYPE::PrimalType* sendbufPrimals;
7371 /* required for async */ void* sendbufAdjoints;
7375 SENDTYPE* sendtype;
7377 typename RECVTYPE::IndexType* recvbufIndices;
7378 typename RECVTYPE::PrimalType* recvbufPrimals;
7379 typename RECVTYPE::PrimalType* recvbufOldPrimals;
7380 /* required for async */ void* recvbufAdjoints;
7382 /* required for async */ int* recvbufCountVec;
7383 /* required for async */ int* recvbufDisplsVec;
7384 const int* recvcounts;
7385 const int* displs;
7386 RECVTYPE* recvtype;
7388
7390 if(nullptr != sendbufIndices) {
7391 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
7392 sendbufIndices = nullptr;
7393 }
7394 if(nullptr != sendbufPrimals) {
7395 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
7396 sendbufPrimals = nullptr;
7397 }
7398 if(nullptr != recvbufIndices) {
7399 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
7400 recvbufIndices = nullptr;
7401 }
7402 if(nullptr != recvbufPrimals) {
7403 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
7404 recvbufPrimals = nullptr;
7405 }
7406 if(nullptr != recvbufOldPrimals) {
7407 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
7408 recvbufOldPrimals = nullptr;
7409 }
7410 if(nullptr != recvbufCount) {
7411 delete [] recvbufCount;
7412 recvbufCount = nullptr;
7413 }
7414 }
7415 };
7416
7417 template<typename SENDTYPE, typename RECVTYPE>
7419 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
7420 typename SENDTYPE::ModifiedType* sendbufMod;
7422 SENDTYPE* sendtype;
7423 typename RECVTYPE::Type* recvbuf;
7424 typename RECVTYPE::ModifiedType* recvbufMod;
7425 const int* displsMod;
7426 const int* recvcounts;
7427 const int* displs;
7428 RECVTYPE* recvtype;
7431 };
7432
7433 template<typename SENDTYPE, typename RECVTYPE>
7434 void AMPI_Iallgatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
7437 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7438 (void)adType;
7439
7440 h->recvbufAdjoints = nullptr;
7442 adjointInterface->getVectorSize());
7443 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
7444 h->sendbufAdjoints = nullptr;
7445 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7446 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
7447 // Primal buffers are always linear in space so we can accesses them in one sweep
7448 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
7449
7450
7453 &h->requestReverse);
7454
7455 }
7456
7457 template<typename SENDTYPE, typename RECVTYPE>
7458 void AMPI_Iallgatherv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7459
7462 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7463 (void)adType;
7464 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7465
7466 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
7467 if(adType->isOldPrimalsRequired()) {
7468 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7469 }
7470 // Primal buffers are always linear in space so we can accesses them in one sweep
7471 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
7472 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
7473 delete [] h->recvbufCountVec;
7474 delete [] h->recvbufDisplsVec;
7475 }
7476
7477 template<typename SENDTYPE, typename RECVTYPE>
7478 void AMPI_Iallgatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
7481 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7482 (void)adType;
7483
7484 h->recvbufAdjoints = nullptr;
7486 adjointInterface->getVectorSize());
7487 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7488 h->sendbufAdjoints = nullptr;
7489 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7490 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
7491 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7492 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7493
7494
7497 &h->requestReverse);
7498
7499 }
7500
7501 template<typename SENDTYPE, typename RECVTYPE>
7502 void AMPI_Iallgatherv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7503
7506 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7507 (void)adType;
7508 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7509
7510 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7511 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7512 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7513 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7514 delete [] h->recvbufCountVec;
7515 delete [] h->recvbufDisplsVec;
7516 }
7517
7518 template<typename SENDTYPE, typename RECVTYPE>
7519 void AMPI_Iallgatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
7522 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7523 (void)adType;
7524
7525 h->recvbufAdjoints = nullptr;
7527 adjointInterface->getVectorSize());
7528 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7529 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7530 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7531
7532 if(adType->isOldPrimalsRequired()) {
7533 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7534 }
7535 h->sendbufAdjoints = nullptr;
7536 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7538
7541 &h->requestReverse);
7542
7543 }
7544
7545 template<typename SENDTYPE, typename RECVTYPE>
7546 void AMPI_Iallgatherv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
7547
7550 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7551 (void)adType;
7552 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7553
7554 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
7555 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7556 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7557 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7558 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7559 delete [] h->recvbufCountVec;
7560 delete [] h->recvbufDisplsVec;
7561 }
7562
7563 template<typename SENDTYPE, typename RECVTYPE>
7564 void AMPI_Iallgatherv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
7567 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7568 (void)adType;
7569
7570 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
7571 }
7572
7573 template<typename SENDTYPE, typename RECVTYPE>
7574 void AMPI_Iallgatherv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
7577 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
7578 (void)adType;
7579
7580 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
7581 }
7582
7583 template<typename SENDTYPE, typename RECVTYPE>
7584 int AMPI_Iallgatherv_finish(HandleBase* handle);
7585 template<typename SENDTYPE, typename RECVTYPE>
7586 int AMPI_Iallgatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
7587 typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* displs, RECVTYPE* recvtype, AMPI_Comm comm,
7588 AMPI_Request* request) {
7589 int rStatus;
7590 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7591
7592 if(!adType->isActiveType()) {
7593 // call the regular function if the type is not active
7594 rStatus = MPI_Iallgatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs,
7595 recvtype->getMpiType(), comm, &request->request);
7596 } else {
7597
7598 // the type is an AD type so handle the buffers
7600 MEDI_OPTIONAL_CONST int* displsMod = displs;
7601 int displsTotalSize = 0;
7602 if(nullptr != displs) {
7603 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
7604 if(recvtype->isModifiedBufferRequired()) {
7605 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
7606 }
7607 }
7608 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
7609 int sendbufElements = 0;
7610
7611 // compute the total size of the buffer
7612 if(AMPI_IN_PLACE != sendbuf) {
7613 sendbufElements = sendcount;
7614 } else {
7615 sendbufElements = recvcounts[getCommRank(comm)];
7616 }
7617
7618 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7619 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
7620 } else {
7621 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
7622 }
7623 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
7624 int recvbufElements = 0;
7625
7626 // compute the total size of the buffer
7627 recvbufElements = displsTotalSize;
7628
7629 if(recvtype->isModifiedBufferRequired() ) {
7630 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
7631 } else {
7632 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
7633 }
7634
7635 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
7636 if(adType->isHandleRequired()) {
7638 }
7639 adType->startAssembly(h);
7640 if(sendtype->isModifiedBufferRequired()) {
7641 if(AMPI_IN_PLACE != sendbuf) {
7642 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
7643 } else {
7644 {
7645 const int rank = getCommRank(comm);
7646 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
7647 }
7648 }
7649 }
7650
7651 if(nullptr != h) {
7652 // gather the information for the reverse sweep
7653
7654 // create the index buffers
7655 if(AMPI_IN_PLACE != sendbuf) {
7656 h->sendbufCount = sendtype->computeActiveElements(sendcount);
7657 } else {
7658 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
7659 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
7660 }
7661 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
7662 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
7663 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
7664 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
7665 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
7666
7667
7668 // extract the old primal values from the recv buffer if the AD tool
7669 // needs the primal values reset
7670 if(adType->isOldPrimalsRequired()) {
7671 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
7672 for(int i = 0; i < getCommSize(comm); ++i) {
7673 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
7674 }
7675 }
7676
7677
7678 if(AMPI_IN_PLACE != sendbuf) {
7679 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
7680 } else {
7681 {
7682 const int rank = getCommRank(comm);
7683 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
7684 }
7685 }
7686
7687 for(int i = 0; i < getCommSize(comm); ++i) {
7688 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
7689 }
7690
7691 // pack all the variables in the handle
7697 h->sendcount = sendcount;
7698 h->sendtype = sendtype;
7699 h->recvcounts = recvcounts;
7700 h->displs = displs;
7701 h->recvtype = recvtype;
7702 h->comm = comm;
7703 }
7704
7705 if(!recvtype->isModifiedBufferRequired()) {
7706 for(int i = 0; i < getCommSize(comm); ++i) {
7707 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
7708 }
7709 }
7710
7711 rStatus = MPI_Iallgatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
7712 recvtype->getModifiedMpiType(), comm, &request->request);
7713
7715 asyncHandle->sendbuf = sendbuf;
7716 asyncHandle->sendbufMod = sendbufMod;
7717 asyncHandle->sendcount = sendcount;
7718 asyncHandle->sendtype = sendtype;
7719 asyncHandle->recvbuf = recvbuf;
7720 asyncHandle->recvbufMod = recvbufMod;
7721 asyncHandle->displsMod = displsMod;
7722 asyncHandle->recvcounts = recvcounts;
7723 asyncHandle->displs = displs;
7724 asyncHandle->recvtype = recvtype;
7725 asyncHandle->comm = comm;
7726 asyncHandle->toolHandle = h;
7727 request->handle = asyncHandle;
7729
7730 // create adjoint wait
7731 if(nullptr != h) {
7734 adType->addToolAction(waitH);
7735 }
7736 }
7737
7738 return rStatus;
7739 }
7740
7741 template<typename SENDTYPE, typename RECVTYPE>
7743 int rStatus = 0;
7744
7747 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
7748 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
7749 int sendcount = asyncHandle->sendcount;
7750 SENDTYPE* sendtype = asyncHandle->sendtype;
7751 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
7752 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
7753 const int* displsMod = asyncHandle->displsMod;
7754 const int* recvcounts = asyncHandle->recvcounts;
7755 const int* displs = asyncHandle->displs;
7756 RECVTYPE* recvtype = asyncHandle->recvtype;
7757 AMPI_Comm comm = asyncHandle->comm;
7758 AMPI_Request* request = asyncHandle->request;
7761 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
7762 MEDI_UNUSED(h); // Unused generated to ignore warnings
7763 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
7764 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
7765 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
7766 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
7767 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
7768 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
7769 MEDI_UNUSED(displsMod); // Unused generated to ignore warnings
7770 MEDI_UNUSED(recvcounts); // Unused generated to ignore warnings
7771 MEDI_UNUSED(displs); // Unused generated to ignore warnings
7772 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
7773 MEDI_UNUSED(comm); // Unused generated to ignore warnings
7774 MEDI_UNUSED(request); // Unused generated to ignore warnings
7775
7776 delete asyncHandle;
7777
7778 if(adType->isActiveType()) {
7779
7780 adType->addToolAction(h);
7781
7782 if(recvtype->isModifiedBufferRequired()) {
7783 for(int i = 0; i < getCommSize(comm); ++i) {
7784 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
7785 }
7786 }
7787
7788 if(nullptr != h) {
7789 // handle the recv buffers
7790 for(int i = 0; i < getCommSize(comm); ++i) {
7791 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
7792 }
7793 }
7794
7795 adType->stopAssembly(h);
7796 if(recvtype->isModifiedBufferRequired()) {
7797 delete [] displsMod;
7798 }
7799
7800 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
7801 sendtype->deleteModifiedTypeBuffer(sendbufMod);
7802 }
7803 if(recvtype->isModifiedBufferRequired() ) {
7804 recvtype->deleteModifiedTypeBuffer(recvbufMod);
7805 }
7806
7807 // handle is deleted by the AD tool
7808 }
7809
7810 return rStatus;
7811 }
7812
7813#endif
7814#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
7815 template<typename DATATYPE>
7818 typename DATATYPE::IndexType* sendbufIndices;
7819 typename DATATYPE::PrimalType* sendbufPrimals;
7820 /* required for async */ void* sendbufAdjoints;
7824 typename DATATYPE::IndexType* recvbufIndices;
7825 typename DATATYPE::PrimalType* recvbufPrimals;
7826 typename DATATYPE::PrimalType* recvbufOldPrimals;
7827 /* required for async */ void* recvbufAdjoints;
7831 DATATYPE* datatype;
7834
7836 if(nullptr != sendbufIndices) {
7837 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
7838 sendbufIndices = nullptr;
7839 }
7840 if(nullptr != sendbufPrimals) {
7841 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
7842 sendbufPrimals = nullptr;
7843 }
7844 if(nullptr != recvbufIndices) {
7845 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
7846 recvbufIndices = nullptr;
7847 }
7848 if(nullptr != recvbufPrimals) {
7849 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
7850 recvbufPrimals = nullptr;
7851 }
7852 if(nullptr != recvbufOldPrimals) {
7853 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
7854 recvbufOldPrimals = nullptr;
7855 }
7856 }
7857 };
7858
7859 template<typename DATATYPE>
7861 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf;
7862 typename DATATYPE::ModifiedType* sendbufMod;
7863 typename DATATYPE::Type* recvbuf;
7864 typename DATATYPE::ModifiedType* recvbufMod;
7866 DATATYPE* datatype;
7870 };
7871
7872 template<typename DATATYPE>
7873 void AMPI_Iallreduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
7875 (handle);
7876 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7877 (void)adType;
7878
7879 AMPI_Op convOp = adType->convertOperator(h->op);
7880 (void)convOp;
7881 h->recvbufAdjoints = nullptr;
7882 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7883 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
7884 h->sendbufAdjoints = nullptr;
7885 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7886 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
7887 // Primal buffers are always linear in space so we can accesses them in one sweep
7888 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
7889
7890
7892 h->count, h->datatype, h->op, h->comm, &h->requestReverse);
7893
7894 }
7895
7896 template<typename DATATYPE>
7898
7900 (handle);
7901 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7902 (void)adType;
7903 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7904
7905 AMPI_Op convOp = adType->convertOperator(h->op);
7906 (void)convOp;
7907 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
7908 if(adType->isOldPrimalsRequired()) {
7909 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7910 }
7911 // Primal buffers are always linear in space so we can accesses them in one sweep
7912 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
7913 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
7914 }
7915
7916 template<typename DATATYPE>
7917 void AMPI_Iallreduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
7919 (handle);
7920 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7921 (void)adType;
7922
7923 AMPI_Op convOp = adType->convertOperator(h->op);
7924 (void)convOp;
7925 h->recvbufAdjoints = nullptr;
7926 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7927 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7928 h->sendbufAdjoints = nullptr;
7929 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7930 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
7931 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7932 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
7933
7934
7936 h->count, h->datatype, h->op, h->comm, &h->requestReverse);
7937
7938 }
7939
7940 template<typename DATATYPE>
7942
7944 (handle);
7945 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7946 (void)adType;
7947 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7948
7949 AMPI_Op convOp = adType->convertOperator(h->op);
7950 (void)convOp;
7951 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
7952 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7953 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7954 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
7955 }
7956
7957 template<typename DATATYPE>
7958 void AMPI_Iallreduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
7960 (handle);
7961 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7962 (void)adType;
7963
7964 AMPI_Op convOp = adType->convertOperator(h->op);
7965 (void)convOp;
7966 h->recvbufAdjoints = nullptr;
7967 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
7968 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
7969 // Adjoint buffers are always linear in space so we can accesses them in one sweep
7970 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
7971
7972 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
7973 if(adType->isOldPrimalsRequired()) {
7974 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
7975 }
7976 h->sendbufAdjoints = nullptr;
7977 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
7979
7981 h->count, h->datatype, h->op, h->comm, &h->requestReverse);
7982
7983 }
7984
7985 template<typename DATATYPE>
7987
7989 (handle);
7990 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
7991 (void)adType;
7992 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
7993
7994 AMPI_Op convOp = adType->convertOperator(h->op);
7995 (void)convOp;
7996 adjointInterface->combineAdjoints(h->sendbufAdjoints, h->sendbufTotalSize, getCommSize(h->comm));
7997 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
7998 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
8000 adjointInterface->getVectorSize());
8001 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8002 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8003 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
8004 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
8005 }
8006
8007 template<typename DATATYPE>
8008 void AMPI_Iallreduce_global_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
8010 (handle);
8011 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8012 (void)adType;
8013
8014 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
8015 }
8016
8017 template<typename DATATYPE>
8018 void AMPI_Iallreduce_global_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
8020 (handle);
8021 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
8022 (void)adType;
8023
8024 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
8025 }
8026
8027 template<typename DATATYPE>
8028 int AMPI_Iallreduce_global_finish(HandleBase* handle);
8029 template<typename DATATYPE>
8030 int AMPI_Iallreduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
8031 int count, DATATYPE* datatype, AMPI_Op op, AMPI_Comm comm, AMPI_Request* request) {
8032 int rStatus;
8033 ADToolInterface const* adType = selectADTool(datatype->getADTool());
8034 AMPI_Op convOp = adType->convertOperator(op);
8035 (void)convOp;
8036
8037 if(!adType->isActiveType()) {
8038 // call the regular function if the type is not active
8039 rStatus = MPI_Iallreduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, comm,
8040 &request->request);
8041 } else {
8042
8043 // the type is an AD type so handle the buffers
8045 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
8046 int sendbufElements = 0;
8047
8048 // compute the total size of the buffer
8049 if(AMPI_IN_PLACE != sendbuf) {
8050 sendbufElements = count;
8051 } else {
8052 sendbufElements = count;
8053 }
8054
8055 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8056 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
8057 } else {
8058 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
8059 }
8060 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
8061 int recvbufElements = 0;
8062
8063 // compute the total size of the buffer
8064 recvbufElements = count;
8065
8066 if(datatype->isModifiedBufferRequired() ) {
8067 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
8068 } else {
8069 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
8070 }
8071
8072 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
8073 if(adType->isHandleRequired()) {
8075 }
8076 adType->startAssembly(h);
8077 if(datatype->isModifiedBufferRequired()) {
8078 if(AMPI_IN_PLACE != sendbuf) {
8079 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
8080 } else {
8081 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
8082 }
8083 }
8084
8085 if(nullptr != h) {
8086 // gather the information for the reverse sweep
8087
8088 // create the index buffers
8089 if(AMPI_IN_PLACE != sendbuf) {
8090 h->sendbufCount = datatype->computeActiveElements(count);
8091 } else {
8092 h->sendbufCount = datatype->computeActiveElements(count);
8093 }
8094 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
8095 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
8096 h->recvbufCount = datatype->computeActiveElements(count);
8097 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
8098 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
8099
8100 // extract the primal values for the operator if required
8101 if(convOp.requiresPrimal) {
8102 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
8103 if(AMPI_IN_PLACE != sendbuf) {
8104 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
8105 } else {
8106 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
8107 }
8108 }
8109
8110 // extract the old primal values from the recv buffer if the AD tool
8111 // needs the primal values reset
8112 if(adType->isOldPrimalsRequired()) {
8113 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
8114 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
8115 }
8116
8117
8118 if(AMPI_IN_PLACE != sendbuf) {
8119 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
8120 } else {
8121 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
8122 }
8123
8124 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
8125
8126 // pack all the variables in the handle
8132 h->count = count;
8133 h->datatype = datatype;
8134 h->op = op;
8135 h->comm = comm;
8136 }
8137
8138 if(!datatype->isModifiedBufferRequired()) {
8139 datatype->clearIndices(recvbuf, 0, count);
8140 }
8141
8142 rStatus = MPI_Iallreduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction,
8143 comm, &request->request);
8144
8146 asyncHandle->sendbuf = sendbuf;
8147 asyncHandle->sendbufMod = sendbufMod;
8148 asyncHandle->recvbuf = recvbuf;
8149 asyncHandle->recvbufMod = recvbufMod;
8150 asyncHandle->count = count;
8151 asyncHandle->datatype = datatype;
8152 asyncHandle->op = op;
8153 asyncHandle->comm = comm;
8154 asyncHandle->toolHandle = h;
8155 request->handle = asyncHandle;
8157
8158 // create adjoint wait
8159 if(nullptr != h) {
8162 adType->addToolAction(waitH);
8163 }
8164 }
8165
8166 return rStatus;
8167 }
8168
8169 template<typename DATATYPE>
8171 int rStatus = 0;
8172
8174 (handle);
8175 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf = asyncHandle->sendbuf;
8176 typename DATATYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
8177 typename DATATYPE::Type* recvbuf = asyncHandle->recvbuf;
8178 typename DATATYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
8179 int count = asyncHandle->count;
8180 DATATYPE* datatype = asyncHandle->datatype;
8181 AMPI_Op op = asyncHandle->op;
8182 AMPI_Comm comm = asyncHandle->comm;
8183 AMPI_Request* request = asyncHandle->request;
8185 (asyncHandle->toolHandle);
8186 ADToolInterface const* adType = selectADTool(datatype->getADTool());
8187 MEDI_UNUSED(h); // Unused generated to ignore warnings
8188 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
8189 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
8190 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
8191 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
8192 MEDI_UNUSED(count); // Unused generated to ignore warnings
8193 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
8194 MEDI_UNUSED(op); // Unused generated to ignore warnings
8195 MEDI_UNUSED(comm); // Unused generated to ignore warnings
8196 MEDI_UNUSED(request); // Unused generated to ignore warnings
8197
8198 delete asyncHandle;
8199
8200 if(adType->isActiveType()) {
8201
8202 AMPI_Op convOp = adType->convertOperator(op);
8203 (void)convOp;
8204 adType->addToolAction(h);
8205
8206 if(datatype->isModifiedBufferRequired()) {
8207 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
8208 }
8209
8210 if(nullptr != h) {
8211 // handle the recv buffers
8212 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
8213 }
8214 // extract the primal values for the operator if required
8215 if(nullptr != h && convOp.requiresPrimal) {
8216 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
8217 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
8218 }
8219
8220 adType->stopAssembly(h);
8221
8222 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8223 datatype->deleteModifiedTypeBuffer(sendbufMod);
8224 }
8225 if(datatype->isModifiedBufferRequired() ) {
8226 datatype->deleteModifiedTypeBuffer(recvbufMod);
8227 }
8228
8229 // handle is deleted by the AD tool
8230 }
8231
8232 return rStatus;
8233 }
8234
8235#endif
8236#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
8237 template<typename SENDTYPE, typename RECVTYPE>
8240 typename SENDTYPE::IndexType* sendbufIndices;
8241 typename SENDTYPE::PrimalType* sendbufPrimals;
8242 /* required for async */ void* sendbufAdjoints;
8246 SENDTYPE* sendtype;
8248 typename RECVTYPE::IndexType* recvbufIndices;
8249 typename RECVTYPE::PrimalType* recvbufPrimals;
8250 typename RECVTYPE::PrimalType* recvbufOldPrimals;
8251 /* required for async */ void* recvbufAdjoints;
8255 RECVTYPE* recvtype;
8257
8259 if(nullptr != sendbufIndices) {
8260 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
8261 sendbufIndices = nullptr;
8262 }
8263 if(nullptr != sendbufPrimals) {
8264 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
8265 sendbufPrimals = nullptr;
8266 }
8267 if(nullptr != recvbufIndices) {
8268 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
8269 recvbufIndices = nullptr;
8270 }
8271 if(nullptr != recvbufPrimals) {
8272 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
8273 recvbufPrimals = nullptr;
8274 }
8275 if(nullptr != recvbufOldPrimals) {
8276 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
8277 recvbufOldPrimals = nullptr;
8278 }
8279 }
8280 };
8281
8282 template<typename SENDTYPE, typename RECVTYPE>
8284 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
8285 typename SENDTYPE::ModifiedType* sendbufMod;
8287 SENDTYPE* sendtype;
8288 typename RECVTYPE::Type* recvbuf;
8289 typename RECVTYPE::ModifiedType* recvbufMod;
8291 RECVTYPE* recvtype;
8294 };
8295
8296 template<typename SENDTYPE, typename RECVTYPE>
8297 void AMPI_Ialltoall_p(HandleBase* handle, AdjointInterface* adjointInterface) {
8299 (handle);
8300 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8301 (void)adType;
8302
8303 h->recvbufAdjoints = nullptr;
8304 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
8305 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
8306 h->sendbufAdjoints = nullptr;
8307 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
8308 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
8309 // Primal buffers are always linear in space so we can accesses them in one sweep
8310 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
8311
8312
8315
8316 }
8317
8318 template<typename SENDTYPE, typename RECVTYPE>
8319 void AMPI_Ialltoall_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8320
8322 (handle);
8323 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8324 (void)adType;
8325 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8326
8327 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
8328 if(adType->isOldPrimalsRequired()) {
8329 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
8330 }
8331 // Primal buffers are always linear in space so we can accesses them in one sweep
8332 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
8333 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
8334 }
8335
8336 template<typename SENDTYPE, typename RECVTYPE>
8337 void AMPI_Ialltoall_d(HandleBase* handle, AdjointInterface* adjointInterface) {
8339 (handle);
8340 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8341 (void)adType;
8342
8343 h->recvbufAdjoints = nullptr;
8344 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
8345 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
8346 h->sendbufAdjoints = nullptr;
8347 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
8348 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
8349 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8350 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8351
8352
8355
8356 }
8357
8358 template<typename SENDTYPE, typename RECVTYPE>
8359 void AMPI_Ialltoall_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8360
8362 (handle);
8363 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8364 (void)adType;
8365 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8366
8367 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
8368 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8369 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
8370 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
8371 }
8372
8373 template<typename SENDTYPE, typename RECVTYPE>
8374 void AMPI_Ialltoall_b(HandleBase* handle, AdjointInterface* adjointInterface) {
8376 (handle);
8377 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8378 (void)adType;
8379
8380 h->recvbufAdjoints = nullptr;
8381 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
8382 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
8383 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8384 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
8385
8386 if(adType->isOldPrimalsRequired()) {
8387 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
8388 }
8389 h->sendbufAdjoints = nullptr;
8390 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
8391 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
8392
8395
8396 }
8397
8398 template<typename SENDTYPE, typename RECVTYPE>
8399 void AMPI_Ialltoall_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8400
8402 (handle);
8403 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8404 (void)adType;
8405 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8406
8407 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8408 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8409 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
8410 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
8411 }
8412
8413 template<typename SENDTYPE, typename RECVTYPE>
8414 void AMPI_Ialltoall_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
8416 (handle);
8417 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8418 (void)adType;
8419
8420 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
8421 }
8422
8423 template<typename SENDTYPE, typename RECVTYPE>
8424 void AMPI_Ialltoall_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
8426 (handle);
8427 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8428 (void)adType;
8429
8430 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
8431 }
8432
8433 template<typename SENDTYPE, typename RECVTYPE>
8434 int AMPI_Ialltoall_finish(HandleBase* handle);
8435 template<typename SENDTYPE, typename RECVTYPE>
8436 int AMPI_Ialltoall(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
8437 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, AMPI_Comm comm, AMPI_Request* request) {
8438 int rStatus;
8439 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
8440
8441 if(!adType->isActiveType()) {
8442 // call the regular function if the type is not active
8443 rStatus = MPI_Ialltoall(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), comm,
8444 &request->request);
8445 } else {
8446
8447 // the type is an AD type so handle the buffers
8449 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
8450 int sendbufElements = 0;
8451
8452 // compute the total size of the buffer
8453 if(AMPI_IN_PLACE != sendbuf) {
8454 sendbufElements = sendcount * getCommSize(comm);
8455 } else {
8456 sendbufElements = recvcount * getCommSize(comm);
8457 }
8458
8459 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8460 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
8461 } else {
8462 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
8463 }
8464 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
8465 int recvbufElements = 0;
8466
8467 // compute the total size of the buffer
8468 recvbufElements = recvcount * getCommSize(comm);
8469
8470 if(recvtype->isModifiedBufferRequired() ) {
8471 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
8472 } else {
8473 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
8474 }
8475
8476 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
8477 if(adType->isHandleRequired()) {
8479 }
8480 adType->startAssembly(h);
8481 if(sendtype->isModifiedBufferRequired()) {
8482 if(AMPI_IN_PLACE != sendbuf) {
8483 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
8484 } else {
8485 recvtype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
8486 }
8487 }
8488
8489 if(nullptr != h) {
8490 // gather the information for the reverse sweep
8491
8492 // create the index buffers
8493 if(AMPI_IN_PLACE != sendbuf) {
8494 h->sendbufCount = sendtype->computeActiveElements(sendcount);
8495 } else {
8496 h->sendbufCount = recvtype->computeActiveElements(recvcount);
8497 }
8498 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
8499 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
8500 h->recvbufCount = recvtype->computeActiveElements(recvcount);
8501 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
8502 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
8503
8504
8505 // extract the old primal values from the recv buffer if the AD tool
8506 // needs the primal values reset
8507 if(adType->isOldPrimalsRequired()) {
8508 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
8509 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
8510 }
8511
8512
8513 if(AMPI_IN_PLACE != sendbuf) {
8514 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
8515 } else {
8516 recvtype->getIndices(recvbuf, 0, h->sendbufIndices, 0, recvcount * getCommSize(comm));
8517 }
8518
8519 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
8520
8521 // pack all the variables in the handle
8527 h->sendcount = sendcount;
8528 h->sendtype = sendtype;
8529 h->recvcount = recvcount;
8530 h->recvtype = recvtype;
8531 h->comm = comm;
8532 }
8533
8534 if(!recvtype->isModifiedBufferRequired()) {
8535 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
8536 }
8537
8538 rStatus = MPI_Ialltoall(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
8539 recvtype->getModifiedMpiType(), comm, &request->request);
8540
8542 asyncHandle->sendbuf = sendbuf;
8543 asyncHandle->sendbufMod = sendbufMod;
8544 asyncHandle->sendcount = sendcount;
8545 asyncHandle->sendtype = sendtype;
8546 asyncHandle->recvbuf = recvbuf;
8547 asyncHandle->recvbufMod = recvbufMod;
8548 asyncHandle->recvcount = recvcount;
8549 asyncHandle->recvtype = recvtype;
8550 asyncHandle->comm = comm;
8551 asyncHandle->toolHandle = h;
8552 request->handle = asyncHandle;
8554
8555 // create adjoint wait
8556 if(nullptr != h) {
8559 adType->addToolAction(waitH);
8560 }
8561 }
8562
8563 return rStatus;
8564 }
8565
8566 template<typename SENDTYPE, typename RECVTYPE>
8568 int rStatus = 0;
8569
8572 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
8573 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
8574 int sendcount = asyncHandle->sendcount;
8575 SENDTYPE* sendtype = asyncHandle->sendtype;
8576 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
8577 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
8578 int recvcount = asyncHandle->recvcount;
8579 RECVTYPE* recvtype = asyncHandle->recvtype;
8580 AMPI_Comm comm = asyncHandle->comm;
8581 AMPI_Request* request = asyncHandle->request;
8583 (asyncHandle->toolHandle);
8584 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
8585 MEDI_UNUSED(h); // Unused generated to ignore warnings
8586 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
8587 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
8588 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
8589 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
8590 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
8591 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
8592 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
8593 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
8594 MEDI_UNUSED(comm); // Unused generated to ignore warnings
8595 MEDI_UNUSED(request); // Unused generated to ignore warnings
8596
8597 delete asyncHandle;
8598
8599 if(adType->isActiveType()) {
8600
8601 adType->addToolAction(h);
8602
8603 if(recvtype->isModifiedBufferRequired()) {
8604 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
8605 }
8606
8607 if(nullptr != h) {
8608 // handle the recv buffers
8609 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
8610 }
8611
8612 adType->stopAssembly(h);
8613
8614 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8615 sendtype->deleteModifiedTypeBuffer(sendbufMod);
8616 }
8617 if(recvtype->isModifiedBufferRequired() ) {
8618 recvtype->deleteModifiedTypeBuffer(recvbufMod);
8619 }
8620
8621 // handle is deleted by the AD tool
8622 }
8623
8624 return rStatus;
8625 }
8626
8627#endif
8628#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
8629 template<typename SENDTYPE, typename RECVTYPE>
8632 typename SENDTYPE::IndexType* sendbufIndices;
8633 typename SENDTYPE::PrimalType* sendbufPrimals;
8634 /* required for async */ void* sendbufAdjoints;
8636 /* required for async */ int* sendbufCountVec;
8637 /* required for async */ int* sendbufDisplsVec;
8638 const int* sendcounts;
8639 const int* sdispls;
8640 SENDTYPE* sendtype;
8642 typename RECVTYPE::IndexType* recvbufIndices;
8643 typename RECVTYPE::PrimalType* recvbufPrimals;
8644 typename RECVTYPE::PrimalType* recvbufOldPrimals;
8645 /* required for async */ void* recvbufAdjoints;
8647 /* required for async */ int* recvbufCountVec;
8648 /* required for async */ int* recvbufDisplsVec;
8649 const int* recvcounts;
8650 const int* rdispls;
8651 RECVTYPE* recvtype;
8653
8655 if(nullptr != sendbufIndices) {
8656 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
8657 sendbufIndices = nullptr;
8658 }
8659 if(nullptr != sendbufPrimals) {
8660 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
8661 sendbufPrimals = nullptr;
8662 }
8663 if(nullptr != sendbufCount) {
8664 delete [] sendbufCount;
8665 sendbufCount = nullptr;
8666 }
8667 if(nullptr != recvbufIndices) {
8668 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
8669 recvbufIndices = nullptr;
8670 }
8671 if(nullptr != recvbufPrimals) {
8672 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
8673 recvbufPrimals = nullptr;
8674 }
8675 if(nullptr != recvbufOldPrimals) {
8676 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
8677 recvbufOldPrimals = nullptr;
8678 }
8679 if(nullptr != recvbufCount) {
8680 delete [] recvbufCount;
8681 recvbufCount = nullptr;
8682 }
8683 }
8684 };
8685
8686 template<typename SENDTYPE, typename RECVTYPE>
8688 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
8689 typename SENDTYPE::ModifiedType* sendbufMod;
8690 const int* sdisplsMod;
8691 const int* sendcounts;
8692 const int* sdispls;
8693 SENDTYPE* sendtype;
8694 typename RECVTYPE::Type* recvbuf;
8695 typename RECVTYPE::ModifiedType* recvbufMod;
8696 const int* rdisplsMod;
8697 const int* recvcounts;
8698 const int* rdispls;
8699 RECVTYPE* recvtype;
8702 };
8703
8704 template<typename SENDTYPE, typename RECVTYPE>
8705 void AMPI_Ialltoallv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
8707 (handle);
8708 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8709 (void)adType;
8710
8711 h->recvbufAdjoints = nullptr;
8713 adjointInterface->getVectorSize());
8714 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
8715 h->sendbufAdjoints = nullptr;
8717 adjointInterface->getVectorSize());
8718 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
8719 // Primal buffers are always linear in space so we can accesses them in one sweep
8720 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
8721
8722
8725 h->recvtype, h->comm, &h->requestReverse);
8726
8727 }
8728
8729 template<typename SENDTYPE, typename RECVTYPE>
8730 void AMPI_Ialltoallv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8731
8733 (handle);
8734 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8735 (void)adType;
8736 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8737
8738 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
8739 delete [] h->sendbufCountVec;
8740 delete [] h->sendbufDisplsVec;
8741 if(adType->isOldPrimalsRequired()) {
8742 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
8743 }
8744 // Primal buffers are always linear in space so we can accesses them in one sweep
8745 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
8746 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
8747 delete [] h->recvbufCountVec;
8748 delete [] h->recvbufDisplsVec;
8749 }
8750
8751 template<typename SENDTYPE, typename RECVTYPE>
8752 void AMPI_Ialltoallv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
8754 (handle);
8755 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8756 (void)adType;
8757
8758 h->recvbufAdjoints = nullptr;
8760 adjointInterface->getVectorSize());
8761 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
8762 h->sendbufAdjoints = nullptr;
8764 adjointInterface->getVectorSize());
8765 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
8766 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8767 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8768
8769
8772 h->recvtype, h->comm, &h->requestReverse);
8773
8774 }
8775
8776 template<typename SENDTYPE, typename RECVTYPE>
8777 void AMPI_Ialltoallv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8778
8780 (handle);
8781 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8782 (void)adType;
8783 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8784
8785 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
8786 delete [] h->sendbufCountVec;
8787 delete [] h->sendbufDisplsVec;
8788 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8789 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
8790 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
8791 delete [] h->recvbufCountVec;
8792 delete [] h->recvbufDisplsVec;
8793 }
8794
8795 template<typename SENDTYPE, typename RECVTYPE>
8796 void AMPI_Ialltoallv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
8798 (handle);
8799 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8800 (void)adType;
8801
8802 h->recvbufAdjoints = nullptr;
8804 adjointInterface->getVectorSize());
8805 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
8806 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8807 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
8808
8809 if(adType->isOldPrimalsRequired()) {
8810 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
8811 }
8812 h->sendbufAdjoints = nullptr;
8814 adjointInterface->getVectorSize());
8815 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
8816
8819 h->recvtype, h->comm, &h->requestReverse);
8820
8821 }
8822
8823 template<typename SENDTYPE, typename RECVTYPE>
8824 void AMPI_Ialltoallv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
8825
8827 (handle);
8828 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8829 (void)adType;
8830 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
8831
8832 // Adjoint buffers are always linear in space so we can accesses them in one sweep
8833 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
8834 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
8835 delete [] h->sendbufCountVec;
8836 delete [] h->sendbufDisplsVec;
8837 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
8838 delete [] h->recvbufCountVec;
8839 delete [] h->recvbufDisplsVec;
8840 }
8841
8842 template<typename SENDTYPE, typename RECVTYPE>
8843 void AMPI_Ialltoallv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
8845 (handle);
8846 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8847 (void)adType;
8848
8849 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
8850 }
8851
8852 template<typename SENDTYPE, typename RECVTYPE>
8853 void AMPI_Ialltoallv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
8855 (handle);
8856 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
8857 (void)adType;
8858
8859 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
8860 }
8861
8862 template<typename SENDTYPE, typename RECVTYPE>
8863 int AMPI_Ialltoallv_finish(HandleBase* handle);
8864 template<typename SENDTYPE, typename RECVTYPE>
8865 int AMPI_Ialltoallv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, const int* sendcounts, const int* sdispls,
8866 SENDTYPE* sendtype, typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* rdispls, RECVTYPE* recvtype,
8867 AMPI_Comm comm, AMPI_Request* request) {
8868 int rStatus;
8869 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
8870
8871 if(!adType->isActiveType()) {
8872 // call the regular function if the type is not active
8873 rStatus = MPI_Ialltoallv(sendbuf, sendcounts, sdispls, sendtype->getMpiType(), recvbuf, recvcounts, rdispls,
8874 recvtype->getMpiType(), comm, &request->request);
8875 } else {
8876
8877 // the type is an AD type so handle the buffers
8879 MEDI_OPTIONAL_CONST int* sdisplsMod = sdispls;
8880 int sdisplsTotalSize = 0;
8881 if(nullptr != sdispls) {
8882 sdisplsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
8883 if(recvtype->isModifiedBufferRequired()) {
8884 sdisplsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
8885 }
8886 }
8887 MEDI_OPTIONAL_CONST int* rdisplsMod = rdispls;
8888 int rdisplsTotalSize = 0;
8889 if(nullptr != rdispls) {
8890 rdisplsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
8891 if(recvtype->isModifiedBufferRequired()) {
8892 rdisplsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
8893 }
8894 }
8895 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
8896 int sendbufElements = 0;
8897
8898 // compute the total size of the buffer
8899 if(AMPI_IN_PLACE != sendbuf) {
8900 sendbufElements = sdisplsTotalSize;
8901 } else {
8902 sendbufElements = rdisplsTotalSize;
8903 }
8904
8905 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
8906 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
8907 } else {
8908 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
8909 }
8910 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
8911 int recvbufElements = 0;
8912
8913 // compute the total size of the buffer
8914 recvbufElements = rdisplsTotalSize;
8915
8916 if(recvtype->isModifiedBufferRequired() ) {
8917 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
8918 } else {
8919 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
8920 }
8921
8922 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
8923 if(adType->isHandleRequired()) {
8925 }
8926 adType->startAssembly(h);
8927 if(sendtype->isModifiedBufferRequired()) {
8928 if(AMPI_IN_PLACE != sendbuf) {
8929 for(int i = 0; i < getCommSize(comm); ++i) {
8930 sendtype->copyIntoModifiedBuffer(sendbuf, sdispls[i], sendbufMod, sdisplsMod[i], sendcounts[i]);
8931 }
8932 } else {
8933 for(int i = 0; i < getCommSize(comm); ++i) {
8934 recvtype->copyIntoModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
8935 }
8936 }
8937 }
8938
8939 if(nullptr != h) {
8940 // gather the information for the reverse sweep
8941
8942 // create the index buffers
8943 if(AMPI_IN_PLACE != sendbuf) {
8944 createLinearIndexCounts(h->sendbufCount, sendcounts, sdispls, getCommSize(comm), sendtype);
8945 } else {
8946 createLinearIndexCounts(h->sendbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
8947 }
8948 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
8949 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
8950 createLinearIndexCounts(h->recvbufCount, recvcounts, rdispls, getCommSize(comm), recvtype);
8951 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
8952 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
8953
8954
8955 // extract the old primal values from the recv buffer if the AD tool
8956 // needs the primal values reset
8957 if(adType->isOldPrimalsRequired()) {
8958 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
8959 for(int i = 0; i < getCommSize(comm); ++i) {
8960 recvtype->getValues(recvbuf, rdispls[i], h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
8961 }
8962 }
8963
8964
8965 if(AMPI_IN_PLACE != sendbuf) {
8966 for(int i = 0; i < getCommSize(comm); ++i) {
8967 sendtype->getIndices(sendbuf, sdispls[i], h->sendbufIndices, sdisplsMod[i], sendcounts[i]);
8968 }
8969 } else {
8970 for(int i = 0; i < getCommSize(comm); ++i) {
8971 recvtype->getIndices(recvbuf, rdispls[i], h->sendbufIndices, rdisplsMod[i], recvcounts[i]);
8972 }
8973 }
8974
8975 for(int i = 0; i < getCommSize(comm); ++i) {
8976 recvtype->createIndices(recvbuf, rdispls[i], h->recvbufIndices, rdisplsMod[i], recvcounts[i]);
8977 }
8978
8979 // pack all the variables in the handle
8985 h->sendcounts = sendcounts;
8986 h->sdispls = sdispls;
8987 h->sendtype = sendtype;
8988 h->recvcounts = recvcounts;
8989 h->rdispls = rdispls;
8990 h->recvtype = recvtype;
8991 h->comm = comm;
8992 }
8993
8994 if(!recvtype->isModifiedBufferRequired()) {
8995 for(int i = 0; i < getCommSize(comm); ++i) {
8996 recvtype->clearIndices(recvbuf, rdispls[i], recvcounts[i]);
8997 }
8998 }
8999
9000 rStatus = MPI_Ialltoallv(sendbufMod, sendcounts, sdisplsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcounts,
9001 rdisplsMod, recvtype->getModifiedMpiType(), comm, &request->request);
9002
9004 asyncHandle->sendbuf = sendbuf;
9005 asyncHandle->sendbufMod = sendbufMod;
9006 asyncHandle->sdisplsMod = sdisplsMod;
9007 asyncHandle->sendcounts = sendcounts;
9008 asyncHandle->sdispls = sdispls;
9009 asyncHandle->sendtype = sendtype;
9010 asyncHandle->recvbuf = recvbuf;
9011 asyncHandle->recvbufMod = recvbufMod;
9012 asyncHandle->rdisplsMod = rdisplsMod;
9013 asyncHandle->recvcounts = recvcounts;
9014 asyncHandle->rdispls = rdispls;
9015 asyncHandle->recvtype = recvtype;
9016 asyncHandle->comm = comm;
9017 asyncHandle->toolHandle = h;
9018 request->handle = asyncHandle;
9020
9021 // create adjoint wait
9022 if(nullptr != h) {
9025 adType->addToolAction(waitH);
9026 }
9027 }
9028
9029 return rStatus;
9030 }
9031
9032 template<typename SENDTYPE, typename RECVTYPE>
9034 int rStatus = 0;
9035
9038 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
9039 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
9040 const int* sdisplsMod = asyncHandle->sdisplsMod;
9041 const int* sendcounts = asyncHandle->sendcounts;
9042 const int* sdispls = asyncHandle->sdispls;
9043 SENDTYPE* sendtype = asyncHandle->sendtype;
9044 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
9045 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
9046 const int* rdisplsMod = asyncHandle->rdisplsMod;
9047 const int* recvcounts = asyncHandle->recvcounts;
9048 const int* rdispls = asyncHandle->rdispls;
9049 RECVTYPE* recvtype = asyncHandle->recvtype;
9050 AMPI_Comm comm = asyncHandle->comm;
9051 AMPI_Request* request = asyncHandle->request;
9053 (asyncHandle->toolHandle);
9054 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
9055 MEDI_UNUSED(h); // Unused generated to ignore warnings
9056 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
9057 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
9058 MEDI_UNUSED(sdisplsMod); // Unused generated to ignore warnings
9059 MEDI_UNUSED(sendcounts); // Unused generated to ignore warnings
9060 MEDI_UNUSED(sdispls); // Unused generated to ignore warnings
9061 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
9062 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
9063 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
9064 MEDI_UNUSED(rdisplsMod); // Unused generated to ignore warnings
9065 MEDI_UNUSED(recvcounts); // Unused generated to ignore warnings
9066 MEDI_UNUSED(rdispls); // Unused generated to ignore warnings
9067 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
9068 MEDI_UNUSED(comm); // Unused generated to ignore warnings
9069 MEDI_UNUSED(request); // Unused generated to ignore warnings
9070
9071 delete asyncHandle;
9072
9073 if(adType->isActiveType()) {
9074
9075 adType->addToolAction(h);
9076
9077 if(recvtype->isModifiedBufferRequired()) {
9078 for(int i = 0; i < getCommSize(comm); ++i) {
9079 recvtype->copyFromModifiedBuffer(recvbuf, rdispls[i], recvbufMod, rdisplsMod[i], recvcounts[i]);
9080 }
9081 }
9082
9083 if(nullptr != h) {
9084 // handle the recv buffers
9085 for(int i = 0; i < getCommSize(comm); ++i) {
9086 recvtype->registerValue(recvbuf, rdispls[i], h->recvbufIndices, h->recvbufOldPrimals, rdisplsMod[i], recvcounts[i]);
9087 }
9088 }
9089
9090 adType->stopAssembly(h);
9091 if(recvtype->isModifiedBufferRequired()) {
9092 delete [] sdisplsMod;
9093 }
9094 if(recvtype->isModifiedBufferRequired()) {
9095 delete [] rdisplsMod;
9096 }
9097
9098 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9099 sendtype->deleteModifiedTypeBuffer(sendbufMod);
9100 }
9101 if(recvtype->isModifiedBufferRequired() ) {
9102 recvtype->deleteModifiedTypeBuffer(recvbufMod);
9103 }
9104
9105 // handle is deleted by the AD tool
9106 }
9107
9108 return rStatus;
9109 }
9110
9111#endif
9112#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
9113 template<typename DATATYPE>
9116 typename DATATYPE::IndexType* bufferSendIndices;
9117 typename DATATYPE::PrimalType* bufferSendPrimals;
9118 /* required for async */ void* bufferSendAdjoints;
9122 typename DATATYPE::IndexType* bufferRecvIndices;
9123 typename DATATYPE::PrimalType* bufferRecvPrimals;
9124 typename DATATYPE::PrimalType* bufferRecvOldPrimals;
9125 /* required for async */ void* bufferRecvAdjoints;
9129 DATATYPE* datatype;
9130 int root;
9132
9134 if(nullptr != bufferSendIndices) {
9135 datatype->getADTool().deleteIndexTypeBuffer(bufferSendIndices);
9136 bufferSendIndices = nullptr;
9137 }
9138 if(nullptr != bufferSendPrimals) {
9139 datatype->getADTool().deletePrimalTypeBuffer(bufferSendPrimals);
9140 bufferSendPrimals = nullptr;
9141 }
9142 if(nullptr != bufferRecvIndices) {
9143 datatype->getADTool().deleteIndexTypeBuffer(bufferRecvIndices);
9144 bufferRecvIndices = nullptr;
9145 }
9146 if(nullptr != bufferRecvPrimals) {
9147 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvPrimals);
9148 bufferRecvPrimals = nullptr;
9149 }
9150 if(nullptr != bufferRecvOldPrimals) {
9151 datatype->getADTool().deletePrimalTypeBuffer(bufferRecvOldPrimals);
9152 bufferRecvOldPrimals = nullptr;
9153 }
9154 }
9155 };
9156
9157 template<typename DATATYPE>
9159 typename DATATYPE::Type* bufferSend;
9160 typename DATATYPE::ModifiedType* bufferSendMod;
9161 typename DATATYPE::Type* bufferRecv;
9162 typename DATATYPE::ModifiedType* bufferRecvMod;
9164 DATATYPE* datatype;
9165 int root;
9168 };
9169
9170 template<typename DATATYPE>
9171 void AMPI_Ibcast_wrap_p(HandleBase* handle, AdjointInterface* adjointInterface) {
9173 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9174 (void)adType;
9175
9176 h->bufferRecvAdjoints = nullptr;
9177 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
9178 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferRecvPrimals, h->bufferRecvTotalSize );
9179 h->bufferSendAdjoints = nullptr;
9180 if(h->root == getCommRank(h->comm)) {
9181 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
9182 adjointInterface->createPrimalTypeBuffer((void*&)h->bufferSendPrimals, h->bufferSendTotalSize );
9183 // Primal buffers are always linear in space so we can accesses them in one sweep
9185
9186 }
9187
9189 h->count, h->datatype, h->root, h->comm, &h->requestReverse);
9190
9191 }
9192
9193 template<typename DATATYPE>
9194 void AMPI_Ibcast_wrap_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9195
9197 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9198 (void)adType;
9199 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9200
9201 if(h->root == getCommRank(h->comm)) {
9202 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferSendPrimals);
9203 }
9204 if(adType->isOldPrimalsRequired()) {
9206 }
9207 // Primal buffers are always linear in space so we can accesses them in one sweep
9209 adjointInterface->deletePrimalTypeBuffer((void*&)h->bufferRecvPrimals);
9210 }
9211
9212 template<typename DATATYPE>
9213 void AMPI_Ibcast_wrap_d(HandleBase* handle, AdjointInterface* adjointInterface) {
9215 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9216 (void)adType;
9217
9218 h->bufferRecvAdjoints = nullptr;
9219 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
9221 h->bufferSendAdjoints = nullptr;
9222 if(h->root == getCommRank(h->comm)) {
9223 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
9225 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9227
9228 }
9229
9231 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm, &h->requestReverse);
9232
9233 }
9234
9235 template<typename DATATYPE>
9236 void AMPI_Ibcast_wrap_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9237
9239 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9240 (void)adType;
9241 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9242
9243 if(h->root == getCommRank(h->comm)) {
9244 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
9245 }
9246 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9248 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
9249 }
9250
9251 template<typename DATATYPE>
9252 void AMPI_Ibcast_wrap_b(HandleBase* handle, AdjointInterface* adjointInterface) {
9254 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9255 (void)adType;
9256
9257 h->bufferRecvAdjoints = nullptr;
9258 h->bufferRecvCountVec = adjointInterface->getVectorSize() * h->bufferRecvCount;
9260 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9262
9263 if(adType->isOldPrimalsRequired()) {
9265 }
9266 h->bufferSendAdjoints = nullptr;
9267 if(h->root == getCommRank(h->comm)) {
9268 h->bufferSendCountVec = adjointInterface->getVectorSize() * h->bufferSendCount;
9270 }
9271
9273 h->bufferRecvCountVec, h->count, h->datatype, h->root, h->comm, &h->requestReverse);
9274
9275 }
9276
9277 template<typename DATATYPE>
9278 void AMPI_Ibcast_wrap_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9279
9281 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9282 (void)adType;
9283 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9284
9285 if(h->root == getCommRank(h->comm)) {
9287 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9289 adjointInterface->deleteAdjointTypeBuffer(h->bufferSendAdjoints);
9290 }
9291 adjointInterface->deleteAdjointTypeBuffer(h->bufferRecvAdjoints);
9292 }
9293
9294 template<typename DATATYPE>
9295 void AMPI_Ibcast_wrap_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
9297 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9298 (void)adType;
9299
9300 if(h->root == getCommRank(h->comm)) {
9301 adType->iterateIdentifiers(h->bufferSendIndices, h->bufferSendTotalSize, func, userData);
9302 }
9303 }
9304
9305 template<typename DATATYPE>
9306 void AMPI_Ibcast_wrap_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
9308 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
9309 (void)adType;
9310
9311 adType->iterateIdentifiers(h->bufferRecvIndices, h->bufferRecvTotalSize, func, userData);
9312 }
9313
9314 template<typename DATATYPE>
9315 int AMPI_Ibcast_wrap_finish(HandleBase* handle);
9316 template<typename DATATYPE>
9317 int AMPI_Ibcast_wrap(typename DATATYPE::Type* bufferSend, typename DATATYPE::Type* bufferRecv, int count,
9318 DATATYPE* datatype, int root, AMPI_Comm comm, AMPI_Request* request) {
9319 int rStatus;
9320 ADToolInterface const* adType = selectADTool(datatype->getADTool());
9321
9322 if(!adType->isActiveType()) {
9323 // call the regular function if the type is not active
9324 rStatus = MPI_Ibcast_wrap(bufferSend, bufferRecv, count, datatype->getMpiType(), root, comm, &request->request);
9325 } else {
9326
9327 // the type is an AD type so handle the buffers
9329 typename DATATYPE::ModifiedType* bufferSendMod = nullptr;
9330 int bufferSendElements = 0;
9331
9332 if(root == getCommRank(comm)) {
9333 // compute the total size of the buffer
9334 if(AMPI_IN_PLACE != bufferSend) {
9335 bufferSendElements = count;
9336 } else {
9337 bufferSendElements = count;
9338 }
9339
9340 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
9341 datatype->createModifiedTypeBuffer(bufferSendMod, bufferSendElements);
9342 } else {
9343 bufferSendMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferSend));
9344 }
9345 }
9346 typename DATATYPE::ModifiedType* bufferRecvMod = nullptr;
9347 int bufferRecvElements = 0;
9348
9349 // compute the total size of the buffer
9350 bufferRecvElements = count;
9351
9352 if(datatype->isModifiedBufferRequired() ) {
9353 datatype->createModifiedTypeBuffer(bufferRecvMod, bufferRecvElements);
9354 } else {
9355 bufferRecvMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(bufferRecv));
9356 }
9357
9358 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
9359 if(adType->isHandleRequired()) {
9361 }
9362 adType->startAssembly(h);
9363 if(root == getCommRank(comm)) {
9364 if(datatype->isModifiedBufferRequired()) {
9365 if(AMPI_IN_PLACE != bufferSend) {
9366 datatype->copyIntoModifiedBuffer(bufferSend, 0, bufferSendMod, 0, count);
9367 } else {
9368 datatype->copyIntoModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
9369 }
9370 }
9371 }
9372
9373 if(nullptr != h) {
9374 // gather the information for the reverse sweep
9375
9376 // create the index buffers
9377 if(root == getCommRank(comm)) {
9378 if(AMPI_IN_PLACE != bufferSend) {
9379 h->bufferSendCount = datatype->computeActiveElements(count);
9380 } else {
9381 h->bufferSendCount = datatype->computeActiveElements(count);
9382 }
9383 h->bufferSendTotalSize = datatype->computeActiveElements(bufferSendElements);
9384 datatype->getADTool().createIndexTypeBuffer(h->bufferSendIndices, h->bufferSendTotalSize);
9385 }
9386 h->bufferRecvCount = datatype->computeActiveElements(count);
9387 h->bufferRecvTotalSize = datatype->computeActiveElements(bufferRecvElements);
9388 datatype->getADTool().createIndexTypeBuffer(h->bufferRecvIndices, h->bufferRecvTotalSize);
9389
9390
9391 // extract the old primal values from the recv buffer if the AD tool
9392 // needs the primal values reset
9393 if(adType->isOldPrimalsRequired()) {
9394 datatype->getADTool().createPrimalTypeBuffer(h->bufferRecvOldPrimals, h->bufferRecvTotalSize);
9395 datatype->getValues(bufferRecv, 0, h->bufferRecvOldPrimals, 0, count);
9396 }
9397
9398
9399 if(root == getCommRank(comm)) {
9400 if(AMPI_IN_PLACE != bufferSend) {
9401 datatype->getIndices(bufferSend, 0, h->bufferSendIndices, 0, count);
9402 } else {
9403 datatype->getIndices(bufferRecv, 0, h->bufferSendIndices, 0, count);
9404 }
9405 }
9406
9407 datatype->createIndices(bufferRecv, 0, h->bufferRecvIndices, 0, count);
9408
9409 // pack all the variables in the handle
9415 h->count = count;
9416 h->datatype = datatype;
9417 h->root = root;
9418 h->comm = comm;
9419 }
9420
9421 if(!datatype->isModifiedBufferRequired()) {
9422 datatype->clearIndices(bufferRecv, 0, count);
9423 }
9424
9425 rStatus = MPI_Ibcast_wrap(bufferSendMod, bufferRecvMod, count, datatype->getModifiedMpiType(), root, comm,
9426 &request->request);
9427
9429 asyncHandle->bufferSend = bufferSend;
9430 asyncHandle->bufferSendMod = bufferSendMod;
9431 asyncHandle->bufferRecv = bufferRecv;
9432 asyncHandle->bufferRecvMod = bufferRecvMod;
9433 asyncHandle->count = count;
9434 asyncHandle->datatype = datatype;
9435 asyncHandle->root = root;
9436 asyncHandle->comm = comm;
9437 asyncHandle->toolHandle = h;
9438 request->handle = asyncHandle;
9440
9441 // create adjoint wait
9442 if(nullptr != h) {
9445 adType->addToolAction(waitH);
9446 }
9447 }
9448
9449 return rStatus;
9450 }
9451
9452 template<typename DATATYPE>
9454 int rStatus = 0;
9455
9457 typename DATATYPE::Type* bufferSend = asyncHandle->bufferSend;
9458 typename DATATYPE::ModifiedType* bufferSendMod = asyncHandle->bufferSendMod;
9459 typename DATATYPE::Type* bufferRecv = asyncHandle->bufferRecv;
9460 typename DATATYPE::ModifiedType* bufferRecvMod = asyncHandle->bufferRecvMod;
9461 int count = asyncHandle->count;
9462 DATATYPE* datatype = asyncHandle->datatype;
9463 int root = asyncHandle->root;
9464 AMPI_Comm comm = asyncHandle->comm;
9465 AMPI_Request* request = asyncHandle->request;
9467 (asyncHandle->toolHandle);
9468 ADToolInterface const* adType = selectADTool(datatype->getADTool());
9469 MEDI_UNUSED(h); // Unused generated to ignore warnings
9470 MEDI_UNUSED(bufferSend); // Unused generated to ignore warnings
9471 MEDI_UNUSED(bufferSendMod); // Unused generated to ignore warnings
9472 MEDI_UNUSED(bufferRecv); // Unused generated to ignore warnings
9473 MEDI_UNUSED(bufferRecvMod); // Unused generated to ignore warnings
9474 MEDI_UNUSED(count); // Unused generated to ignore warnings
9475 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
9476 MEDI_UNUSED(root); // Unused generated to ignore warnings
9477 MEDI_UNUSED(comm); // Unused generated to ignore warnings
9478 MEDI_UNUSED(request); // Unused generated to ignore warnings
9479
9480 delete asyncHandle;
9481
9482 if(adType->isActiveType()) {
9483
9484 adType->addToolAction(h);
9485
9486 if(datatype->isModifiedBufferRequired()) {
9487 datatype->copyFromModifiedBuffer(bufferRecv, 0, bufferRecvMod, 0, count);
9488 }
9489
9490 if(nullptr != h) {
9491 // handle the recv buffers
9492 datatype->registerValue(bufferRecv, 0, h->bufferRecvIndices, h->bufferRecvOldPrimals, 0, count);
9493 }
9494
9495 adType->stopAssembly(h);
9496
9497 if(root == getCommRank(comm)) {
9498 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == bufferSend)) {
9499 datatype->deleteModifiedTypeBuffer(bufferSendMod);
9500 }
9501 }
9502 if(datatype->isModifiedBufferRequired() ) {
9503 datatype->deleteModifiedTypeBuffer(bufferRecvMod);
9504 }
9505
9506 // handle is deleted by the AD tool
9507 }
9508
9509 return rStatus;
9510 }
9511
9512#endif
9513#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
9514 template<typename SENDTYPE, typename RECVTYPE>
9517 typename SENDTYPE::IndexType* sendbufIndices;
9518 typename SENDTYPE::PrimalType* sendbufPrimals;
9519 /* required for async */ void* sendbufAdjoints;
9523 SENDTYPE* sendtype;
9525 typename RECVTYPE::IndexType* recvbufIndices;
9526 typename RECVTYPE::PrimalType* recvbufPrimals;
9527 typename RECVTYPE::PrimalType* recvbufOldPrimals;
9528 /* required for async */ void* recvbufAdjoints;
9532 RECVTYPE* recvtype;
9533 int root;
9535
9537 if(nullptr != sendbufIndices) {
9538 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
9539 sendbufIndices = nullptr;
9540 }
9541 if(nullptr != sendbufPrimals) {
9542 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
9543 sendbufPrimals = nullptr;
9544 }
9545 if(nullptr != recvbufIndices) {
9546 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
9547 recvbufIndices = nullptr;
9548 }
9549 if(nullptr != recvbufPrimals) {
9550 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
9551 recvbufPrimals = nullptr;
9552 }
9553 if(nullptr != recvbufOldPrimals) {
9554 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
9555 recvbufOldPrimals = nullptr;
9556 }
9557 }
9558 };
9559
9560 template<typename SENDTYPE, typename RECVTYPE>
9562 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
9563 typename SENDTYPE::ModifiedType* sendbufMod;
9565 SENDTYPE* sendtype;
9566 typename RECVTYPE::Type* recvbuf;
9567 typename RECVTYPE::ModifiedType* recvbufMod;
9569 RECVTYPE* recvtype;
9570 int root;
9573 };
9574
9575 template<typename SENDTYPE, typename RECVTYPE>
9576 void AMPI_Igather_p(HandleBase* handle, AdjointInterface* adjointInterface) {
9578 (handle);
9579 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9580 (void)adType;
9581
9582 h->recvbufAdjoints = nullptr;
9583 if(h->root == getCommRank(h->comm)) {
9584 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
9585 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
9586 }
9587 h->sendbufAdjoints = nullptr;
9588 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9589 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
9590 // Primal buffers are always linear in space so we can accesses them in one sweep
9591 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
9592
9593
9596
9597 }
9598
9599 template<typename SENDTYPE, typename RECVTYPE>
9600 void AMPI_Igather_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9601
9603 (handle);
9604 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9605 (void)adType;
9606 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9607
9608 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
9609 if(adType->isOldPrimalsRequired()) {
9610 if(h->root == getCommRank(h->comm)) {
9611 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
9612 }
9613 }
9614 if(h->root == getCommRank(h->comm)) {
9615 // Primal buffers are always linear in space so we can accesses them in one sweep
9616 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
9617 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
9618 }
9619 }
9620
9621 template<typename SENDTYPE, typename RECVTYPE>
9622 void AMPI_Igather_d(HandleBase* handle, AdjointInterface* adjointInterface) {
9624 (handle);
9625 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9626 (void)adType;
9627
9628 h->recvbufAdjoints = nullptr;
9629 if(h->root == getCommRank(h->comm)) {
9630 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
9631 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
9632 }
9633 h->sendbufAdjoints = nullptr;
9634 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9635 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
9636 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9637 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
9638
9639
9642
9643 }
9644
9645 template<typename SENDTYPE, typename RECVTYPE>
9646 void AMPI_Igather_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9647
9649 (handle);
9650 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9651 (void)adType;
9652 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9653
9654 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9655 if(h->root == getCommRank(h->comm)) {
9656 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9657 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9658 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9659 }
9660 }
9661
9662 template<typename SENDTYPE, typename RECVTYPE>
9663 void AMPI_Igather_b(HandleBase* handle, AdjointInterface* adjointInterface) {
9665 (handle);
9666 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9667 (void)adType;
9668
9669 h->recvbufAdjoints = nullptr;
9670 if(h->root == getCommRank(h->comm)) {
9671 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
9672 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
9673 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9674 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
9675
9676 }
9677 if(adType->isOldPrimalsRequired()) {
9678 if(h->root == getCommRank(h->comm)) {
9679 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
9680 }
9681 }
9682 h->sendbufAdjoints = nullptr;
9683 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
9684 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
9685
9688
9689 }
9690
9691 template<typename SENDTYPE, typename RECVTYPE>
9692 void AMPI_Igather_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
9693
9695 (handle);
9696 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9697 (void)adType;
9698 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
9699
9700 // Adjoint buffers are always linear in space so we can accesses them in one sweep
9701 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
9702 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
9703 if(h->root == getCommRank(h->comm)) {
9704 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
9705 }
9706 }
9707
9708 template<typename SENDTYPE, typename RECVTYPE>
9709 void AMPI_Igather_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
9711 (handle);
9712 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9713 (void)adType;
9714
9715 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
9716 }
9717
9718 template<typename SENDTYPE, typename RECVTYPE>
9719 void AMPI_Igather_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
9721 (handle);
9722 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
9723 (void)adType;
9724
9725 if(h->root == getCommRank(h->comm)) {
9726 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
9727 }
9728 }
9729
9730 template<typename SENDTYPE, typename RECVTYPE>
9731 int AMPI_Igather_finish(HandleBase* handle);
9732 template<typename SENDTYPE, typename RECVTYPE>
9733 int AMPI_Igather(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
9734 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm, AMPI_Request* request) {
9735 int rStatus;
9736 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
9737
9738 if(!adType->isActiveType()) {
9739 // call the regular function if the type is not active
9740 rStatus = MPI_Igather(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
9741 comm, &request->request);
9742 } else {
9743
9744 // the type is an AD type so handle the buffers
9746 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
9747 int sendbufElements = 0;
9748
9749 // compute the total size of the buffer
9750 if(AMPI_IN_PLACE != sendbuf) {
9751 sendbufElements = sendcount;
9752 } else {
9753 sendbufElements = recvcount;
9754 }
9755
9756 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9757 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
9758 } else {
9759 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
9760 }
9761 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
9762 int recvbufElements = 0;
9763
9764 if(root == getCommRank(comm)) {
9765 // compute the total size of the buffer
9766 recvbufElements = recvcount * getCommSize(comm);
9767
9768 if(recvtype->isModifiedBufferRequired() ) {
9769 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
9770 } else {
9771 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
9772 }
9773 }
9774
9775 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
9776 if(adType->isHandleRequired()) {
9778 }
9779 adType->startAssembly(h);
9780 if(sendtype->isModifiedBufferRequired()) {
9781 if(AMPI_IN_PLACE != sendbuf) {
9782 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
9783 } else {
9784 recvtype->copyIntoModifiedBuffer(recvbuf, recvcount * getCommRank(comm), recvbufMod, recvcount * getCommRank(comm),
9785 recvcount);
9786 }
9787 }
9788
9789 if(nullptr != h) {
9790 // gather the information for the reverse sweep
9791
9792 // create the index buffers
9793 if(AMPI_IN_PLACE != sendbuf) {
9794 h->sendbufCount = sendtype->computeActiveElements(sendcount);
9795 } else {
9796 h->sendbufCount = recvtype->computeActiveElements(recvcount);
9797 }
9798 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
9799 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
9800 if(root == getCommRank(comm)) {
9801 h->recvbufCount = recvtype->computeActiveElements(recvcount);
9802 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
9803 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
9804 }
9805
9806
9807 // extract the old primal values from the recv buffer if the AD tool
9808 // needs the primal values reset
9809 if(adType->isOldPrimalsRequired()) {
9810 if(root == getCommRank(comm)) {
9811 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
9812 if(root == getCommRank(comm)) {
9813 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
9814 }
9815 }
9816 }
9817
9818
9819 if(AMPI_IN_PLACE != sendbuf) {
9820 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
9821 } else {
9822 recvtype->getIndices(recvbuf, recvcount * getCommRank(comm), h->sendbufIndices, 0, recvcount);
9823 }
9824
9825 if(root == getCommRank(comm)) {
9826 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount * getCommSize(comm));
9827 }
9828
9829 // pack all the variables in the handle
9835 h->sendcount = sendcount;
9836 h->sendtype = sendtype;
9837 h->recvcount = recvcount;
9838 h->recvtype = recvtype;
9839 h->root = root;
9840 h->comm = comm;
9841 }
9842
9843 if(root == getCommRank(comm)) {
9844 if(!recvtype->isModifiedBufferRequired()) {
9845 recvtype->clearIndices(recvbuf, 0, recvcount * getCommSize(comm));
9846 }
9847 }
9848
9849 rStatus = MPI_Igather(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
9850 recvtype->getModifiedMpiType(), root, comm, &request->request);
9851
9853 asyncHandle->sendbuf = sendbuf;
9854 asyncHandle->sendbufMod = sendbufMod;
9855 asyncHandle->sendcount = sendcount;
9856 asyncHandle->sendtype = sendtype;
9857 asyncHandle->recvbuf = recvbuf;
9858 asyncHandle->recvbufMod = recvbufMod;
9859 asyncHandle->recvcount = recvcount;
9860 asyncHandle->recvtype = recvtype;
9861 asyncHandle->root = root;
9862 asyncHandle->comm = comm;
9863 asyncHandle->toolHandle = h;
9864 request->handle = asyncHandle;
9866
9867 // create adjoint wait
9868 if(nullptr != h) {
9871 adType->addToolAction(waitH);
9872 }
9873 }
9874
9875 return rStatus;
9876 }
9877
9878 template<typename SENDTYPE, typename RECVTYPE>
9880 int rStatus = 0;
9881
9883 (handle);
9884 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
9885 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
9886 int sendcount = asyncHandle->sendcount;
9887 SENDTYPE* sendtype = asyncHandle->sendtype;
9888 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
9889 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
9890 int recvcount = asyncHandle->recvcount;
9891 RECVTYPE* recvtype = asyncHandle->recvtype;
9892 int root = asyncHandle->root;
9893 AMPI_Comm comm = asyncHandle->comm;
9894 AMPI_Request* request = asyncHandle->request;
9896 (asyncHandle->toolHandle);
9897 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
9898 MEDI_UNUSED(h); // Unused generated to ignore warnings
9899 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
9900 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
9901 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
9902 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
9903 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
9904 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
9905 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
9906 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
9907 MEDI_UNUSED(root); // Unused generated to ignore warnings
9908 MEDI_UNUSED(comm); // Unused generated to ignore warnings
9909 MEDI_UNUSED(request); // Unused generated to ignore warnings
9910
9911 delete asyncHandle;
9912
9913 if(adType->isActiveType()) {
9914
9915 adType->addToolAction(h);
9916
9917 if(root == getCommRank(comm)) {
9918 if(recvtype->isModifiedBufferRequired()) {
9919 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount * getCommSize(comm));
9920 }
9921 }
9922
9923 if(nullptr != h) {
9924 // handle the recv buffers
9925 if(root == getCommRank(comm)) {
9926 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount * getCommSize(comm));
9927 }
9928 }
9929
9930 adType->stopAssembly(h);
9931
9932 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
9933 sendtype->deleteModifiedTypeBuffer(sendbufMod);
9934 }
9935 if(root == getCommRank(comm)) {
9936 if(recvtype->isModifiedBufferRequired() ) {
9937 recvtype->deleteModifiedTypeBuffer(recvbufMod);
9938 }
9939 }
9940
9941 // handle is deleted by the AD tool
9942 }
9943
9944 return rStatus;
9945 }
9946
9947#endif
9948#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
9949 template<typename SENDTYPE, typename RECVTYPE>
9952 typename SENDTYPE::IndexType* sendbufIndices;
9953 typename SENDTYPE::PrimalType* sendbufPrimals;
9954 /* required for async */ void* sendbufAdjoints;
9958 SENDTYPE* sendtype;
9960 typename RECVTYPE::IndexType* recvbufIndices;
9961 typename RECVTYPE::PrimalType* recvbufPrimals;
9962 typename RECVTYPE::PrimalType* recvbufOldPrimals;
9963 /* required for async */ void* recvbufAdjoints;
9965 /* required for async */ int* recvbufCountVec;
9966 /* required for async */ int* recvbufDisplsVec;
9967 const int* recvcounts;
9968 const int* displs;
9969 RECVTYPE* recvtype;
9970 int root;
9972
9974 if(nullptr != sendbufIndices) {
9975 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
9976 sendbufIndices = nullptr;
9977 }
9978 if(nullptr != sendbufPrimals) {
9979 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
9980 sendbufPrimals = nullptr;
9981 }
9982 if(nullptr != recvbufIndices) {
9983 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
9984 recvbufIndices = nullptr;
9985 }
9986 if(nullptr != recvbufPrimals) {
9987 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
9988 recvbufPrimals = nullptr;
9989 }
9990 if(nullptr != recvbufOldPrimals) {
9991 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
9992 recvbufOldPrimals = nullptr;
9993 }
9994 if(nullptr != recvbufCount) {
9995 delete [] recvbufCount;
9996 recvbufCount = nullptr;
9997 }
9998 }
9999 };
10000
10001 template<typename SENDTYPE, typename RECVTYPE>
10003 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf;
10004 typename SENDTYPE::ModifiedType* sendbufMod;
10006 SENDTYPE* sendtype;
10007 typename RECVTYPE::Type* recvbuf;
10008 typename RECVTYPE::ModifiedType* recvbufMod;
10009 const int* displsMod;
10010 const int* recvcounts;
10011 const int* displs;
10012 RECVTYPE* recvtype;
10013 int root;
10016 };
10017
10018 template<typename SENDTYPE, typename RECVTYPE>
10019 void AMPI_Igatherv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
10021 (handle);
10022 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10023 (void)adType;
10024
10025 h->recvbufAdjoints = nullptr;
10026 if(h->root == getCommRank(h->comm)) {
10028 adjointInterface->getVectorSize());
10029 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
10030 }
10031 h->sendbufAdjoints = nullptr;
10032 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10033 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
10034 // Primal buffers are always linear in space so we can accesses them in one sweep
10035 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
10036
10037
10040 &h->requestReverse);
10041
10042 }
10043
10044 template<typename SENDTYPE, typename RECVTYPE>
10045 void AMPI_Igatherv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10046
10048 (handle);
10049 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10050 (void)adType;
10051 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10052
10053 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
10054 if(adType->isOldPrimalsRequired()) {
10055 if(h->root == getCommRank(h->comm)) {
10056 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10057 }
10058 }
10059 if(h->root == getCommRank(h->comm)) {
10060 // Primal buffers are always linear in space so we can accesses them in one sweep
10061 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
10062 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
10063 delete [] h->recvbufCountVec;
10064 delete [] h->recvbufDisplsVec;
10065 }
10066 }
10067
10068 template<typename SENDTYPE, typename RECVTYPE>
10069 void AMPI_Igatherv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
10071 (handle);
10072 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10073 (void)adType;
10074
10075 h->recvbufAdjoints = nullptr;
10076 if(h->root == getCommRank(h->comm)) {
10078 adjointInterface->getVectorSize());
10079 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10080 }
10081 h->sendbufAdjoints = nullptr;
10082 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10083 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10084 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10085 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10086
10087
10090 &h->requestReverse);
10091
10092 }
10093
10094 template<typename SENDTYPE, typename RECVTYPE>
10095 void AMPI_Igatherv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10096
10098 (handle);
10099 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10100 (void)adType;
10101 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10102
10103 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10104 if(h->root == getCommRank(h->comm)) {
10105 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10106 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10107 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10108 delete [] h->recvbufCountVec;
10109 delete [] h->recvbufDisplsVec;
10110 }
10111 }
10112
10113 template<typename SENDTYPE, typename RECVTYPE>
10114 void AMPI_Igatherv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
10116 (handle);
10117 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10118 (void)adType;
10119
10120 h->recvbufAdjoints = nullptr;
10121 if(h->root == getCommRank(h->comm)) {
10123 adjointInterface->getVectorSize());
10124 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10125 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10126 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10127
10128 }
10129 if(adType->isOldPrimalsRequired()) {
10130 if(h->root == getCommRank(h->comm)) {
10131 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10132 }
10133 }
10134 h->sendbufAdjoints = nullptr;
10135 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10136 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10137
10140 &h->requestReverse);
10141
10142 }
10143
10144 template<typename SENDTYPE, typename RECVTYPE>
10145 void AMPI_Igatherv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10146
10148 (handle);
10149 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10150 (void)adType;
10151 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10152
10153 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10154 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10155 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10156 if(h->root == getCommRank(h->comm)) {
10157 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10158 delete [] h->recvbufCountVec;
10159 delete [] h->recvbufDisplsVec;
10160 }
10161 }
10162
10163 template<typename SENDTYPE, typename RECVTYPE>
10164 void AMPI_Igatherv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
10166 (handle);
10167 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10168 (void)adType;
10169
10170 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
10171 }
10172
10173 template<typename SENDTYPE, typename RECVTYPE>
10174 void AMPI_Igatherv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
10176 (handle);
10177 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10178 (void)adType;
10179
10180 if(h->root == getCommRank(h->comm)) {
10181 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
10182 }
10183 }
10184
10185 template<typename SENDTYPE, typename RECVTYPE>
10186 int AMPI_Igatherv_finish(HandleBase* handle);
10187 template<typename SENDTYPE, typename RECVTYPE>
10188 int AMPI_Igatherv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
10189 typename RECVTYPE::Type* recvbuf, const int* recvcounts, const int* displs, RECVTYPE* recvtype, int root,
10190 AMPI_Comm comm, AMPI_Request* request) {
10191 int rStatus;
10192 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
10193
10194 if(!adType->isActiveType()) {
10195 // call the regular function if the type is not active
10196 rStatus = MPI_Igatherv(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcounts, displs, recvtype->getMpiType(),
10197 root, comm, &request->request);
10198 } else {
10199
10200 // the type is an AD type so handle the buffers
10202 MEDI_OPTIONAL_CONST int* displsMod = displs;
10203 int displsTotalSize = 0;
10204 if(nullptr != displs) {
10205 displsTotalSize = computeDisplacementsTotalSize(recvcounts, getCommSize(comm));
10206 if(recvtype->isModifiedBufferRequired()) {
10207 displsMod = createLinearDisplacements(recvcounts, getCommSize(comm));
10208 }
10209 }
10210 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
10211 int sendbufElements = 0;
10212
10213 // compute the total size of the buffer
10214 if(AMPI_IN_PLACE != sendbuf) {
10215 sendbufElements = sendcount;
10216 } else {
10217 sendbufElements = recvcounts[getCommRank(comm)];
10218 }
10219
10220 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
10221 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
10222 } else {
10223 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
10224 }
10225 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
10226 int recvbufElements = 0;
10227
10228 if(root == getCommRank(comm)) {
10229 // compute the total size of the buffer
10230 recvbufElements = displsTotalSize;
10231
10232 if(recvtype->isModifiedBufferRequired() ) {
10233 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
10234 } else {
10235 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
10236 }
10237 }
10238
10239 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
10240 if(adType->isHandleRequired()) {
10242 }
10243 adType->startAssembly(h);
10244 if(sendtype->isModifiedBufferRequired()) {
10245 if(AMPI_IN_PLACE != sendbuf) {
10246 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount);
10247 } else {
10248 {
10249 const int rank = getCommRank(comm);
10250 recvtype->copyIntoModifiedBuffer(recvbuf, displs[rank], recvbufMod, displsMod[rank], recvcounts[rank]);
10251 }
10252 }
10253 }
10254
10255 if(nullptr != h) {
10256 // gather the information for the reverse sweep
10257
10258 // create the index buffers
10259 if(AMPI_IN_PLACE != sendbuf) {
10260 h->sendbufCount = sendtype->computeActiveElements(sendcount);
10261 } else {
10262 h->sendbufCount = recvtype->computeActiveElements(displs[getCommRank(comm)] + recvcounts[getCommRank(
10263 comm)]) - recvtype->computeActiveElements(displs[getCommRank(comm)]);
10264 }
10265 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
10266 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
10267 if(root == getCommRank(comm)) {
10268 createLinearIndexCounts(h->recvbufCount, recvcounts, displs, getCommSize(comm), recvtype);
10269 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
10270 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
10271 }
10272
10273
10274 // extract the old primal values from the recv buffer if the AD tool
10275 // needs the primal values reset
10276 if(adType->isOldPrimalsRequired()) {
10277 if(root == getCommRank(comm)) {
10278 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
10279 if(root == getCommRank(comm)) {
10280 for(int i = 0; i < getCommSize(comm); ++i) {
10281 recvtype->getValues(recvbuf, displs[i], h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
10282 }
10283 }
10284 }
10285 }
10286
10287
10288 if(AMPI_IN_PLACE != sendbuf) {
10289 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount);
10290 } else {
10291 {
10292 const int rank = getCommRank(comm);
10293 recvtype->getIndices(recvbuf, displs[rank], h->sendbufIndices, 0, recvcounts[rank]);
10294 }
10295 }
10296
10297 if(root == getCommRank(comm)) {
10298 for(int i = 0; i < getCommSize(comm); ++i) {
10299 recvtype->createIndices(recvbuf, displs[i], h->recvbufIndices, displsMod[i], recvcounts[i]);
10300 }
10301 }
10302
10303 // pack all the variables in the handle
10309 h->sendcount = sendcount;
10310 h->sendtype = sendtype;
10311 h->recvcounts = recvcounts;
10312 h->displs = displs;
10313 h->recvtype = recvtype;
10314 h->root = root;
10315 h->comm = comm;
10316 }
10317
10318 if(root == getCommRank(comm)) {
10319 if(!recvtype->isModifiedBufferRequired()) {
10320 for(int i = 0; i < getCommSize(comm); ++i) {
10321 recvtype->clearIndices(recvbuf, displs[i], recvcounts[i]);
10322 }
10323 }
10324 }
10325
10326 rStatus = MPI_Igatherv(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcounts, displsMod,
10327 recvtype->getModifiedMpiType(), root, comm, &request->request);
10328
10330 asyncHandle->sendbuf = sendbuf;
10331 asyncHandle->sendbufMod = sendbufMod;
10332 asyncHandle->sendcount = sendcount;
10333 asyncHandle->sendtype = sendtype;
10334 asyncHandle->recvbuf = recvbuf;
10335 asyncHandle->recvbufMod = recvbufMod;
10336 asyncHandle->displsMod = displsMod;
10337 asyncHandle->recvcounts = recvcounts;
10338 asyncHandle->displs = displs;
10339 asyncHandle->recvtype = recvtype;
10340 asyncHandle->root = root;
10341 asyncHandle->comm = comm;
10342 asyncHandle->toolHandle = h;
10343 request->handle = asyncHandle;
10345
10346 // create adjoint wait
10347 if(nullptr != h) {
10350 adType->addToolAction(waitH);
10351 }
10352 }
10353
10354 return rStatus;
10355 }
10356
10357 template<typename SENDTYPE, typename RECVTYPE>
10359 int rStatus = 0;
10360
10363 MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
10364 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
10365 int sendcount = asyncHandle->sendcount;
10366 SENDTYPE* sendtype = asyncHandle->sendtype;
10367 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
10368 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
10369 const int* displsMod = asyncHandle->displsMod;
10370 const int* recvcounts = asyncHandle->recvcounts;
10371 const int* displs = asyncHandle->displs;
10372 RECVTYPE* recvtype = asyncHandle->recvtype;
10373 int root = asyncHandle->root;
10374 AMPI_Comm comm = asyncHandle->comm;
10375 AMPI_Request* request = asyncHandle->request;
10377 (asyncHandle->toolHandle);
10378 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
10379 MEDI_UNUSED(h); // Unused generated to ignore warnings
10380 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
10381 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
10382 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
10383 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
10384 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
10385 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
10386 MEDI_UNUSED(displsMod); // Unused generated to ignore warnings
10387 MEDI_UNUSED(recvcounts); // Unused generated to ignore warnings
10388 MEDI_UNUSED(displs); // Unused generated to ignore warnings
10389 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
10390 MEDI_UNUSED(root); // Unused generated to ignore warnings
10391 MEDI_UNUSED(comm); // Unused generated to ignore warnings
10392 MEDI_UNUSED(request); // Unused generated to ignore warnings
10393
10394 delete asyncHandle;
10395
10396 if(adType->isActiveType()) {
10397
10398 adType->addToolAction(h);
10399
10400 if(root == getCommRank(comm)) {
10401 if(recvtype->isModifiedBufferRequired()) {
10402 for(int i = 0; i < getCommSize(comm); ++i) {
10403 recvtype->copyFromModifiedBuffer(recvbuf, displs[i], recvbufMod, displsMod[i], recvcounts[i]);
10404 }
10405 }
10406 }
10407
10408 if(nullptr != h) {
10409 // handle the recv buffers
10410 if(root == getCommRank(comm)) {
10411 for(int i = 0; i < getCommSize(comm); ++i) {
10412 recvtype->registerValue(recvbuf, displs[i], h->recvbufIndices, h->recvbufOldPrimals, displsMod[i], recvcounts[i]);
10413 }
10414 }
10415 }
10416
10417 adType->stopAssembly(h);
10418 if(recvtype->isModifiedBufferRequired()) {
10419 delete [] displsMod;
10420 }
10421
10422 if(sendtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
10423 sendtype->deleteModifiedTypeBuffer(sendbufMod);
10424 }
10425 if(root == getCommRank(comm)) {
10426 if(recvtype->isModifiedBufferRequired() ) {
10427 recvtype->deleteModifiedTypeBuffer(recvbufMod);
10428 }
10429 }
10430
10431 // handle is deleted by the AD tool
10432 }
10433
10434 return rStatus;
10435 }
10436
10437#endif
10438#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
10439 template<typename DATATYPE>
10442 typename DATATYPE::IndexType* sendbufIndices;
10443 typename DATATYPE::PrimalType* sendbufPrimals;
10444 /* required for async */ void* sendbufAdjoints;
10448 typename DATATYPE::IndexType* recvbufIndices;
10449 typename DATATYPE::PrimalType* recvbufPrimals;
10450 typename DATATYPE::PrimalType* recvbufOldPrimals;
10451 /* required for async */ void* recvbufAdjoints;
10455 DATATYPE* datatype;
10457 int root;
10459
10461 if(nullptr != sendbufIndices) {
10462 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
10463 sendbufIndices = nullptr;
10464 }
10465 if(nullptr != sendbufPrimals) {
10466 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
10467 sendbufPrimals = nullptr;
10468 }
10469 if(nullptr != recvbufIndices) {
10470 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
10471 recvbufIndices = nullptr;
10472 }
10473 if(nullptr != recvbufPrimals) {
10474 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
10475 recvbufPrimals = nullptr;
10476 }
10477 if(nullptr != recvbufOldPrimals) {
10478 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
10479 recvbufOldPrimals = nullptr;
10480 }
10481 }
10482 };
10483
10484 template<typename DATATYPE>
10486 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf;
10487 typename DATATYPE::ModifiedType* sendbufMod;
10488 typename DATATYPE::Type* recvbuf;
10489 typename DATATYPE::ModifiedType* recvbufMod;
10491 DATATYPE* datatype;
10493 int root;
10496 };
10497
10498 template<typename DATATYPE>
10499 void AMPI_Ireduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
10501 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10502 (void)adType;
10503
10504 AMPI_Op convOp = adType->convertOperator(h->op);
10505 (void)convOp;
10506 h->recvbufAdjoints = nullptr;
10507 if(h->root == getCommRank(h->comm)) {
10508 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10509 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
10510 }
10511 h->sendbufAdjoints = nullptr;
10512 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10513 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
10514 // Primal buffers are always linear in space so we can accesses them in one sweep
10515 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
10516
10517
10519 h->count, h->datatype, h->op, h->root, h->comm, &h->requestReverse);
10520
10521 }
10522
10523 template<typename DATATYPE>
10525
10527 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10528 (void)adType;
10529 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10530
10531 AMPI_Op convOp = adType->convertOperator(h->op);
10532 (void)convOp;
10533 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
10534 if(adType->isOldPrimalsRequired()) {
10535 if(h->root == getCommRank(h->comm)) {
10536 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10537 }
10538 }
10539 if(h->root == getCommRank(h->comm)) {
10540 // Primal buffers are always linear in space so we can accesses them in one sweep
10541 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
10542 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
10543 }
10544 }
10545
10546 template<typename DATATYPE>
10547 void AMPI_Ireduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
10549 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10550 (void)adType;
10551
10552 AMPI_Op convOp = adType->convertOperator(h->op);
10553 (void)convOp;
10554 h->recvbufAdjoints = nullptr;
10555 if(h->root == getCommRank(h->comm)) {
10556 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10557 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10558 }
10559 h->sendbufAdjoints = nullptr;
10560 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10561 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10562 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10563 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10564
10565
10567 h->count, h->datatype, h->op, h->root, h->comm, &h->requestReverse);
10568
10569 }
10570
10571 template<typename DATATYPE>
10573
10575 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10576 (void)adType;
10577 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10578
10579 AMPI_Op convOp = adType->convertOperator(h->op);
10580 (void)convOp;
10581 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10582 if(h->root == getCommRank(h->comm)) {
10583 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10584 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10585 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10586 }
10587 }
10588
10589 template<typename DATATYPE>
10590 void AMPI_Ireduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
10592 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10593 (void)adType;
10594
10595 AMPI_Op convOp = adType->convertOperator(h->op);
10596 (void)convOp;
10597 h->recvbufAdjoints = nullptr;
10598 if(h->root == getCommRank(h->comm)) {
10599 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10600 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
10601 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10602 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
10603
10604 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
10605 }
10606 if(adType->isOldPrimalsRequired()) {
10607 if(h->root == getCommRank(h->comm)) {
10608 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10609 }
10610 }
10611 h->sendbufAdjoints = nullptr;
10612 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10613 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
10614
10616 h->count, h->datatype, h->op, h->root, h->comm, &h->requestReverse);
10617
10618 }
10619
10620 template<typename DATATYPE>
10622
10624 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10625 (void)adType;
10626 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10627
10628 AMPI_Op convOp = adType->convertOperator(h->op);
10629 (void)convOp;
10630 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
10631 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
10633 adjointInterface->getVectorSize());
10634 // Adjoint buffers are always linear in space so we can accesses them in one sweep
10635 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
10636 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
10637 if(h->root == getCommRank(h->comm)) {
10638 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
10639 }
10640 }
10641
10642 template<typename DATATYPE>
10643 void AMPI_Ireduce_global_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
10645 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10646 (void)adType;
10647
10648 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
10649 }
10650
10651 template<typename DATATYPE>
10652 void AMPI_Ireduce_global_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
10654 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
10655 (void)adType;
10656
10657 if(h->root == getCommRank(h->comm)) {
10658 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
10659 }
10660 }
10661
10662 template<typename DATATYPE>
10663 int AMPI_Ireduce_global_finish(HandleBase* handle);
10664 template<typename DATATYPE>
10665 int AMPI_Ireduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
10666 int count, DATATYPE* datatype, AMPI_Op op, int root, AMPI_Comm comm, AMPI_Request* request) {
10667 int rStatus;
10668 ADToolInterface const* adType = selectADTool(datatype->getADTool());
10669 AMPI_Op convOp = adType->convertOperator(op);
10670 (void)convOp;
10671
10672 if(!adType->isActiveType()) {
10673 // call the regular function if the type is not active
10674 rStatus = MPI_Ireduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, root, comm,
10675 &request->request);
10676 } else {
10677
10678 // the type is an AD type so handle the buffers
10680 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
10681 int sendbufElements = 0;
10682
10683 // compute the total size of the buffer
10684 if(AMPI_IN_PLACE != sendbuf) {
10685 sendbufElements = count;
10686 } else {
10687 sendbufElements = count;
10688 }
10689
10690 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
10691 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
10692 } else {
10693 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
10694 }
10695 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
10696 int recvbufElements = 0;
10697
10698 if(root == getCommRank(comm)) {
10699 // compute the total size of the buffer
10700 recvbufElements = count;
10701
10702 if(datatype->isModifiedBufferRequired() ) {
10703 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
10704 } else {
10705 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
10706 }
10707 }
10708
10709 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
10710 if(adType->isHandleRequired()) {
10712 }
10713 adType->startAssembly(h);
10714 if(datatype->isModifiedBufferRequired()) {
10715 if(AMPI_IN_PLACE != sendbuf) {
10716 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
10717 } else {
10718 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
10719 }
10720 }
10721
10722 if(nullptr != h) {
10723 // gather the information for the reverse sweep
10724
10725 // create the index buffers
10726 if(AMPI_IN_PLACE != sendbuf) {
10727 h->sendbufCount = datatype->computeActiveElements(count);
10728 } else {
10729 h->sendbufCount = datatype->computeActiveElements(count);
10730 }
10731 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
10732 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
10733 if(root == getCommRank(comm)) {
10734 h->recvbufCount = datatype->computeActiveElements(count);
10735 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
10736 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
10737 }
10738
10739 // extract the primal values for the operator if required
10740 if(convOp.requiresPrimal) {
10741 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
10742 if(AMPI_IN_PLACE != sendbuf) {
10743 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
10744 } else {
10745 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
10746 }
10747 }
10748
10749 // extract the old primal values from the recv buffer if the AD tool
10750 // needs the primal values reset
10751 if(adType->isOldPrimalsRequired()) {
10752 if(root == getCommRank(comm)) {
10753 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
10754 if(root == getCommRank(comm)) {
10755 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
10756 }
10757 }
10758 }
10759
10760
10761 if(AMPI_IN_PLACE != sendbuf) {
10762 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
10763 } else {
10764 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
10765 }
10766
10767 if(root == getCommRank(comm)) {
10768 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
10769 }
10770
10771 // pack all the variables in the handle
10777 h->count = count;
10778 h->datatype = datatype;
10779 h->op = op;
10780 h->root = root;
10781 h->comm = comm;
10782 }
10783
10784 if(root == getCommRank(comm)) {
10785 if(!datatype->isModifiedBufferRequired()) {
10786 datatype->clearIndices(recvbuf, 0, count);
10787 }
10788 }
10789
10790 rStatus = MPI_Ireduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction,
10791 root, comm, &request->request);
10792
10794 asyncHandle->sendbuf = sendbuf;
10795 asyncHandle->sendbufMod = sendbufMod;
10796 asyncHandle->recvbuf = recvbuf;
10797 asyncHandle->recvbufMod = recvbufMod;
10798 asyncHandle->count = count;
10799 asyncHandle->datatype = datatype;
10800 asyncHandle->op = op;
10801 asyncHandle->root = root;
10802 asyncHandle->comm = comm;
10803 asyncHandle->toolHandle = h;
10804 request->handle = asyncHandle;
10806
10807 // create adjoint wait
10808 if(nullptr != h) {
10811 adType->addToolAction(waitH);
10812 }
10813 }
10814
10815 return rStatus;
10816 }
10817
10818 template<typename DATATYPE>
10820 int rStatus = 0;
10821
10823 (handle);
10824 MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf = asyncHandle->sendbuf;
10825 typename DATATYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
10826 typename DATATYPE::Type* recvbuf = asyncHandle->recvbuf;
10827 typename DATATYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
10828 int count = asyncHandle->count;
10829 DATATYPE* datatype = asyncHandle->datatype;
10830 AMPI_Op op = asyncHandle->op;
10831 int root = asyncHandle->root;
10832 AMPI_Comm comm = asyncHandle->comm;
10833 AMPI_Request* request = asyncHandle->request;
10835 (asyncHandle->toolHandle);
10836 ADToolInterface const* adType = selectADTool(datatype->getADTool());
10837 MEDI_UNUSED(h); // Unused generated to ignore warnings
10838 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
10839 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
10840 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
10841 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
10842 MEDI_UNUSED(count); // Unused generated to ignore warnings
10843 MEDI_UNUSED(datatype); // Unused generated to ignore warnings
10844 MEDI_UNUSED(op); // Unused generated to ignore warnings
10845 MEDI_UNUSED(root); // Unused generated to ignore warnings
10846 MEDI_UNUSED(comm); // Unused generated to ignore warnings
10847 MEDI_UNUSED(request); // Unused generated to ignore warnings
10848
10849 delete asyncHandle;
10850
10851 if(adType->isActiveType()) {
10852
10853 AMPI_Op convOp = adType->convertOperator(op);
10854 (void)convOp;
10855 adType->addToolAction(h);
10856
10857 if(root == getCommRank(comm)) {
10858 if(datatype->isModifiedBufferRequired()) {
10859 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
10860 }
10861 }
10862
10863 if(nullptr != h) {
10864 // handle the recv buffers
10865 if(root == getCommRank(comm)) {
10866 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
10867 }
10868 }
10869 // extract the primal values for the operator if required
10870 if(nullptr != h && convOp.requiresPrimal) {
10871 if(root == getCommRank(comm)) {
10872 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
10873 if(root == getCommRank(comm)) {
10874 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
10875 }
10876 }
10877 }
10878
10879 adType->stopAssembly(h);
10880
10881 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
10882 datatype->deleteModifiedTypeBuffer(sendbufMod);
10883 }
10884 if(root == getCommRank(comm)) {
10885 if(datatype->isModifiedBufferRequired() ) {
10886 datatype->deleteModifiedTypeBuffer(recvbufMod);
10887 }
10888 }
10889
10890 // handle is deleted by the AD tool
10891 }
10892
10893 return rStatus;
10894 }
10895
10896#endif
10897#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
10898 template<typename SENDTYPE, typename RECVTYPE>
10901 typename SENDTYPE::IndexType* sendbufIndices;
10902 typename SENDTYPE::PrimalType* sendbufPrimals;
10903 /* required for async */ void* sendbufAdjoints;
10907 SENDTYPE* sendtype;
10909 typename RECVTYPE::IndexType* recvbufIndices;
10910 typename RECVTYPE::PrimalType* recvbufPrimals;
10911 typename RECVTYPE::PrimalType* recvbufOldPrimals;
10912 /* required for async */ void* recvbufAdjoints;
10916 RECVTYPE* recvtype;
10917 int root;
10919
10921 if(nullptr != sendbufIndices) {
10922 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
10923 sendbufIndices = nullptr;
10924 }
10925 if(nullptr != sendbufPrimals) {
10926 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
10927 sendbufPrimals = nullptr;
10928 }
10929 if(nullptr != recvbufIndices) {
10930 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
10931 recvbufIndices = nullptr;
10932 }
10933 if(nullptr != recvbufPrimals) {
10934 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
10935 recvbufPrimals = nullptr;
10936 }
10937 if(nullptr != recvbufOldPrimals) {
10938 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
10939 recvbufOldPrimals = nullptr;
10940 }
10941 }
10942 };
10943
10944 template<typename SENDTYPE, typename RECVTYPE>
10946 const typename SENDTYPE::Type* sendbuf;
10947 typename SENDTYPE::ModifiedType* sendbufMod;
10949 SENDTYPE* sendtype;
10950 typename RECVTYPE::Type* recvbuf;
10951 typename RECVTYPE::ModifiedType* recvbufMod;
10953 RECVTYPE* recvtype;
10954 int root;
10957 };
10958
10959 template<typename SENDTYPE, typename RECVTYPE>
10960 void AMPI_Iscatter_p(HandleBase* handle, AdjointInterface* adjointInterface) {
10962 (handle);
10963 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10964 (void)adType;
10965
10966 h->recvbufAdjoints = nullptr;
10967 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
10968 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
10969 h->sendbufAdjoints = nullptr;
10970 if(h->root == getCommRank(h->comm)) {
10971 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
10972 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
10973 // Primal buffers are always linear in space so we can accesses them in one sweep
10974 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
10975
10976 }
10977
10980
10981 }
10982
10983 template<typename SENDTYPE, typename RECVTYPE>
10984 void AMPI_Iscatter_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
10985
10987 (handle);
10988 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
10989 (void)adType;
10990 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
10991
10992 if(h->root == getCommRank(h->comm)) {
10993 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
10994 }
10995 if(adType->isOldPrimalsRequired()) {
10996 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
10997 }
10998 // Primal buffers are always linear in space so we can accesses them in one sweep
10999 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
11000 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
11001 }
11002
11003 template<typename SENDTYPE, typename RECVTYPE>
11004 void AMPI_Iscatter_d(HandleBase* handle, AdjointInterface* adjointInterface) {
11006 (handle);
11007 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11008 (void)adType;
11009
11010 h->recvbufAdjoints = nullptr;
11011 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11012 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11013 h->sendbufAdjoints = nullptr;
11014 if(h->root == getCommRank(h->comm)) {
11015 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11016 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11017 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11018 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11019
11020 }
11021
11024
11025 }
11026
11027 template<typename SENDTYPE, typename RECVTYPE>
11028 void AMPI_Iscatter_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
11029
11031 (handle);
11032 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11033 (void)adType;
11034 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
11035
11036 if(h->root == getCommRank(h->comm)) {
11037 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11038 }
11039 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11040 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11041 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11042 }
11043
11044 template<typename SENDTYPE, typename RECVTYPE>
11045 void AMPI_Iscatter_b(HandleBase* handle, AdjointInterface* adjointInterface) {
11047 (handle);
11048 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11049 (void)adType;
11050
11051 h->recvbufAdjoints = nullptr;
11052 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11053 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11054 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11055 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11056
11057 if(adType->isOldPrimalsRequired()) {
11058 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11059 }
11060 h->sendbufAdjoints = nullptr;
11061 if(h->root == getCommRank(h->comm)) {
11062 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11063 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11064 }
11065
11068
11069 }
11070
11071 template<typename SENDTYPE, typename RECVTYPE>
11072 void AMPI_Iscatter_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
11073
11075 (handle);
11076 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11077 (void)adType;
11078 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
11079
11080 if(h->root == getCommRank(h->comm)) {
11081 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11082 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11083 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11084 }
11085 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11086 }
11087
11088 template<typename SENDTYPE, typename RECVTYPE>
11089 void AMPI_Iscatter_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
11091 (handle);
11092 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11093 (void)adType;
11094
11095 if(h->root == getCommRank(h->comm)) {
11096 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
11097 }
11098 }
11099
11100 template<typename SENDTYPE, typename RECVTYPE>
11101 void AMPI_Iscatter_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
11103 (handle);
11104 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11105 (void)adType;
11106
11107 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
11108 }
11109
11110 template<typename SENDTYPE, typename RECVTYPE>
11111 int AMPI_Iscatter_finish(HandleBase* handle);
11112 template<typename SENDTYPE, typename RECVTYPE>
11113 int AMPI_Iscatter(const typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
11114 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm, AMPI_Request* request) {
11115 int rStatus;
11116 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
11117
11118 if(!adType->isActiveType()) {
11119 // call the regular function if the type is not active
11120 rStatus = MPI_Iscatter(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
11121 comm, &request->request);
11122 } else {
11123
11124 // the type is an AD type so handle the buffers
11126 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
11127 int sendbufElements = 0;
11128
11129 if(root == getCommRank(comm)) {
11130 // compute the total size of the buffer
11131 sendbufElements = sendcount * getCommSize(comm);
11132
11133 if(sendtype->isModifiedBufferRequired() ) {
11134 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
11135 } else {
11136 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
11137 }
11138 }
11139 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
11140 int recvbufElements = 0;
11141
11142 // compute the total size of the buffer
11143 if(AMPI_IN_PLACE != recvbuf) {
11144 recvbufElements = recvcount;
11145 } else {
11146 recvbufElements = sendcount;
11147 }
11148
11149 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11150 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
11151 } else {
11152 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
11153 }
11154
11155 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
11156 if(adType->isHandleRequired()) {
11158 }
11159 adType->startAssembly(h);
11160 if(root == getCommRank(comm)) {
11161 if(sendtype->isModifiedBufferRequired()) {
11162 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
11163 }
11164 }
11165
11166 if(nullptr != h) {
11167 // gather the information for the reverse sweep
11168
11169 // create the index buffers
11170 if(root == getCommRank(comm)) {
11171 h->sendbufCount = sendtype->computeActiveElements(sendcount);
11172 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
11173 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
11174 }
11175 if(AMPI_IN_PLACE != recvbuf) {
11176 h->recvbufCount = recvtype->computeActiveElements(recvcount);
11177 } else {
11178 h->recvbufCount = sendtype->computeActiveElements(sendcount);
11179 }
11180 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
11181 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
11182
11183
11184 // extract the old primal values from the recv buffer if the AD tool
11185 // needs the primal values reset
11186 if(adType->isOldPrimalsRequired()) {
11187 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
11188 if(AMPI_IN_PLACE != recvbuf) {
11189 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
11190 } else {
11191 sendtype->getValues(sendbuf, sendcount * getCommRank(comm), h->recvbufOldPrimals, 0, sendcount);
11192 }
11193 }
11194
11195
11196 if(root == getCommRank(comm)) {
11197 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
11198 }
11199
11200 if(AMPI_IN_PLACE != recvbuf) {
11201 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
11202 } else {
11203 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
11204 0, sendcount);
11205 }
11206
11207 // pack all the variables in the handle
11213 h->sendcount = sendcount;
11214 h->sendtype = sendtype;
11215 h->recvcount = recvcount;
11216 h->recvtype = recvtype;
11217 h->root = root;
11218 h->comm = comm;
11219 }
11220
11221 if(!recvtype->isModifiedBufferRequired()) {
11222 if(AMPI_IN_PLACE != recvbuf) {
11223 recvtype->clearIndices(recvbuf, 0, recvcount);
11224 } else {
11225 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), sendcount);
11226 }
11227 }
11228
11229 rStatus = MPI_Iscatter(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
11230 recvtype->getModifiedMpiType(), root, comm, &request->request);
11231
11233 asyncHandle->sendbuf = sendbuf;
11234 asyncHandle->sendbufMod = sendbufMod;
11235 asyncHandle->sendcount = sendcount;
11236 asyncHandle->sendtype = sendtype;
11237 asyncHandle->recvbuf = recvbuf;
11238 asyncHandle->recvbufMod = recvbufMod;
11239 asyncHandle->recvcount = recvcount;
11240 asyncHandle->recvtype = recvtype;
11241 asyncHandle->root = root;
11242 asyncHandle->comm = comm;
11243 asyncHandle->toolHandle = h;
11244 request->handle = asyncHandle;
11246
11247 // create adjoint wait
11248 if(nullptr != h) {
11251 adType->addToolAction(waitH);
11252 }
11253 }
11254
11255 return rStatus;
11256 }
11257
11258 template<typename SENDTYPE, typename RECVTYPE>
11260 int rStatus = 0;
11261
11264 const typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
11265 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
11266 int sendcount = asyncHandle->sendcount;
11267 SENDTYPE* sendtype = asyncHandle->sendtype;
11268 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
11269 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
11270 int recvcount = asyncHandle->recvcount;
11271 RECVTYPE* recvtype = asyncHandle->recvtype;
11272 int root = asyncHandle->root;
11273 AMPI_Comm comm = asyncHandle->comm;
11274 AMPI_Request* request = asyncHandle->request;
11276 (asyncHandle->toolHandle);
11277 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
11278 MEDI_UNUSED(h); // Unused generated to ignore warnings
11279 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
11280 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
11281 MEDI_UNUSED(sendcount); // Unused generated to ignore warnings
11282 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
11283 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
11284 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
11285 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
11286 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
11287 MEDI_UNUSED(root); // Unused generated to ignore warnings
11288 MEDI_UNUSED(comm); // Unused generated to ignore warnings
11289 MEDI_UNUSED(request); // Unused generated to ignore warnings
11290
11291 delete asyncHandle;
11292
11293 if(adType->isActiveType()) {
11294
11295 adType->addToolAction(h);
11296
11297 if(recvtype->isModifiedBufferRequired()) {
11298 if(AMPI_IN_PLACE != recvbuf) {
11299 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
11300 } else {
11301 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm),
11302 sendbufMod, sendcount * getCommRank(comm), sendcount);
11303 }
11304 }
11305
11306 if(nullptr != h) {
11307 // handle the recv buffers
11308 if(AMPI_IN_PLACE != recvbuf) {
11309 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
11310 } else {
11311 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
11312 h->recvbufOldPrimals, 0, sendcount);
11313 }
11314 }
11315
11316 adType->stopAssembly(h);
11317
11318 if(root == getCommRank(comm)) {
11319 if(sendtype->isModifiedBufferRequired() ) {
11320 sendtype->deleteModifiedTypeBuffer(sendbufMod);
11321 }
11322 }
11323 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11324 recvtype->deleteModifiedTypeBuffer(recvbufMod);
11325 }
11326
11327 // handle is deleted by the AD tool
11328 }
11329
11330 return rStatus;
11331 }
11332
11333#endif
11334#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
11335 template<typename SENDTYPE, typename RECVTYPE>
11338 typename SENDTYPE::IndexType* sendbufIndices;
11339 typename SENDTYPE::PrimalType* sendbufPrimals;
11340 /* required for async */ void* sendbufAdjoints;
11342 /* required for async */ int* sendbufCountVec;
11343 /* required for async */ int* sendbufDisplsVec;
11344 const int* sendcounts;
11345 const int* displs;
11346 SENDTYPE* sendtype;
11348 typename RECVTYPE::IndexType* recvbufIndices;
11349 typename RECVTYPE::PrimalType* recvbufPrimals;
11350 typename RECVTYPE::PrimalType* recvbufOldPrimals;
11351 /* required for async */ void* recvbufAdjoints;
11355 RECVTYPE* recvtype;
11356 int root;
11358
11360 if(nullptr != sendbufIndices) {
11361 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
11362 sendbufIndices = nullptr;
11363 }
11364 if(nullptr != sendbufPrimals) {
11365 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
11366 sendbufPrimals = nullptr;
11367 }
11368 if(nullptr != sendbufCount) {
11369 delete [] sendbufCount;
11370 sendbufCount = nullptr;
11371 }
11372 if(nullptr != recvbufIndices) {
11373 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
11374 recvbufIndices = nullptr;
11375 }
11376 if(nullptr != recvbufPrimals) {
11377 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
11378 recvbufPrimals = nullptr;
11379 }
11380 if(nullptr != recvbufOldPrimals) {
11381 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
11382 recvbufOldPrimals = nullptr;
11383 }
11384 }
11385 };
11386
11387 template<typename SENDTYPE, typename RECVTYPE>
11389 const typename SENDTYPE::Type* sendbuf;
11390 typename SENDTYPE::ModifiedType* sendbufMod;
11391 const int* displsMod;
11392 const int* sendcounts;
11393 const int* displs;
11394 SENDTYPE* sendtype;
11395 typename RECVTYPE::Type* recvbuf;
11396 typename RECVTYPE::ModifiedType* recvbufMod;
11398 RECVTYPE* recvtype;
11399 int root;
11402 };
11403
11404 template<typename SENDTYPE, typename RECVTYPE>
11405 void AMPI_Iscatterv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
11407 (handle);
11408 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11409 (void)adType;
11410
11411 h->recvbufAdjoints = nullptr;
11412 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11413 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
11414 h->sendbufAdjoints = nullptr;
11415 if(h->root == getCommRank(h->comm)) {
11417 adjointInterface->getVectorSize());
11418 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
11419 // Primal buffers are always linear in space so we can accesses them in one sweep
11420 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
11421
11422 }
11423
11426 &h->requestReverse);
11427
11428 }
11429
11430 template<typename SENDTYPE, typename RECVTYPE>
11431 void AMPI_Iscatterv_p_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
11432
11434 (handle);
11435 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11436 (void)adType;
11437 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
11438
11439 if(h->root == getCommRank(h->comm)) {
11440 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
11441 delete [] h->sendbufCountVec;
11442 delete [] h->sendbufDisplsVec;
11443 }
11444 if(adType->isOldPrimalsRequired()) {
11445 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11446 }
11447 // Primal buffers are always linear in space so we can accesses them in one sweep
11448 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
11449 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
11450 }
11451
11452 template<typename SENDTYPE, typename RECVTYPE>
11453 void AMPI_Iscatterv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
11455 (handle);
11456 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11457 (void)adType;
11458
11459 h->recvbufAdjoints = nullptr;
11460 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11461 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11462 h->sendbufAdjoints = nullptr;
11463 if(h->root == getCommRank(h->comm)) {
11465 adjointInterface->getVectorSize());
11466 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11467 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11468 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11469
11470 }
11471
11474 &h->requestReverse);
11475
11476 }
11477
11478 template<typename SENDTYPE, typename RECVTYPE>
11479 void AMPI_Iscatterv_d_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
11480
11482 (handle);
11483 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11484 (void)adType;
11485 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
11486
11487 if(h->root == getCommRank(h->comm)) {
11488 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11489 delete [] h->sendbufCountVec;
11490 delete [] h->sendbufDisplsVec;
11491 }
11492 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11493 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11494 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11495 }
11496
11497 template<typename SENDTYPE, typename RECVTYPE>
11498 void AMPI_Iscatterv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
11500 (handle);
11501 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11502 (void)adType;
11503
11504 h->recvbufAdjoints = nullptr;
11505 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11506 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11507 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11508 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11509
11510 if(adType->isOldPrimalsRequired()) {
11511 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11512 }
11513 h->sendbufAdjoints = nullptr;
11514 if(h->root == getCommRank(h->comm)) {
11516 adjointInterface->getVectorSize());
11517 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11518 }
11519
11522 &h->requestReverse);
11523
11524 }
11525
11526 template<typename SENDTYPE, typename RECVTYPE>
11527 void AMPI_Iscatterv_b_finish(HandleBase* handle, AdjointInterface* adjointInterface) {
11528
11530 (handle);
11531 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11532 (void)adType;
11533 MPI_Wait(&h->requestReverse.request, MPI_STATUS_IGNORE);
11534
11535 if(h->root == getCommRank(h->comm)) {
11536 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11537 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11538 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11539 delete [] h->sendbufCountVec;
11540 delete [] h->sendbufDisplsVec;
11541 }
11542 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11543 }
11544
11545 template<typename SENDTYPE, typename RECVTYPE>
11546 void AMPI_Iscatterv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
11548 (handle);
11549 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11550 (void)adType;
11551
11552 if(h->root == getCommRank(h->comm)) {
11553 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
11554 }
11555 }
11556
11557 template<typename SENDTYPE, typename RECVTYPE>
11558 void AMPI_Iscatterv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
11560 (handle);
11561 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
11562 (void)adType;
11563
11564 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
11565 }
11566
11567 template<typename SENDTYPE, typename RECVTYPE>
11568 int AMPI_Iscatterv_finish(HandleBase* handle);
11569 template<typename SENDTYPE, typename RECVTYPE>
11570 int AMPI_Iscatterv(const typename SENDTYPE::Type* sendbuf, const int* sendcounts, const int* displs, SENDTYPE* sendtype,
11571 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm, AMPI_Request* request) {
11572 int rStatus;
11573 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
11574
11575 if(!adType->isActiveType()) {
11576 // call the regular function if the type is not active
11577 rStatus = MPI_Iscatterv(sendbuf, sendcounts, displs, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(),
11578 root, comm, &request->request);
11579 } else {
11580
11581 // the type is an AD type so handle the buffers
11583 MEDI_OPTIONAL_CONST int* displsMod = displs;
11584 int displsTotalSize = 0;
11585 if(nullptr != displs) {
11586 displsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
11587 if(recvtype->isModifiedBufferRequired()) {
11588 displsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
11589 }
11590 }
11591 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
11592 int sendbufElements = 0;
11593
11594 if(root == getCommRank(comm)) {
11595 // compute the total size of the buffer
11596 sendbufElements = displsTotalSize;
11597
11598 if(sendtype->isModifiedBufferRequired() ) {
11599 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
11600 } else {
11601 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
11602 }
11603 }
11604 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
11605 int recvbufElements = 0;
11606
11607 // compute the total size of the buffer
11608 if(AMPI_IN_PLACE != recvbuf) {
11609 recvbufElements = recvcount;
11610 } else {
11611 recvbufElements = sendcounts[getCommRank(comm)];
11612 }
11613
11614 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11615 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
11616 } else {
11617 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
11618 }
11619
11620 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
11621 if(adType->isHandleRequired()) {
11623 }
11624 adType->startAssembly(h);
11625 if(root == getCommRank(comm)) {
11626 if(sendtype->isModifiedBufferRequired()) {
11627 for(int i = 0; i < getCommSize(comm); ++i) {
11628 sendtype->copyIntoModifiedBuffer(sendbuf, displs[i], sendbufMod, displsMod[i], sendcounts[i]);
11629 }
11630 }
11631 }
11632
11633 if(nullptr != h) {
11634 // gather the information for the reverse sweep
11635
11636 // create the index buffers
11637 if(root == getCommRank(comm)) {
11638 createLinearIndexCounts(h->sendbufCount, sendcounts, displs, getCommSize(comm), sendtype);
11639 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
11640 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
11641 }
11642 if(AMPI_IN_PLACE != recvbuf) {
11643 h->recvbufCount = recvtype->computeActiveElements(recvcount);
11644 } else {
11645 h->recvbufCount = sendtype->computeActiveElements(displs[getCommRank(comm)] + sendcounts[getCommRank(
11646 comm)]) - sendtype->computeActiveElements(displs[getCommRank(comm)]);
11647 }
11648 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
11649 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
11650
11651
11652 // extract the old primal values from the recv buffer if the AD tool
11653 // needs the primal values reset
11654 if(adType->isOldPrimalsRequired()) {
11655 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
11656 if(AMPI_IN_PLACE != recvbuf) {
11657 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
11658 } else {
11659 {
11660 const int rank = getCommRank(comm);
11661 sendtype->getValues(sendbuf, displs[rank], h->recvbufOldPrimals, 0, sendcounts[rank]);
11662 }
11663 }
11664 }
11665
11666
11667 if(root == getCommRank(comm)) {
11668 for(int i = 0; i < getCommSize(comm); ++i) {
11669 sendtype->getIndices(sendbuf, displs[i], h->sendbufIndices, displsMod[i], sendcounts[i]);
11670 }
11671 }
11672
11673 if(AMPI_IN_PLACE != recvbuf) {
11674 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
11675 } else {
11676 {
11677 const int rank = getCommRank(comm);
11678 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices, 0,
11679 sendcounts[rank]);
11680 }
11681 }
11682
11683 // pack all the variables in the handle
11689 h->sendcounts = sendcounts;
11690 h->displs = displs;
11691 h->sendtype = sendtype;
11692 h->recvcount = recvcount;
11693 h->recvtype = recvtype;
11694 h->root = root;
11695 h->comm = comm;
11696 }
11697
11698 if(!recvtype->isModifiedBufferRequired()) {
11699 if(AMPI_IN_PLACE != recvbuf) {
11700 recvtype->clearIndices(recvbuf, 0, recvcount);
11701 } else {
11702 {
11703 const int rank = getCommRank(comm);
11704 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendcounts[rank]);
11705 }
11706 }
11707 }
11708
11709 rStatus = MPI_Iscatterv(sendbufMod, sendcounts, displsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
11710 recvtype->getModifiedMpiType(), root, comm, &request->request);
11711
11713 asyncHandle->sendbuf = sendbuf;
11714 asyncHandle->sendbufMod = sendbufMod;
11715 asyncHandle->displsMod = displsMod;
11716 asyncHandle->sendcounts = sendcounts;
11717 asyncHandle->displs = displs;
11718 asyncHandle->sendtype = sendtype;
11719 asyncHandle->recvbuf = recvbuf;
11720 asyncHandle->recvbufMod = recvbufMod;
11721 asyncHandle->recvcount = recvcount;
11722 asyncHandle->recvtype = recvtype;
11723 asyncHandle->root = root;
11724 asyncHandle->comm = comm;
11725 asyncHandle->toolHandle = h;
11726 request->handle = asyncHandle;
11728
11729 // create adjoint wait
11730 if(nullptr != h) {
11733 adType->addToolAction(waitH);
11734 }
11735 }
11736
11737 return rStatus;
11738 }
11739
11740 template<typename SENDTYPE, typename RECVTYPE>
11742 int rStatus = 0;
11743
11746 const typename SENDTYPE::Type* sendbuf = asyncHandle->sendbuf;
11747 typename SENDTYPE::ModifiedType* sendbufMod = asyncHandle->sendbufMod;
11748 const int* displsMod = asyncHandle->displsMod;
11749 const int* sendcounts = asyncHandle->sendcounts;
11750 const int* displs = asyncHandle->displs;
11751 SENDTYPE* sendtype = asyncHandle->sendtype;
11752 typename RECVTYPE::Type* recvbuf = asyncHandle->recvbuf;
11753 typename RECVTYPE::ModifiedType* recvbufMod = asyncHandle->recvbufMod;
11754 int recvcount = asyncHandle->recvcount;
11755 RECVTYPE* recvtype = asyncHandle->recvtype;
11756 int root = asyncHandle->root;
11757 AMPI_Comm comm = asyncHandle->comm;
11758 AMPI_Request* request = asyncHandle->request;
11760 (asyncHandle->toolHandle);
11761 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
11762 MEDI_UNUSED(h); // Unused generated to ignore warnings
11763 MEDI_UNUSED(sendbuf); // Unused generated to ignore warnings
11764 MEDI_UNUSED(sendbufMod); // Unused generated to ignore warnings
11765 MEDI_UNUSED(displsMod); // Unused generated to ignore warnings
11766 MEDI_UNUSED(sendcounts); // Unused generated to ignore warnings
11767 MEDI_UNUSED(displs); // Unused generated to ignore warnings
11768 MEDI_UNUSED(sendtype); // Unused generated to ignore warnings
11769 MEDI_UNUSED(recvbuf); // Unused generated to ignore warnings
11770 MEDI_UNUSED(recvbufMod); // Unused generated to ignore warnings
11771 MEDI_UNUSED(recvcount); // Unused generated to ignore warnings
11772 MEDI_UNUSED(recvtype); // Unused generated to ignore warnings
11773 MEDI_UNUSED(root); // Unused generated to ignore warnings
11774 MEDI_UNUSED(comm); // Unused generated to ignore warnings
11775 MEDI_UNUSED(request); // Unused generated to ignore warnings
11776
11777 delete asyncHandle;
11778
11779 if(adType->isActiveType()) {
11780
11781 adType->addToolAction(h);
11782
11783 if(recvtype->isModifiedBufferRequired()) {
11784 if(AMPI_IN_PLACE != recvbuf) {
11785 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
11786 } else {
11787 {
11788 const int rank = getCommRank(comm);
11789 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendbufMod,
11790 displsMod[rank], sendcounts[rank]);
11791 }
11792 }
11793 }
11794
11795 if(nullptr != h) {
11796 // handle the recv buffers
11797 if(AMPI_IN_PLACE != recvbuf) {
11798 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
11799 } else {
11800 {
11801 const int rank = getCommRank(comm);
11802 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices,
11803 h->recvbufOldPrimals, 0, sendcounts[rank]);
11804 }
11805 }
11806 }
11807
11808 adType->stopAssembly(h);
11809 if(recvtype->isModifiedBufferRequired()) {
11810 delete [] displsMod;
11811 }
11812
11813 if(root == getCommRank(comm)) {
11814 if(sendtype->isModifiedBufferRequired() ) {
11815 sendtype->deleteModifiedTypeBuffer(sendbufMod);
11816 }
11817 }
11818 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
11819 recvtype->deleteModifiedTypeBuffer(recvbufMod);
11820 }
11821
11822 // handle is deleted by the AD tool
11823 }
11824
11825 return rStatus;
11826 }
11827
11828#endif
11829#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
11830 template<typename DATATYPE>
11833 typename DATATYPE::IndexType* sendbufIndices;
11834 typename DATATYPE::PrimalType* sendbufPrimals;
11835 /* required for async */ void* sendbufAdjoints;
11839 typename DATATYPE::IndexType* recvbufIndices;
11840 typename DATATYPE::PrimalType* recvbufPrimals;
11841 typename DATATYPE::PrimalType* recvbufOldPrimals;
11842 /* required for async */ void* recvbufAdjoints;
11846 DATATYPE* datatype;
11848 int root;
11850
11852 if(nullptr != sendbufIndices) {
11853 datatype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
11854 sendbufIndices = nullptr;
11855 }
11856 if(nullptr != sendbufPrimals) {
11857 datatype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
11858 sendbufPrimals = nullptr;
11859 }
11860 if(nullptr != recvbufIndices) {
11861 datatype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
11862 recvbufIndices = nullptr;
11863 }
11864 if(nullptr != recvbufPrimals) {
11865 datatype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
11866 recvbufPrimals = nullptr;
11867 }
11868 if(nullptr != recvbufOldPrimals) {
11869 datatype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
11870 recvbufOldPrimals = nullptr;
11871 }
11872 }
11873 };
11874
11875
11876 template<typename DATATYPE>
11877 void AMPI_Reduce_global_p(HandleBase* handle, AdjointInterface* adjointInterface) {
11879 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11880 (void)adType;
11881
11882 AMPI_Op convOp = adType->convertOperator(h->op);
11883 (void)convOp;
11884 h->recvbufAdjoints = nullptr;
11885 if(h->root == getCommRank(h->comm)) {
11886 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11887 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
11888 }
11889 h->sendbufAdjoints = nullptr;
11890 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11891 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
11892 // Primal buffers are always linear in space so we can accesses them in one sweep
11893 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
11894
11895
11897 h->datatype, h->op, h->root, h->comm);
11898
11899 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
11900 if(adType->isOldPrimalsRequired()) {
11901 if(h->root == getCommRank(h->comm)) {
11902 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11903 }
11904 }
11905 if(h->root == getCommRank(h->comm)) {
11906 // Primal buffers are always linear in space so we can accesses them in one sweep
11907 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
11908 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
11909 }
11910 }
11911
11912 template<typename DATATYPE>
11913 void AMPI_Reduce_global_d(HandleBase* handle, AdjointInterface* adjointInterface) {
11915 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11916 (void)adType;
11917
11918 AMPI_Op convOp = adType->convertOperator(h->op);
11919 (void)convOp;
11920 h->recvbufAdjoints = nullptr;
11921 if(h->root == getCommRank(h->comm)) {
11922 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11923 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11924 }
11925 h->sendbufAdjoints = nullptr;
11926 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11927 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11928 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11929 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11930
11931
11933 h->count, h->datatype, h->op, h->root, h->comm);
11934
11935 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11936 if(h->root == getCommRank(h->comm)) {
11937 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11938 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11939 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11940 }
11941 }
11942
11943 template<typename DATATYPE>
11944 void AMPI_Reduce_global_b(HandleBase* handle, AdjointInterface* adjointInterface) {
11946 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11947 (void)adType;
11948
11949 AMPI_Op convOp = adType->convertOperator(h->op);
11950 (void)convOp;
11951 h->recvbufAdjoints = nullptr;
11952 if(h->root == getCommRank(h->comm)) {
11953 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
11954 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
11955 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11956 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
11957
11958 convOp.preAdjointOperation(h->recvbufAdjoints, h->recvbufPrimals, h->recvbufCount, adjointInterface->getVectorSize());
11959 }
11960 if(adType->isOldPrimalsRequired()) {
11961 if(h->root == getCommRank(h->comm)) {
11962 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
11963 }
11964 }
11965 h->sendbufAdjoints = nullptr;
11966 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
11967 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
11968
11970 h->count, h->datatype, h->op, h->root, h->comm);
11971
11972 // the primals of the recive buffer are always given to the function. The operator should ignore them if not needed.
11973 // The wrapper functions make sure that for operators that need the primals an all* action is perfomed (e.g. Allreduce instead of Reduce)
11975 adjointInterface->getVectorSize());
11976 // Adjoint buffers are always linear in space so we can accesses them in one sweep
11977 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
11978 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
11979 if(h->root == getCommRank(h->comm)) {
11980 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
11981 }
11982 }
11983
11984 template<typename DATATYPE>
11985 void AMPI_Reduce_global_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
11987 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11988 (void)adType;
11989
11990 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
11991 }
11992
11993 template<typename DATATYPE>
11994 void AMPI_Reduce_global_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
11996 ADToolInterface const* adType = selectADTool(h->datatype->getADTool());
11997 (void)adType;
11998
11999 if(h->root == getCommRank(h->comm)) {
12000 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
12001 }
12002 }
12003
12004 template<typename DATATYPE>
12005 int AMPI_Reduce_global(MEDI_OPTIONAL_CONST typename DATATYPE::Type* sendbuf, typename DATATYPE::Type* recvbuf,
12006 int count, DATATYPE* datatype, AMPI_Op op, int root, AMPI_Comm comm) {
12007 int rStatus;
12008 ADToolInterface const* adType = selectADTool(datatype->getADTool());
12009 AMPI_Op convOp = adType->convertOperator(op);
12010 (void)convOp;
12011
12012 if(!adType->isActiveType()) {
12013 // call the regular function if the type is not active
12014 rStatus = MPI_Reduce(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.primalFunction, root, comm);
12015 } else {
12016
12017 // the type is an AD type so handle the buffers
12019 typename DATATYPE::ModifiedType* sendbufMod = nullptr;
12020 int sendbufElements = 0;
12021
12022 // compute the total size of the buffer
12023 if(AMPI_IN_PLACE != sendbuf) {
12024 sendbufElements = count;
12025 } else {
12026 sendbufElements = count;
12027 }
12028
12029 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
12030 datatype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
12031 } else {
12032 sendbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(sendbuf));
12033 }
12034 typename DATATYPE::ModifiedType* recvbufMod = nullptr;
12035 int recvbufElements = 0;
12036
12037 if(root == getCommRank(comm)) {
12038 // compute the total size of the buffer
12039 recvbufElements = count;
12040
12041 if(datatype->isModifiedBufferRequired() ) {
12042 datatype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
12043 } else {
12044 recvbufMod = reinterpret_cast<typename DATATYPE::ModifiedType*>(const_cast<typename DATATYPE::Type*>(recvbuf));
12045 }
12046 }
12047
12048 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
12049 if(adType->isHandleRequired()) {
12051 }
12052 adType->startAssembly(h);
12053 if(datatype->isModifiedBufferRequired()) {
12054 if(AMPI_IN_PLACE != sendbuf) {
12055 datatype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, count);
12056 } else {
12057 datatype->copyIntoModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
12058 }
12059 }
12060
12061 if(nullptr != h) {
12062 // gather the information for the reverse sweep
12063
12064 // create the index buffers
12065 if(AMPI_IN_PLACE != sendbuf) {
12066 h->sendbufCount = datatype->computeActiveElements(count);
12067 } else {
12068 h->sendbufCount = datatype->computeActiveElements(count);
12069 }
12070 h->sendbufTotalSize = datatype->computeActiveElements(sendbufElements);
12071 datatype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
12072 if(root == getCommRank(comm)) {
12073 h->recvbufCount = datatype->computeActiveElements(count);
12074 h->recvbufTotalSize = datatype->computeActiveElements(recvbufElements);
12075 datatype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
12076 }
12077
12078 // extract the primal values for the operator if required
12079 if(convOp.requiresPrimal) {
12080 datatype->getADTool().createPrimalTypeBuffer(h->sendbufPrimals, h->sendbufTotalSize);
12081 if(AMPI_IN_PLACE != sendbuf) {
12082 datatype->getValues(sendbuf, 0, h->sendbufPrimals, 0, count);
12083 } else {
12084 datatype->getValues(recvbuf, 0, h->sendbufPrimals, 0, count);
12085 }
12086 }
12087
12088 // extract the old primal values from the recv buffer if the AD tool
12089 // needs the primal values reset
12090 if(adType->isOldPrimalsRequired()) {
12091 if(root == getCommRank(comm)) {
12092 datatype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
12093 if(root == getCommRank(comm)) {
12094 datatype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, count);
12095 }
12096 }
12097 }
12098
12099
12100 if(AMPI_IN_PLACE != sendbuf) {
12101 datatype->getIndices(sendbuf, 0, h->sendbufIndices, 0, count);
12102 } else {
12103 datatype->getIndices(recvbuf, 0, h->sendbufIndices, 0, count);
12104 }
12105
12106 if(root == getCommRank(comm)) {
12107 datatype->createIndices(recvbuf, 0, h->recvbufIndices, 0, count);
12108 }
12109
12110 // pack all the variables in the handle
12116 h->count = count;
12117 h->datatype = datatype;
12118 h->op = op;
12119 h->root = root;
12120 h->comm = comm;
12121 }
12122
12123 if(root == getCommRank(comm)) {
12124 if(!datatype->isModifiedBufferRequired()) {
12125 datatype->clearIndices(recvbuf, 0, count);
12126 }
12127 }
12128
12129 rStatus = MPI_Reduce(sendbufMod, recvbufMod, count, datatype->getModifiedMpiType(), convOp.modifiedPrimalFunction, root,
12130 comm);
12131 adType->addToolAction(h);
12132
12133 if(root == getCommRank(comm)) {
12134 if(datatype->isModifiedBufferRequired()) {
12135 datatype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, count);
12136 }
12137 }
12138
12139 if(nullptr != h) {
12140 // handle the recv buffers
12141 if(root == getCommRank(comm)) {
12142 datatype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, count);
12143 }
12144 }
12145 // extract the primal values for the operator if required
12146 if(nullptr != h && convOp.requiresPrimal) {
12147 if(root == getCommRank(comm)) {
12148 datatype->getADTool().createPrimalTypeBuffer(h->recvbufPrimals, h->recvbufTotalSize);
12149 if(root == getCommRank(comm)) {
12150 datatype->getValues(recvbuf, 0, h->recvbufPrimals, 0, count);
12151 }
12152 }
12153 }
12154
12155 adType->stopAssembly(h);
12156
12157 if(datatype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == sendbuf)) {
12158 datatype->deleteModifiedTypeBuffer(sendbufMod);
12159 }
12160 if(root == getCommRank(comm)) {
12161 if(datatype->isModifiedBufferRequired() ) {
12162 datatype->deleteModifiedTypeBuffer(recvbufMod);
12163 }
12164 }
12165
12166 // handle is deleted by the AD tool
12167 }
12168
12169 return rStatus;
12170 }
12171
12172#endif
12173#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12174 template<typename SENDTYPE, typename RECVTYPE>
12177 typename SENDTYPE::IndexType* sendbufIndices;
12178 typename SENDTYPE::PrimalType* sendbufPrimals;
12179 /* required for async */ void* sendbufAdjoints;
12183 SENDTYPE* sendtype;
12185 typename RECVTYPE::IndexType* recvbufIndices;
12186 typename RECVTYPE::PrimalType* recvbufPrimals;
12187 typename RECVTYPE::PrimalType* recvbufOldPrimals;
12188 /* required for async */ void* recvbufAdjoints;
12192 RECVTYPE* recvtype;
12193 int root;
12195
12197 if(nullptr != sendbufIndices) {
12198 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
12199 sendbufIndices = nullptr;
12200 }
12201 if(nullptr != sendbufPrimals) {
12202 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
12203 sendbufPrimals = nullptr;
12204 }
12205 if(nullptr != recvbufIndices) {
12206 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
12207 recvbufIndices = nullptr;
12208 }
12209 if(nullptr != recvbufPrimals) {
12210 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
12211 recvbufPrimals = nullptr;
12212 }
12213 if(nullptr != recvbufOldPrimals) {
12214 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
12215 recvbufOldPrimals = nullptr;
12216 }
12217 }
12218 };
12219
12220
12221 template<typename SENDTYPE, typename RECVTYPE>
12222 void AMPI_Scatter_p(HandleBase* handle, AdjointInterface* adjointInterface) {
12224 (handle);
12225 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12226 (void)adType;
12227
12228 h->recvbufAdjoints = nullptr;
12229 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
12230 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
12231 h->sendbufAdjoints = nullptr;
12232 if(h->root == getCommRank(h->comm)) {
12233 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
12234 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
12235 // Primal buffers are always linear in space so we can accesses them in one sweep
12236 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
12237
12238 }
12239
12241 h->recvbufPrimals, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
12242
12243 if(h->root == getCommRank(h->comm)) {
12244 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
12245 }
12246 if(adType->isOldPrimalsRequired()) {
12247 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
12248 }
12249 // Primal buffers are always linear in space so we can accesses them in one sweep
12250 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
12251 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
12252 }
12253
12254 template<typename SENDTYPE, typename RECVTYPE>
12255 void AMPI_Scatter_d(HandleBase* handle, AdjointInterface* adjointInterface) {
12257 (handle);
12258 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12259 (void)adType;
12260
12261 h->recvbufAdjoints = nullptr;
12262 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
12263 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
12264 h->sendbufAdjoints = nullptr;
12265 if(h->root == getCommRank(h->comm)) {
12266 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
12267 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
12268 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12269 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
12270
12271 }
12272
12275
12276 if(h->root == getCommRank(h->comm)) {
12277 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
12278 }
12279 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12280 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
12281 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
12282 }
12283
12284 template<typename SENDTYPE, typename RECVTYPE>
12285 void AMPI_Scatter_b(HandleBase* handle, AdjointInterface* adjointInterface) {
12287 (handle);
12288 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12289 (void)adType;
12290
12291 h->recvbufAdjoints = nullptr;
12292 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
12293 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
12294 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12295 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
12296
12297 if(adType->isOldPrimalsRequired()) {
12298 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
12299 }
12300 h->sendbufAdjoints = nullptr;
12301 if(h->root == getCommRank(h->comm)) {
12302 h->sendbufCountVec = adjointInterface->getVectorSize() * h->sendbufCount;
12303 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
12304 }
12305
12308
12309 if(h->root == getCommRank(h->comm)) {
12310 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12311 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
12312 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
12313 }
12314 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
12315 }
12316
12317 template<typename SENDTYPE, typename RECVTYPE>
12318 void AMPI_Scatter_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
12320 (handle);
12321 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12322 (void)adType;
12323
12324 if(h->root == getCommRank(h->comm)) {
12325 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
12326 }
12327 }
12328
12329 template<typename SENDTYPE, typename RECVTYPE>
12330 void AMPI_Scatter_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
12332 (handle);
12333 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12334 (void)adType;
12335
12336 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
12337 }
12338
12339 template<typename SENDTYPE, typename RECVTYPE>
12340 int AMPI_Scatter(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, int sendcount, SENDTYPE* sendtype,
12341 typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm) {
12342 int rStatus;
12343 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
12344
12345 if(!adType->isActiveType()) {
12346 // call the regular function if the type is not active
12347 rStatus = MPI_Scatter(sendbuf, sendcount, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(), root,
12348 comm);
12349 } else {
12350
12351 // the type is an AD type so handle the buffers
12353 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
12354 int sendbufElements = 0;
12355
12356 if(root == getCommRank(comm)) {
12357 // compute the total size of the buffer
12358 sendbufElements = sendcount * getCommSize(comm);
12359
12360 if(sendtype->isModifiedBufferRequired() ) {
12361 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
12362 } else {
12363 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
12364 }
12365 }
12366 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
12367 int recvbufElements = 0;
12368
12369 // compute the total size of the buffer
12370 if(AMPI_IN_PLACE != recvbuf) {
12371 recvbufElements = recvcount;
12372 } else {
12373 recvbufElements = sendcount;
12374 }
12375
12376 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
12377 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
12378 } else {
12379 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
12380 }
12381
12382 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
12383 if(adType->isHandleRequired()) {
12385 }
12386 adType->startAssembly(h);
12387 if(root == getCommRank(comm)) {
12388 if(sendtype->isModifiedBufferRequired()) {
12389 sendtype->copyIntoModifiedBuffer(sendbuf, 0, sendbufMod, 0, sendcount * getCommSize(comm));
12390 }
12391 }
12392
12393 if(nullptr != h) {
12394 // gather the information for the reverse sweep
12395
12396 // create the index buffers
12397 if(root == getCommRank(comm)) {
12398 h->sendbufCount = sendtype->computeActiveElements(sendcount);
12399 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
12400 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
12401 }
12402 if(AMPI_IN_PLACE != recvbuf) {
12403 h->recvbufCount = recvtype->computeActiveElements(recvcount);
12404 } else {
12405 h->recvbufCount = sendtype->computeActiveElements(sendcount);
12406 }
12407 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
12408 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
12409
12410
12411 // extract the old primal values from the recv buffer if the AD tool
12412 // needs the primal values reset
12413 if(adType->isOldPrimalsRequired()) {
12414 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
12415 if(AMPI_IN_PLACE != recvbuf) {
12416 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
12417 } else {
12418 sendtype->getValues(sendbuf, sendcount * getCommRank(comm), h->recvbufOldPrimals, 0, sendcount);
12419 }
12420 }
12421
12422
12423 if(root == getCommRank(comm)) {
12424 sendtype->getIndices(sendbuf, 0, h->sendbufIndices, 0, sendcount * getCommSize(comm));
12425 }
12426
12427 if(AMPI_IN_PLACE != recvbuf) {
12428 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
12429 } else {
12430 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
12431 0, sendcount);
12432 }
12433
12434 // pack all the variables in the handle
12440 h->sendcount = sendcount;
12441 h->sendtype = sendtype;
12442 h->recvcount = recvcount;
12443 h->recvtype = recvtype;
12444 h->root = root;
12445 h->comm = comm;
12446 }
12447
12448 if(!recvtype->isModifiedBufferRequired()) {
12449 if(AMPI_IN_PLACE != recvbuf) {
12450 recvtype->clearIndices(recvbuf, 0, recvcount);
12451 } else {
12452 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), sendcount);
12453 }
12454 }
12455
12456 rStatus = MPI_Scatter(sendbufMod, sendcount, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
12457 recvtype->getModifiedMpiType(), root, comm);
12458 adType->addToolAction(h);
12459
12460 if(recvtype->isModifiedBufferRequired()) {
12461 if(AMPI_IN_PLACE != recvbuf) {
12462 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
12463 } else {
12464 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm),
12465 sendbufMod, sendcount * getCommRank(comm), sendcount);
12466 }
12467 }
12468
12469 if(nullptr != h) {
12470 // handle the recv buffers
12471 if(AMPI_IN_PLACE != recvbuf) {
12472 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
12473 } else {
12474 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), sendcount * getCommRank(comm), h->recvbufIndices,
12475 h->recvbufOldPrimals, 0, sendcount);
12476 }
12477 }
12478
12479 adType->stopAssembly(h);
12480
12481 if(root == getCommRank(comm)) {
12482 if(sendtype->isModifiedBufferRequired() ) {
12483 sendtype->deleteModifiedTypeBuffer(sendbufMod);
12484 }
12485 }
12486 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
12487 recvtype->deleteModifiedTypeBuffer(recvbufMod);
12488 }
12489
12490 // handle is deleted by the AD tool
12491 }
12492
12493 return rStatus;
12494 }
12495
12496#endif
12497#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12498 template<typename SENDTYPE, typename RECVTYPE>
12501 typename SENDTYPE::IndexType* sendbufIndices;
12502 typename SENDTYPE::PrimalType* sendbufPrimals;
12503 /* required for async */ void* sendbufAdjoints;
12505 /* required for async */ int* sendbufCountVec;
12506 /* required for async */ int* sendbufDisplsVec;
12507 const int* sendcounts;
12508 const int* displs;
12509 SENDTYPE* sendtype;
12511 typename RECVTYPE::IndexType* recvbufIndices;
12512 typename RECVTYPE::PrimalType* recvbufPrimals;
12513 typename RECVTYPE::PrimalType* recvbufOldPrimals;
12514 /* required for async */ void* recvbufAdjoints;
12518 RECVTYPE* recvtype;
12519 int root;
12521
12523 if(nullptr != sendbufIndices) {
12524 sendtype->getADTool().deleteIndexTypeBuffer(sendbufIndices);
12525 sendbufIndices = nullptr;
12526 }
12527 if(nullptr != sendbufPrimals) {
12528 sendtype->getADTool().deletePrimalTypeBuffer(sendbufPrimals);
12529 sendbufPrimals = nullptr;
12530 }
12531 if(nullptr != sendbufCount) {
12532 delete [] sendbufCount;
12533 sendbufCount = nullptr;
12534 }
12535 if(nullptr != recvbufIndices) {
12536 recvtype->getADTool().deleteIndexTypeBuffer(recvbufIndices);
12537 recvbufIndices = nullptr;
12538 }
12539 if(nullptr != recvbufPrimals) {
12540 recvtype->getADTool().deletePrimalTypeBuffer(recvbufPrimals);
12541 recvbufPrimals = nullptr;
12542 }
12543 if(nullptr != recvbufOldPrimals) {
12544 recvtype->getADTool().deletePrimalTypeBuffer(recvbufOldPrimals);
12545 recvbufOldPrimals = nullptr;
12546 }
12547 }
12548 };
12549
12550
12551 template<typename SENDTYPE, typename RECVTYPE>
12552 void AMPI_Scatterv_p(HandleBase* handle, AdjointInterface* adjointInterface) {
12554 (handle);
12555 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12556 (void)adType;
12557
12558 h->recvbufAdjoints = nullptr;
12559 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
12560 adjointInterface->createPrimalTypeBuffer((void*&)h->recvbufPrimals, h->recvbufTotalSize );
12561 h->sendbufAdjoints = nullptr;
12562 if(h->root == getCommRank(h->comm)) {
12564 adjointInterface->getVectorSize());
12565 adjointInterface->createPrimalTypeBuffer((void*&)h->sendbufPrimals, h->sendbufTotalSize );
12566 // Primal buffers are always linear in space so we can accesses them in one sweep
12567 adjointInterface->getPrimals(h->sendbufIndices, h->sendbufPrimals, h->sendbufTotalSize);
12568
12569 }
12570
12572 h->displs, h->sendtype, h->recvbufPrimals, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
12573
12574 if(h->root == getCommRank(h->comm)) {
12575 adjointInterface->deletePrimalTypeBuffer((void*&)h->sendbufPrimals);
12576 delete [] h->sendbufCountVec;
12577 delete [] h->sendbufDisplsVec;
12578 }
12579 if(adType->isOldPrimalsRequired()) {
12580 adjointInterface->getPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
12581 }
12582 // Primal buffers are always linear in space so we can accesses them in one sweep
12583 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufPrimals, h->recvbufTotalSize);
12584 adjointInterface->deletePrimalTypeBuffer((void*&)h->recvbufPrimals);
12585 }
12586
12587 template<typename SENDTYPE, typename RECVTYPE>
12588 void AMPI_Scatterv_d(HandleBase* handle, AdjointInterface* adjointInterface) {
12590 (handle);
12591 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12592 (void)adType;
12593
12594 h->recvbufAdjoints = nullptr;
12595 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
12596 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
12597 h->sendbufAdjoints = nullptr;
12598 if(h->root == getCommRank(h->comm)) {
12600 adjointInterface->getVectorSize());
12601 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
12602 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12603 adjointInterface->getAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
12604
12605 }
12606
12608 h->displs, h->sendtype, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
12609
12610 if(h->root == getCommRank(h->comm)) {
12611 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
12612 delete [] h->sendbufCountVec;
12613 delete [] h->sendbufDisplsVec;
12614 }
12615 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12616 adjointInterface->updateAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
12617 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
12618 }
12619
12620 template<typename SENDTYPE, typename RECVTYPE>
12621 void AMPI_Scatterv_b(HandleBase* handle, AdjointInterface* adjointInterface) {
12623 (handle);
12624 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12625 (void)adType;
12626
12627 h->recvbufAdjoints = nullptr;
12628 h->recvbufCountVec = adjointInterface->getVectorSize() * h->recvbufCount;
12629 adjointInterface->createAdjointTypeBuffer(h->recvbufAdjoints, h->recvbufTotalSize );
12630 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12631 adjointInterface->getAdjoints(h->recvbufIndices, h->recvbufAdjoints, h->recvbufTotalSize);
12632
12633 if(adType->isOldPrimalsRequired()) {
12634 adjointInterface->setPrimals(h->recvbufIndices, h->recvbufOldPrimals, h->recvbufTotalSize);
12635 }
12636 h->sendbufAdjoints = nullptr;
12637 if(h->root == getCommRank(h->comm)) {
12639 adjointInterface->getVectorSize());
12640 adjointInterface->createAdjointTypeBuffer(h->sendbufAdjoints, h->sendbufTotalSize );
12641 }
12642
12644 h->displs, h->sendtype, h->recvbufAdjoints, h->recvbufCountVec, h->recvcount, h->recvtype, h->root, h->comm);
12645
12646 if(h->root == getCommRank(h->comm)) {
12647 // Adjoint buffers are always linear in space so we can accesses them in one sweep
12648 adjointInterface->updateAdjoints(h->sendbufIndices, h->sendbufAdjoints, h->sendbufTotalSize);
12649 adjointInterface->deleteAdjointTypeBuffer(h->sendbufAdjoints);
12650 delete [] h->sendbufCountVec;
12651 delete [] h->sendbufDisplsVec;
12652 }
12653 adjointInterface->deleteAdjointTypeBuffer(h->recvbufAdjoints);
12654 }
12655
12656 template<typename SENDTYPE, typename RECVTYPE>
12657 void AMPI_Scatterv_iterIn(HandleBase* handle, CallbackFunc func, void* userData) {
12659 (handle);
12660 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12661 (void)adType;
12662
12663 if(h->root == getCommRank(h->comm)) {
12664 adType->iterateIdentifiers(h->sendbufIndices, h->sendbufTotalSize, func, userData);
12665 }
12666 }
12667
12668 template<typename SENDTYPE, typename RECVTYPE>
12669 void AMPI_Scatterv_iterOut(HandleBase* handle, CallbackFunc func, void* userData) {
12671 (handle);
12672 ADToolInterface const* adType = selectADTool(h->sendtype->getADTool(), h->recvtype->getADTool());
12673 (void)adType;
12674
12675 adType->iterateIdentifiers(h->recvbufIndices, h->recvbufTotalSize, func, userData);
12676 }
12677
12678 template<typename SENDTYPE, typename RECVTYPE>
12679 int AMPI_Scatterv(MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf, const int* sendcounts, const int* displs,
12680 SENDTYPE* sendtype, typename RECVTYPE::Type* recvbuf, int recvcount, RECVTYPE* recvtype, int root, AMPI_Comm comm) {
12681 int rStatus;
12682 ADToolInterface const* adType = selectADTool(sendtype->getADTool(), recvtype->getADTool());
12683
12684 if(!adType->isActiveType()) {
12685 // call the regular function if the type is not active
12686 rStatus = MPI_Scatterv(sendbuf, sendcounts, displs, sendtype->getMpiType(), recvbuf, recvcount, recvtype->getMpiType(),
12687 root, comm);
12688 } else {
12689
12690 // the type is an AD type so handle the buffers
12692 MEDI_OPTIONAL_CONST int* displsMod = displs;
12693 int displsTotalSize = 0;
12694 if(nullptr != displs) {
12695 displsTotalSize = computeDisplacementsTotalSize(sendcounts, getCommSize(comm));
12696 if(recvtype->isModifiedBufferRequired()) {
12697 displsMod = createLinearDisplacements(sendcounts, getCommSize(comm));
12698 }
12699 }
12700 typename SENDTYPE::ModifiedType* sendbufMod = nullptr;
12701 int sendbufElements = 0;
12702
12703 if(root == getCommRank(comm)) {
12704 // compute the total size of the buffer
12705 sendbufElements = displsTotalSize;
12706
12707 if(sendtype->isModifiedBufferRequired() ) {
12708 sendtype->createModifiedTypeBuffer(sendbufMod, sendbufElements);
12709 } else {
12710 sendbufMod = reinterpret_cast<typename SENDTYPE::ModifiedType*>(const_cast<typename SENDTYPE::Type*>(sendbuf));
12711 }
12712 }
12713 typename RECVTYPE::ModifiedType* recvbufMod = nullptr;
12714 int recvbufElements = 0;
12715
12716 // compute the total size of the buffer
12717 if(AMPI_IN_PLACE != recvbuf) {
12718 recvbufElements = recvcount;
12719 } else {
12720 recvbufElements = sendcounts[getCommRank(comm)];
12721 }
12722
12723 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
12724 recvtype->createModifiedTypeBuffer(recvbufMod, recvbufElements);
12725 } else {
12726 recvbufMod = reinterpret_cast<typename RECVTYPE::ModifiedType*>(const_cast<typename RECVTYPE::Type*>(recvbuf));
12727 }
12728
12729 // the handle is created if a reverse action should be recorded, h != nullptr => tape is active
12730 if(adType->isHandleRequired()) {
12732 }
12733 adType->startAssembly(h);
12734 if(root == getCommRank(comm)) {
12735 if(sendtype->isModifiedBufferRequired()) {
12736 for(int i = 0; i < getCommSize(comm); ++i) {
12737 sendtype->copyIntoModifiedBuffer(sendbuf, displs[i], sendbufMod, displsMod[i], sendcounts[i]);
12738 }
12739 }
12740 }
12741
12742 if(nullptr != h) {
12743 // gather the information for the reverse sweep
12744
12745 // create the index buffers
12746 if(root == getCommRank(comm)) {
12747 createLinearIndexCounts(h->sendbufCount, sendcounts, displs, getCommSize(comm), sendtype);
12748 h->sendbufTotalSize = sendtype->computeActiveElements(sendbufElements);
12749 sendtype->getADTool().createIndexTypeBuffer(h->sendbufIndices, h->sendbufTotalSize);
12750 }
12751 if(AMPI_IN_PLACE != recvbuf) {
12752 h->recvbufCount = recvtype->computeActiveElements(recvcount);
12753 } else {
12754 h->recvbufCount = sendtype->computeActiveElements(displs[getCommRank(comm)] + sendcounts[getCommRank(
12755 comm)]) - sendtype->computeActiveElements(displs[getCommRank(comm)]);
12756 }
12757 h->recvbufTotalSize = recvtype->computeActiveElements(recvbufElements);
12758 recvtype->getADTool().createIndexTypeBuffer(h->recvbufIndices, h->recvbufTotalSize);
12759
12760
12761 // extract the old primal values from the recv buffer if the AD tool
12762 // needs the primal values reset
12763 if(adType->isOldPrimalsRequired()) {
12764 recvtype->getADTool().createPrimalTypeBuffer(h->recvbufOldPrimals, h->recvbufTotalSize);
12765 if(AMPI_IN_PLACE != recvbuf) {
12766 recvtype->getValues(recvbuf, 0, h->recvbufOldPrimals, 0, recvcount);
12767 } else {
12768 {
12769 const int rank = getCommRank(comm);
12770 sendtype->getValues(sendbuf, displs[rank], h->recvbufOldPrimals, 0, sendcounts[rank]);
12771 }
12772 }
12773 }
12774
12775
12776 if(root == getCommRank(comm)) {
12777 for(int i = 0; i < getCommSize(comm); ++i) {
12778 sendtype->getIndices(sendbuf, displs[i], h->sendbufIndices, displsMod[i], sendcounts[i]);
12779 }
12780 }
12781
12782 if(AMPI_IN_PLACE != recvbuf) {
12783 recvtype->createIndices(recvbuf, 0, h->recvbufIndices, 0, recvcount);
12784 } else {
12785 {
12786 const int rank = getCommRank(comm);
12787 sendtype->createIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices, 0,
12788 sendcounts[rank]);
12789 }
12790 }
12791
12792 // pack all the variables in the handle
12798 h->sendcounts = sendcounts;
12799 h->displs = displs;
12800 h->sendtype = sendtype;
12801 h->recvcount = recvcount;
12802 h->recvtype = recvtype;
12803 h->root = root;
12804 h->comm = comm;
12805 }
12806
12807 if(!recvtype->isModifiedBufferRequired()) {
12808 if(AMPI_IN_PLACE != recvbuf) {
12809 recvtype->clearIndices(recvbuf, 0, recvcount);
12810 } else {
12811 {
12812 const int rank = getCommRank(comm);
12813 sendtype->clearIndices(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendcounts[rank]);
12814 }
12815 }
12816 }
12817
12818 rStatus = MPI_Scatterv(sendbufMod, sendcounts, displsMod, sendtype->getModifiedMpiType(), recvbufMod, recvcount,
12819 recvtype->getModifiedMpiType(), root, comm);
12820 adType->addToolAction(h);
12821
12822 if(recvtype->isModifiedBufferRequired()) {
12823 if(AMPI_IN_PLACE != recvbuf) {
12824 recvtype->copyFromModifiedBuffer(recvbuf, 0, recvbufMod, 0, recvcount);
12825 } else {
12826 {
12827 const int rank = getCommRank(comm);
12828 sendtype->copyFromModifiedBuffer(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], sendbufMod,
12829 displsMod[rank], sendcounts[rank]);
12830 }
12831 }
12832 }
12833
12834 if(nullptr != h) {
12835 // handle the recv buffers
12836 if(AMPI_IN_PLACE != recvbuf) {
12837 recvtype->registerValue(recvbuf, 0, h->recvbufIndices, h->recvbufOldPrimals, 0, recvcount);
12838 } else {
12839 {
12840 const int rank = getCommRank(comm);
12841 sendtype->registerValue(const_cast<typename SENDTYPE::Type*>(sendbuf), displs[rank], h->recvbufIndices,
12842 h->recvbufOldPrimals, 0, sendcounts[rank]);
12843 }
12844 }
12845 }
12846
12847 adType->stopAssembly(h);
12848 if(recvtype->isModifiedBufferRequired()) {
12849 delete [] displsMod;
12850 }
12851
12852 if(root == getCommRank(comm)) {
12853 if(sendtype->isModifiedBufferRequired() ) {
12854 sendtype->deleteModifiedTypeBuffer(sendbufMod);
12855 }
12856 }
12857 if(recvtype->isModifiedBufferRequired() && !(AMPI_IN_PLACE == recvbuf)) {
12858 recvtype->deleteModifiedTypeBuffer(recvbufMod);
12859 }
12860
12861 // handle is deleted by the AD tool
12862 }
12863
12864 return rStatus;
12865 }
12866
12867#endif
12868
12869#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12870 inline int AMPI_Buffer_attach(void* buffer, int size) {
12871 return MPI_Buffer_attach(buffer, size);
12872 }
12873
12874#endif
12875#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12876 inline int AMPI_Buffer_detach(void* buffer_addr, int* size) {
12877 return MPI_Buffer_detach(buffer_addr, size);
12878 }
12879
12880#endif
12881#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12882 inline int AMPI_Cancel(AMPI_Request* request) {
12883 return MPI_Cancel(&request->request);
12884 }
12885
12886#endif
12887#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12888 template<typename DATATYPE>
12889 inline int AMPI_Get_count(MEDI_OPTIONAL_CONST AMPI_Status* status, DATATYPE* datatype, int* count) {
12890 return MPI_Get_count(status, datatype->getModifiedMpiType(), count);
12891 }
12892
12893#endif
12894#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12895 inline int AMPI_Iprobe(int source, int tag, AMPI_Comm comm, int* flag, AMPI_Status* status) {
12896 return MPI_Iprobe(source, tag, comm, flag, status);
12897 }
12898
12899#endif
12900#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12901 inline int AMPI_Probe(int source, int tag, AMPI_Comm comm, AMPI_Status* status) {
12902 return MPI_Probe(source, tag, comm, status);
12903 }
12904
12905#endif
12906#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12907 inline int AMPI_Request_get_status(AMPI_Request request, int* flag, AMPI_Status* status) {
12908 return MPI_Request_get_status(request.request, flag, status);
12909 }
12910
12911#endif
12912#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12913 inline int AMPI_Test_cancelled(MEDI_OPTIONAL_CONST AMPI_Status* status, int* flag) {
12914 return MPI_Test_cancelled(status, flag);
12915 }
12916
12917#endif
12918#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
12919 inline MPI_Aint AMPI_Aint_add(AMPI_Aint base, AMPI_Aint disp) {
12920 return MPI_Aint_add(base, disp);
12921 }
12922
12923#endif
12924#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
12925 inline MPI_Aint AMPI_Aint_diff(AMPI_Aint addr1, AMPI_Aint addr2) {
12926 return MPI_Aint_diff(addr1, addr2);
12927 }
12928
12929#endif
12930#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12931 inline int AMPI_Get_address(MEDI_OPTIONAL_CONST void* location, AMPI_Aint* address) {
12932 return MPI_Get_address(location, address);
12933 }
12934
12935#endif
12936#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12937 template<typename DATATYPE>
12938 inline int AMPI_Get_elements(const AMPI_Status* status, DATATYPE* datatype, int* count) {
12939 return MPI_Get_elements(status, datatype->getModifiedMpiType(), count);
12940 }
12941
12942#endif
12943#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12944 template<typename DATATYPE>
12945 inline int AMPI_Get_elements_x(const AMPI_Status* status, DATATYPE* datatype, AMPI_Count* count) {
12946 return MPI_Get_elements_x(status, datatype->getModifiedMpiType(), count);
12947 }
12948
12949#endif
12950#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12951 template<typename DATATYPE>
12952 inline int AMPI_Type_get_contents(DATATYPE* datatype, int max_integers, int max_addresses, int max_datatypes,
12953 int* array_of_integers, AMPI_Aint* array_of_addresses, AMPI_Datatype* array_of_datatypes) {
12954 return MPI_Type_get_contents(datatype->getModifiedMpiType(), max_integers, max_addresses, max_datatypes,
12955 array_of_integers, array_of_addresses, array_of_datatypes);
12956 }
12957
12958#endif
12959#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12960 template<typename DATATYPE>
12961 inline int AMPI_Type_get_envelope(DATATYPE* datatype, int* num_integers, int* num_addresses, int* num_datatypes,
12962 int* combiner) {
12963 return MPI_Type_get_envelope(datatype->getModifiedMpiType(), num_integers, num_addresses, num_datatypes, combiner);
12964 }
12965
12966#endif
12967#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12968 template<typename DATATYPE>
12969 inline int AMPI_Type_get_extent(DATATYPE* datatype, AMPI_Aint* lb, AMPI_Aint* extent) {
12970 return MPI_Type_get_extent(datatype->getModifiedMpiType(), lb, extent);
12971 }
12972
12973#endif
12974#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12975 template<typename DATATYPE>
12976 inline int AMPI_Type_get_extent_x(DATATYPE* datatype, AMPI_Count* lb, AMPI_Count* extent) {
12977 return MPI_Type_get_extent_x(datatype->getModifiedMpiType(), lb, extent);
12978 }
12979
12980#endif
12981#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
12982 template<typename DATATYPE>
12983 inline int AMPI_Type_get_true_extent(DATATYPE* datatype, AMPI_Aint* true_lb, AMPI_Aint* true_extent) {
12984 return MPI_Type_get_true_extent(datatype->getModifiedMpiType(), true_lb, true_extent);
12985 }
12986
12987#endif
12988#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
12989 template<typename DATATYPE>
12990 inline int AMPI_Type_get_true_extent_x(DATATYPE* datatype, AMPI_Count* true_lb, AMPI_Count* true_extent) {
12991 return MPI_Type_get_true_extent_x(datatype->getModifiedMpiType(), true_lb, true_extent);
12992 }
12993
12994#endif
12995#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
12996 template<typename DATATYPE>
12997 inline int AMPI_Type_size(DATATYPE* datatype, int* size) {
12998 return MPI_Type_size(datatype->getModifiedMpiType(), size);
12999 }
13000
13001#endif
13002#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13003 template<typename DATATYPE>
13004 inline int AMPI_Type_size_x(DATATYPE* datatype, AMPI_Count* size) {
13005 return MPI_Type_size_x(datatype->getModifiedMpiType(), size);
13006 }
13007
13008#endif
13009#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13010 inline int AMPI_Barrier(AMPI_Comm comm) {
13011 return MPI_Barrier(comm);
13012 }
13013
13014#endif
13015#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13016 inline int AMPI_Op_commutative(AMPI_Op op, int* commute) {
13017 AMPI_Op convOp = op;
13018 (void)convOp;
13019 return MPI_Op_commutative(convOp.modifiedPrimalFunction, commute);
13020 }
13021
13022#endif
13023#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13024 inline int AMPI_Comm_compare(AMPI_Comm comm1, AMPI_Comm comm2, int* result) {
13025 return MPI_Comm_compare(comm1, comm2, result);
13026 }
13027
13028#endif
13029#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13030 inline int AMPI_Comm_create(AMPI_Comm comm, AMPI_Group group, AMPI_Comm* newcomm) {
13031 return MPI_Comm_create(comm, group, newcomm);
13032 }
13033
13034#endif
13035#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13036 inline int AMPI_Comm_create_group(AMPI_Comm comm, AMPI_Group group, int tag, AMPI_Comm* newcomm) {
13037 return MPI_Comm_create_group(comm, group, tag, newcomm);
13038 }
13039
13040#endif
13041#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13043 AMPI_Comm_delete_attr_function* comm_delete_attr_fn, int* comm_keyval, void* extra_state) {
13044 return MPI_Comm_create_keyval(comm_copy_attr_fn, comm_delete_attr_fn, comm_keyval, extra_state);
13045 }
13046
13047#endif
13048#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13049 inline int AMPI_Comm_delete_attr(AMPI_Comm comm, int comm_keyval) {
13050 return MPI_Comm_delete_attr(comm, comm_keyval);
13051 }
13052
13053#endif
13054#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13055 inline int AMPI_Comm_dup(AMPI_Comm comm, AMPI_Comm* newcomm) {
13056 return MPI_Comm_dup(comm, newcomm);
13057 }
13058
13059#endif
13060#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13061 inline int AMPI_Comm_dup_with_info(AMPI_Comm comm, AMPI_Info info, AMPI_Comm* newcomm) {
13062 return MPI_Comm_dup_with_info(comm, info, newcomm);
13063 }
13064
13065#endif
13066#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13067 inline int AMPI_Comm_free(AMPI_Comm* comm) {
13068 return MPI_Comm_free(comm);
13069 }
13070
13071#endif
13072#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13073 inline int AMPI_Comm_free_keyval(int* comm_keyval) {
13074 return MPI_Comm_free_keyval(comm_keyval);
13075 }
13076
13077#endif
13078#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13079 inline int AMPI_Comm_get_attr(AMPI_Comm comm, int comm_keyval, void* attribute_val, int* flag) {
13080 return MPI_Comm_get_attr(comm, comm_keyval, attribute_val, flag);
13081 }
13082
13083#endif
13084#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13085 inline int AMPI_Comm_get_info(AMPI_Comm comm, AMPI_Info* info_used) {
13086 return MPI_Comm_get_info(comm, info_used);
13087 }
13088
13089#endif
13090#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13091 inline int AMPI_Comm_get_name(AMPI_Comm comm, char* comm_name, int* resultlen) {
13092 return MPI_Comm_get_name(comm, comm_name, resultlen);
13093 }
13094
13095#endif
13096#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13097 inline int AMPI_Comm_group(AMPI_Comm comm, AMPI_Group* group) {
13098 return MPI_Comm_group(comm, group);
13099 }
13100
13101#endif
13102#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13103 inline int AMPI_Comm_idup(AMPI_Comm comm, AMPI_Comm* newcomm, AMPI_Request* request) {
13104 return MPI_Comm_idup(comm, newcomm, &request->request);
13105 }
13106
13107#endif
13108#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13109 inline int AMPI_Comm_rank(AMPI_Comm comm, int* rank) {
13110 return MPI_Comm_rank(comm, rank);
13111 }
13112
13113#endif
13114#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13116 return MPI_Comm_remote_group(comm, group);
13117 }
13118
13119#endif
13120#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13121 inline int AMPI_Comm_remote_size(AMPI_Comm comm, int* size) {
13122 return MPI_Comm_remote_size(comm, size);
13123 }
13124
13125#endif
13126#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13127 inline int AMPI_Comm_set_attr(AMPI_Comm comm, int comm_keyval, void* attribute_val) {
13128 return MPI_Comm_set_attr(comm, comm_keyval, attribute_val);
13129 }
13130
13131#endif
13132#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13133 inline int AMPI_Comm_set_info(AMPI_Comm comm, AMPI_Info info) {
13134 return MPI_Comm_set_info(comm, info);
13135 }
13136
13137#endif
13138#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13139 inline int AMPI_Comm_set_name(AMPI_Comm comm, MEDI_OPTIONAL_CONST char* comm_name) {
13140 return MPI_Comm_set_name(comm, comm_name);
13141 }
13142
13143#endif
13144#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13145 inline int AMPI_Comm_size(AMPI_Comm comm, int* size) {
13146 return MPI_Comm_size(comm, size);
13147 }
13148
13149#endif
13150#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13151 inline int AMPI_Comm_split(AMPI_Comm comm, int color, int key, AMPI_Comm* newcomm) {
13152 return MPI_Comm_split(comm, color, key, newcomm);
13153 }
13154
13155#endif
13156#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13157 inline int AMPI_Comm_split_type(AMPI_Comm comm, int split_type, int key, AMPI_Info info, AMPI_Comm* newcomm) {
13158 return MPI_Comm_split_type(comm, split_type, key, info, newcomm);
13159 }
13160
13161#endif
13162#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13163 inline int AMPI_Comm_test_inter(AMPI_Comm comm, int* flag) {
13164 return MPI_Comm_test_inter(comm, flag);
13165 }
13166
13167#endif
13168#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13169 inline int AMPI_Group_compare(AMPI_Group group1, AMPI_Group group2, int* result) {
13170 return MPI_Group_compare(group1, group2, result);
13171 }
13172
13173#endif
13174#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13175 inline int AMPI_Group_difference(AMPI_Group group1, AMPI_Group group2, AMPI_Group* newgroup) {
13176 return MPI_Group_difference(group1, group2, newgroup);
13177 }
13178
13179#endif
13180#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13181 inline int AMPI_Group_excl(AMPI_Group group, int n, MEDI_OPTIONAL_CONST int* ranks, AMPI_Group* newgroup) {
13182 return MPI_Group_excl(group, n, ranks, newgroup);
13183 }
13184
13185#endif
13186#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13187 inline int AMPI_Group_free(AMPI_Group* group) {
13188 return MPI_Group_free(group);
13189 }
13190
13191#endif
13192#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13193 inline int AMPI_Group_incl(AMPI_Group group, int n, MEDI_OPTIONAL_CONST int* ranks, AMPI_Group* newgroup) {
13194 return MPI_Group_incl(group, n, ranks, newgroup);
13195 }
13196
13197#endif
13198#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13199 inline int AMPI_Group_intersection(AMPI_Group group1, AMPI_Group group2, AMPI_Group* newgroup) {
13200 return MPI_Group_intersection(group1, group2, newgroup);
13201 }
13202
13203#endif
13204#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13205 inline int AMPI_Group_range_excl(AMPI_Group group, int n, ::medi::common::Range* ranges, AMPI_Group* newgroup) {
13206 return MPI_Group_range_excl(group, n, ranges, newgroup);
13207 }
13208
13209#endif
13210#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13211 inline int AMPI_Group_range_incl(AMPI_Group group, int n, ::medi::common::Range* ranges, AMPI_Group* newgroup) {
13212 return MPI_Group_range_incl(group, n, ranges, newgroup);
13213 }
13214
13215#endif
13216#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13217 inline int AMPI_Group_rank(AMPI_Group group, int* rank) {
13218 return MPI_Group_rank(group, rank);
13219 }
13220
13221#endif
13222#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13223 inline int AMPI_Group_size(AMPI_Group group, int* size) {
13224 return MPI_Group_size(group, size);
13225 }
13226
13227#endif
13228#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13229 inline int AMPI_Group_translate_ranks(AMPI_Group group1, int n, MEDI_OPTIONAL_CONST int* ranks1, AMPI_Group group2,
13230 int* ranks2) {
13231 return MPI_Group_translate_ranks(group1, n, ranks1, group2, ranks2);
13232 }
13233
13234#endif
13235#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13236 inline int AMPI_Group_union(AMPI_Group group1, AMPI_Group group2, AMPI_Group* newgroup) {
13237 return MPI_Group_union(group1, group2, newgroup);
13238 }
13239
13240#endif
13241#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13242 inline int AMPI_Intercomm_create(AMPI_Comm local_comm, int local_leader, AMPI_Comm peer_comm, int remote_leader,
13243 int tag, AMPI_Comm* newintercomm) {
13244 return MPI_Intercomm_create(local_comm, local_leader, peer_comm, remote_leader, tag, newintercomm);
13245 }
13246
13247#endif
13248#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13249 inline int AMPI_Intercomm_merge(AMPI_Comm intercomm, int high, AMPI_Comm* newintracomm) {
13250 return MPI_Intercomm_merge(intercomm, high, newintracomm);
13251 }
13252
13253#endif
13254#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13256 AMPI_Type_delete_attr_function* type_delete_attr_fn, int* type_keyval, void* extra_state) {
13257 return MPI_Type_create_keyval(type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state);
13258 }
13259
13260#endif
13261#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13262 template<typename DATATYPE>
13263 inline int AMPI_Type_delete_attr(DATATYPE* datatype, int type_keyval) {
13264 return MPI_Type_delete_attr(datatype->getModifiedMpiType(), type_keyval);
13265 }
13266
13267#endif
13268#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13269 inline int AMPI_Type_free_keyval(int* type_keyval) {
13270 return MPI_Type_free_keyval(type_keyval);
13271 }
13272
13273#endif
13274#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13275 template<typename DATATYPE>
13276 inline int AMPI_Type_get_attr(DATATYPE* datatype, int type_keyval, void* attribute_val, int* flag) {
13277 return MPI_Type_get_attr(datatype->getModifiedMpiType(), type_keyval, attribute_val, flag);
13278 }
13279
13280#endif
13281#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13282 template<typename DATATYPE>
13283 inline int AMPI_Type_get_name(DATATYPE* datatype, char* type_name, int* resultlen) {
13284 return MPI_Type_get_name(datatype->getModifiedMpiType(), type_name, resultlen);
13285 }
13286
13287#endif
13288#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13289 template<typename DATATYPE>
13290 inline int AMPI_Type_set_attr(DATATYPE* datatype, int type_keyval, void* attribute_val) {
13291 return MPI_Type_set_attr(datatype->getModifiedMpiType(), type_keyval, attribute_val);
13292 }
13293
13294#endif
13295#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13296 template<typename DATATYPE>
13297 inline int AMPI_Type_set_name(DATATYPE* datatype, const char* type_name) {
13298 return MPI_Type_set_name(datatype->getModifiedMpiType(), type_name);
13299 }
13300
13301#endif
13302#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13304 AMPI_Win_delete_attr_function* win_delete_attr_fn, int* win_keyval, void* extra_state) {
13305 return MPI_Win_create_keyval(win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state);
13306 }
13307
13308#endif
13309#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13310 inline int AMPI_Win_delete_attr(AMPI_Win win, int win_keyval) {
13311 return MPI_Win_delete_attr(win, win_keyval);
13312 }
13313
13314#endif
13315#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13316 inline int AMPI_Win_free_keyval(int* win_keyval) {
13317 return MPI_Win_free_keyval(win_keyval);
13318 }
13319
13320#endif
13321#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13322 inline int AMPI_Win_get_attr(AMPI_Win win, int win_keyval, void* attribute_val, int* flag) {
13323 return MPI_Win_get_attr(win, win_keyval, attribute_val, flag);
13324 }
13325
13326#endif
13327#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13328 inline int AMPI_Win_get_name(AMPI_Win win, char* win_name, int* resultlen) {
13329 return MPI_Win_get_name(win, win_name, resultlen);
13330 }
13331
13332#endif
13333#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13334 inline int AMPI_Win_set_attr(AMPI_Win win, int win_keyval, void* attribute_val) {
13335 return MPI_Win_set_attr(win, win_keyval, attribute_val);
13336 }
13337
13338#endif
13339#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13340 inline int AMPI_Win_set_name(AMPI_Win win, MEDI_OPTIONAL_CONST char* win_name) {
13341 return MPI_Win_set_name(win, win_name);
13342 }
13343
13344#endif
13345#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13346 inline int AMPI_Cart_coords(AMPI_Comm comm, int rank, int maxdims, int* coords) {
13347 return MPI_Cart_coords(comm, rank, maxdims, coords);
13348 }
13349
13350#endif
13351#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13352 inline int AMPI_Cart_create(AMPI_Comm comm_old, int ndims, MEDI_OPTIONAL_CONST int* dims,
13353 MEDI_OPTIONAL_CONST int* periods, int reorder, AMPI_Comm* comm_cart) {
13354 return MPI_Cart_create(comm_old, ndims, dims, periods, reorder, comm_cart);
13355 }
13356
13357#endif
13358#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13359 inline int AMPI_Cart_get(AMPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
13360 return MPI_Cart_get(comm, maxdims, dims, periods, coords);
13361 }
13362
13363#endif
13364#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13365 inline int AMPI_Cart_map(AMPI_Comm comm, int ndims, MEDI_OPTIONAL_CONST int* dims, MEDI_OPTIONAL_CONST int* periods,
13366 int* newrank) {
13367 return MPI_Cart_map(comm, ndims, dims, periods, newrank);
13368 }
13369
13370#endif
13371#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13372 inline int AMPI_Cart_rank(AMPI_Comm comm, MEDI_OPTIONAL_CONST int* coords, int* rank) {
13373 return MPI_Cart_rank(comm, coords, rank);
13374 }
13375
13376#endif
13377#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13378 inline int AMPI_Cart_shift(AMPI_Comm comm, int direction, int disp, int* rank_source, int* rank_dest) {
13379 return MPI_Cart_shift(comm, direction, disp, rank_source, rank_dest);
13380 }
13381
13382#endif
13383#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13384 inline int AMPI_Cart_sub(AMPI_Comm comm, MEDI_OPTIONAL_CONST int* remain_dims, AMPI_Comm* newcomm) {
13385 return MPI_Cart_sub(comm, remain_dims, newcomm);
13386 }
13387
13388#endif
13389#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13390 inline int AMPI_Cartdim_get(AMPI_Comm comm, int* ndims) {
13391 return MPI_Cartdim_get(comm, ndims);
13392 }
13393
13394#endif
13395#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13396 inline int AMPI_Dims_create(int nnodes, int ndims, int* dims) {
13397 return MPI_Dims_create(nnodes, ndims, dims);
13398 }
13399
13400#endif
13401#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13402 inline int AMPI_Dist_graph_create(AMPI_Comm comm_old, int n, MEDI_OPTIONAL_CONST int* sources,
13403 MEDI_OPTIONAL_CONST int* degrees, MEDI_OPTIONAL_CONST int* destinations, MEDI_OPTIONAL_CONST int* weights,
13404 AMPI_Info info, int reorder, AMPI_Comm* comm_dist_graph) {
13405 return MPI_Dist_graph_create(comm_old, n, sources, degrees, destinations, weights, info, reorder, comm_dist_graph);
13406 }
13407
13408#endif
13409#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13410 inline int AMPI_Dist_graph_create_adjacent(AMPI_Comm comm_old, int indegree, MEDI_OPTIONAL_CONST int* sources,
13411 MEDI_OPTIONAL_CONST int* sourceweights, int outdegree, MEDI_OPTIONAL_CONST int* destinations,
13412 MEDI_OPTIONAL_CONST int* destweights, AMPI_Info info, int reorder, AMPI_Comm* comm_dist_graph) {
13413 return MPI_Dist_graph_create_adjacent(comm_old, indegree, sources, sourceweights, outdegree, destinations, destweights,
13414 info, reorder, comm_dist_graph);
13415 }
13416
13417#endif
13418#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13419 inline int AMPI_Dist_graph_neighbors(AMPI_Comm comm, int maxindegree, int* sources, int* sourceweights,
13420 int maxoutdegree, int* destinations, int* destweights) {
13421 return MPI_Dist_graph_neighbors(comm, maxindegree, sources, sourceweights, maxoutdegree, destinations, destweights);
13422 }
13423
13424#endif
13425#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13426 inline int AMPI_Dist_graph_neighbors_count(AMPI_Comm comm, int* indegree, int* outdegree, int* weighted) {
13427 return MPI_Dist_graph_neighbors_count(comm, indegree, outdegree, weighted);
13428 }
13429
13430#endif
13431#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13432 inline int AMPI_Graph_create(AMPI_Comm comm_old, int nnodes, MEDI_OPTIONAL_CONST int* index,
13433 MEDI_OPTIONAL_CONST int* edges, int reorder, AMPI_Comm* comm_graph) {
13434 return MPI_Graph_create(comm_old, nnodes, index, edges, reorder, comm_graph);
13435 }
13436
13437#endif
13438#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13439 inline int AMPI_Graph_get(AMPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
13440 return MPI_Graph_get(comm, maxindex, maxedges, index, edges);
13441 }
13442
13443#endif
13444#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13445 inline int AMPI_Graph_map(AMPI_Comm comm, int nnodes, MEDI_OPTIONAL_CONST int* index, MEDI_OPTIONAL_CONST int* edges,
13446 int* newrank) {
13447 return MPI_Graph_map(comm, nnodes, index, edges, newrank);
13448 }
13449
13450#endif
13451#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13452 inline int AMPI_Graph_neighbors(AMPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
13453 return MPI_Graph_neighbors(comm, rank, maxneighbors, neighbors);
13454 }
13455
13456#endif
13457#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13458 inline int AMPI_Graph_neighbors_count(AMPI_Comm comm, int rank, int* nneighbors) {
13459 return MPI_Graph_neighbors_count(comm, rank, nneighbors);
13460 }
13461
13462#endif
13463#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13464 inline int AMPI_Graphdims_get(AMPI_Comm comm, int* nnodes, int* nedges) {
13465 return MPI_Graphdims_get(comm, nnodes, nedges);
13466 }
13467
13468#endif
13469#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13470 inline int AMPI_Topo_test(AMPI_Comm comm, int* status) {
13471 return MPI_Topo_test(comm, status);
13472 }
13473
13474#endif
13475#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13476 inline double AMPI_Wtick() {
13477 return MPI_Wtick();
13478 }
13479
13480#endif
13481#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13482 inline double AMPI_Wtime() {
13483 return MPI_Wtime();
13484 }
13485
13486#endif
13487#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13488 inline int AMPI_Abort(AMPI_Comm comm, int errorcode) {
13489 return MPI_Abort(comm, errorcode);
13490 }
13491
13492#endif
13493#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13494 inline int AMPI_Add_error_class(int* errorclass) {
13495 return MPI_Add_error_class(errorclass);
13496 }
13497
13498#endif
13499#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13500 inline int AMPI_Add_error_code(int errorclass, int* errorcode) {
13501 return MPI_Add_error_code(errorclass, errorcode);
13502 }
13503
13504#endif
13505#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13506 inline int AMPI_Add_error_string(int errorcode, MEDI_OPTIONAL_CONST char* string) {
13507 return MPI_Add_error_string(errorcode, string);
13508 }
13509
13510#endif
13511#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13512 inline int AMPI_Alloc_mem(AMPI_Aint size, AMPI_Info info, void* baseptr) {
13513 return MPI_Alloc_mem(size, info, baseptr);
13514 }
13515
13516#endif
13517#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13518 inline int AMPI_Comm_call_errhandler(AMPI_Comm comm, int errorcode) {
13519 return MPI_Comm_call_errhandler(comm, errorcode);
13520 }
13521
13522#endif
13523#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13525 return MPI_Comm_create_errhandler(comm_errhandler_fn, errhandler);
13526 }
13527
13528#endif
13529#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_2_2
13530 inline int AMPI_Comm_create_errhandler(AMPI_Comm_errhandler_fn* comm_errhandler_fn, AMPI_Errhandler* errhandler) {
13531 return MPI_Comm_create_errhandler(comm_errhandler_fn, errhandler);
13532 }
13533
13534#endif
13535#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13537 return MPI_Comm_get_errhandler(comm, errhandler);
13538 }
13539
13540#endif
13541#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13543 return MPI_Comm_set_errhandler(comm, errhandler);
13544 }
13545
13546#endif
13547#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13548 inline int AMPI_Errhandler_free(AMPI_Errhandler* errhandler) {
13549 return MPI_Errhandler_free(errhandler);
13550 }
13551
13552#endif
13553#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13554 inline int AMPI_Error_class(int errorcode, int* errorclass) {
13555 return MPI_Error_class(errorcode, errorclass);
13556 }
13557
13558#endif
13559#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13560 inline int AMPI_Error_string(int errorcode, char* string, int* resultlen) {
13561 return MPI_Error_string(errorcode, string, resultlen);
13562 }
13563
13564#endif
13565#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13566 inline int AMPI_File_call_errhandler(AMPI_File fh, int errorcode) {
13567 return MPI_File_call_errhandler(fh, errorcode);
13568 }
13569
13570#endif
13571#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13573 return MPI_File_create_errhandler(file_errhandler_fn, errhandler);
13574 }
13575
13576#endif
13577#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_2_2
13578 inline int AMPI_File_create_errhandler(AMPI_File_errhandler_fn* file_errhandler_fn, AMPI_Errhandler* errhandler) {
13579 return MPI_File_create_errhandler(file_errhandler_fn, errhandler);
13580 }
13581
13582#endif
13583#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13585 return MPI_File_get_errhandler(file, errhandler);
13586 }
13587
13588#endif
13589#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13591 return MPI_File_set_errhandler(file, errhandler);
13592 }
13593
13594#endif
13595#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13596 inline int AMPI_Finalize() {
13597 return MPI_Finalize();
13598 }
13599
13600#endif
13601#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13602 inline int AMPI_Finalized(int* flag) {
13603 return MPI_Finalized(flag);
13604 }
13605
13606#endif
13607#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13608 inline int AMPI_Free_mem(void* base) {
13609 return MPI_Free_mem(base);
13610 }
13611
13612#endif
13613#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13614 inline int AMPI_Get_library_version(char* version, int* resultlen) {
13615 return MPI_Get_library_version(version, resultlen);
13616 }
13617
13618#endif
13619#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13620 inline int AMPI_Get_processor_name(char* name, int* resultlen) {
13621 return MPI_Get_processor_name(name, resultlen);
13622 }
13623
13624#endif
13625#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13626 inline int AMPI_Get_version(int* version, int* subversion) {
13627 return MPI_Get_version(version, subversion);
13628 }
13629
13630#endif
13631#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
13632 inline int AMPI_Initialized(int* flag) {
13633 return MPI_Initialized(flag);
13634 }
13635
13636#endif
13637#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13638 inline int AMPI_Win_call_errhandler(AMPI_Win win, int errorcode) {
13639 return MPI_Win_call_errhandler(win, errorcode);
13640 }
13641
13642#endif
13643#if MEDI_MPI_VERSION_2_2 <= MEDI_MPI_TARGET
13645 return MPI_Win_create_errhandler(win_errhandler_fn, errhandler);
13646 }
13647
13648#endif
13649#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_2_2
13650 inline int AMPI_Win_create_errhandler(AMPI_Win_errhandler_fn* win_errhandler_fn, AMPI_Errhandler* errhandler) {
13651 return MPI_Win_create_errhandler(win_errhandler_fn, errhandler);
13652 }
13653
13654#endif
13655#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13656 inline int AMPI_Win_get_errhandler(AMPI_Win win, AMPI_Errhandler* errhandler) {
13657 return MPI_Win_get_errhandler(win, errhandler);
13658 }
13659
13660#endif
13661#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13663 return MPI_Win_set_errhandler(win, errhandler);
13664 }
13665
13666#endif
13667#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13668 inline int AMPI_Info_create(AMPI_Info* info) {
13669 return MPI_Info_create(info);
13670 }
13671
13672#endif
13673#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13674 inline int AMPI_Info_delete(AMPI_Info info, MEDI_OPTIONAL_CONST char* key) {
13675 return MPI_Info_delete(info, key);
13676 }
13677
13678#endif
13679#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13680 inline int AMPI_Info_dup(AMPI_Info info, AMPI_Info* newinfo) {
13681 return MPI_Info_dup(info, newinfo);
13682 }
13683
13684#endif
13685#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13686 inline int AMPI_Info_free(AMPI_Info* info) {
13687 return MPI_Info_free(info);
13688 }
13689
13690#endif
13691#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13692 inline int AMPI_Info_get(AMPI_Info info, MEDI_OPTIONAL_CONST char* key, int valuelen, char* value, int* flag) {
13693 return MPI_Info_get(info, key, valuelen, value, flag);
13694 }
13695
13696#endif
13697#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13698 inline int AMPI_Info_get_nkeys(AMPI_Info info, int* nkeys) {
13699 return MPI_Info_get_nkeys(info, nkeys);
13700 }
13701
13702#endif
13703#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13704 inline int AMPI_Info_get_nthkey(AMPI_Info info, int n, char* key) {
13705 return MPI_Info_get_nthkey(info, n, key);
13706 }
13707
13708#endif
13709#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13710 inline int AMPI_Info_get_valuelen(AMPI_Info info, MEDI_OPTIONAL_CONST char* key, int* valuelen, int* flag) {
13711 return MPI_Info_get_valuelen(info, key, valuelen, flag);
13712 }
13713
13714#endif
13715#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13716 inline int AMPI_Info_set(AMPI_Info info, MEDI_OPTIONAL_CONST char* key, MEDI_OPTIONAL_CONST char* value) {
13717 return MPI_Info_set(info, key, value);
13718 }
13719
13720#endif
13721#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13722 inline int AMPI_Close_port(MEDI_OPTIONAL_CONST char* port_name) {
13723 return MPI_Close_port(port_name);
13724 }
13725
13726#endif
13727#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13728 inline int AMPI_Comm_accept(MEDI_OPTIONAL_CONST char* port_name, AMPI_Info info, int root, AMPI_Comm comm,
13729 AMPI_Comm* newcomm) {
13730 return MPI_Comm_accept(port_name, info, root, comm, newcomm);
13731 }
13732
13733#endif
13734#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13735 inline int AMPI_Comm_connect(MEDI_OPTIONAL_CONST char* port_name, AMPI_Info info, int root, AMPI_Comm comm,
13736 AMPI_Comm* newcomm) {
13737 return MPI_Comm_connect(port_name, info, root, comm, newcomm);
13738 }
13739
13740#endif
13741#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13743 return MPI_Comm_disconnect(comm);
13744 }
13745
13746#endif
13747#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13748 inline int AMPI_Comm_get_parent(AMPI_Comm* parent) {
13749 return MPI_Comm_get_parent(parent);
13750 }
13751
13752#endif
13753#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13754 inline int AMPI_Comm_join(int fd, AMPI_Comm* intercomm) {
13755 return MPI_Comm_join(fd, intercomm);
13756 }
13757
13758#endif
13759#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13760 inline int AMPI_Comm_spawn(MEDI_OPTIONAL_CONST char* command, char** argv, int maxprocs, AMPI_Info info, int root,
13761 AMPI_Comm comm, AMPI_Comm* intercomm, int* array_of_errcodes) {
13762 return MPI_Comm_spawn(command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes);
13763 }
13764
13765#endif
13766#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13767 inline int AMPI_Comm_spawn_multiple(int count, char** array_of_commands, char*** array_of_argv,
13768 MEDI_OPTIONAL_CONST int* array_of_maxprocs, MEDI_OPTIONAL_CONST AMPI_Info* array_of_info, int root, AMPI_Comm comm,
13769 AMPI_Comm* intercomm, int* array_of_errcodes) {
13770 return MPI_Comm_spawn_multiple(count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm,
13771 intercomm, array_of_errcodes);
13772 }
13773
13774#endif
13775#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13776 inline int AMPI_Lookup_name(MEDI_OPTIONAL_CONST char* service_name, AMPI_Info info, char* port_name) {
13777 return MPI_Lookup_name(service_name, info, port_name);
13778 }
13779
13780#endif
13781#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13782 inline int AMPI_Open_port(AMPI_Info info, char* port_name) {
13783 return MPI_Open_port(info, port_name);
13784 }
13785
13786#endif
13787#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13788 inline int AMPI_Publish_name(MEDI_OPTIONAL_CONST char* service_name, AMPI_Info info,
13789 MEDI_OPTIONAL_CONST char* port_name) {
13790 return MPI_Publish_name(service_name, info, port_name);
13791 }
13792
13793#endif
13794#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13795 inline int AMPI_Unpublish_name(MEDI_OPTIONAL_CONST char* service_name, AMPI_Info info,
13796 MEDI_OPTIONAL_CONST char* port_name) {
13797 return MPI_Unpublish_name(service_name, info, port_name);
13798 }
13799
13800#endif
13801#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13803 return MPI_Grequest_complete(request.request);
13804 }
13805
13806#endif
13807#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13809 AMPI_Grequest_cancel_function* cancel_fn, void* extra_state, AMPI_Request* request) {
13810 return MPI_Grequest_start(query_fn, free_fn, cancel_fn, extra_state, &request->request);
13811 }
13812
13813#endif
13814#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13815 inline int AMPI_Is_thread_main(int* flag) {
13816 return MPI_Is_thread_main(flag);
13817 }
13818
13819#endif
13820#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13821 inline int AMPI_Query_thread(int* provided) {
13822 return MPI_Query_thread(provided);
13823 }
13824
13825#endif
13826#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13827 inline int AMPI_Status_set_cancelled(AMPI_Status* status, int flag) {
13828 return MPI_Status_set_cancelled(status, flag);
13829 }
13830
13831#endif
13832#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13833 template<typename DATATYPE>
13834 inline int AMPI_Status_set_elements(AMPI_Status* status, DATATYPE* datatype, int count) {
13835 return MPI_Status_set_elements(status, datatype->getModifiedMpiType(), count);
13836 }
13837
13838#endif
13839#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
13840 template<typename DATATYPE>
13841 inline int AMPI_Status_set_elements_x(AMPI_Status* status, DATATYPE* datatype, AMPI_Count count) {
13842 return MPI_Status_set_elements_x(status, datatype->getModifiedMpiType(), count);
13843 }
13844
13845#endif
13846#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13847 inline int AMPI_File_close(AMPI_File* fh) {
13848 return MPI_File_close(fh);
13849 }
13850
13851#endif
13852#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13853 inline int AMPI_File_delete(MEDI_OPTIONAL_CONST char* filename, AMPI_Info info) {
13854 return MPI_File_delete(filename, info);
13855 }
13856
13857#endif
13858#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13859 inline int AMPI_File_get_amode(AMPI_File fh, int* amode) {
13860 return MPI_File_get_amode(fh, amode);
13861 }
13862
13863#endif
13864#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13865 inline int AMPI_File_get_atomicity(AMPI_File fh, int* flag) {
13866 return MPI_File_get_atomicity(fh, flag);
13867 }
13868
13869#endif
13870#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13872 return MPI_File_get_byte_offset(fh, offset, disp);
13873 }
13874
13875#endif
13876#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13878 return MPI_File_get_group(fh, group);
13879 }
13880
13881#endif
13882#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13883 inline int AMPI_File_get_info(AMPI_File fh, AMPI_Info* info_used) {
13884 return MPI_File_get_info(fh, info_used);
13885 }
13886
13887#endif
13888#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13890 return MPI_File_get_position(fh, offset);
13891 }
13892
13893#endif
13894#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13896 return MPI_File_get_position_shared(fh, offset);
13897 }
13898
13899#endif
13900#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13902 return MPI_File_get_size(fh, size);
13903 }
13904
13905#endif
13906#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13907 template<typename DATATYPE>
13908 inline int AMPI_File_get_type_extent(AMPI_File fh, DATATYPE* datatype, AMPI_Aint* extent) {
13909 return MPI_File_get_type_extent(fh, datatype->getModifiedMpiType(), extent);
13910 }
13911
13912#endif
13913#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13914 template<typename ETYPE, typename FILETYPE>
13915 inline int AMPI_File_get_view(AMPI_File fh, AMPI_Offset* disp, ETYPE* etype, FILETYPE* filetype, char* datarep) {
13916 return MPI_File_get_view(fh, disp, etype->getModifiedMpiType(), filetype->getModifiedMpiType(), datarep);
13917 }
13918
13919#endif
13920#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13921 template<typename DATATYPE>
13922 inline int AMPI_File_iread(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13923 return MPI_File_iread(fh, buf, count, datatype->getModifiedMpiType(), request);
13924 }
13925
13926#endif
13927#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13928 template<typename DATATYPE>
13929 inline int AMPI_File_iread_all(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13930 return MPI_File_iread_all(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13931 }
13932
13933#endif
13934#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13935 template<typename DATATYPE>
13936 inline int AMPI_File_iread_at(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
13937 AMPI_Request* request) {
13938 return MPI_File_iread_at(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13939 }
13940
13941#endif
13942#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13943 template<typename DATATYPE>
13944 inline int AMPI_File_iread_at_all(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
13945 AMPI_Request* request) {
13946 return MPI_File_iread_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13947 }
13948
13949#endif
13950#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13951 template<typename DATATYPE>
13952 inline int AMPI_File_iread_shared(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13953 return MPI_File_iread_shared(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13954 }
13955
13956#endif
13957#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13958 template<typename DATATYPE>
13959 inline int AMPI_File_iwrite(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13960 return MPI_File_iwrite(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13961 }
13962
13963#endif
13964#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13965 template<typename DATATYPE>
13966 inline int AMPI_File_iwrite_all(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Request* request) {
13967 return MPI_File_iwrite_all(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13968 }
13969
13970#endif
13971#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13972 template<typename DATATYPE>
13973 inline int AMPI_File_iwrite_at(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
13974 AMPI_Request* request) {
13975 return MPI_File_iwrite_at(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13976 }
13977
13978#endif
13979#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
13980 template<typename DATATYPE>
13981 inline int AMPI_File_iwrite_at_all(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
13982 AMPI_Request* request) {
13983 return MPI_File_iwrite_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), &request->request);
13984 }
13985
13986#endif
13987#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13988 template<typename DATATYPE>
13989 inline int AMPI_File_iwrite_shared(AMPI_File fh, const void* buf, int count, DATATYPE* datatype,
13990 AMPI_Request* request) {
13991 return MPI_File_iwrite_shared(fh, buf, count, datatype->getModifiedMpiType(), &request->request);
13992 }
13993
13994#endif
13995#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
13996 inline int AMPI_File_open(AMPI_Comm comm, MEDI_OPTIONAL_CONST char* filename, int amode, AMPI_Info info,
13997 AMPI_File* fh) {
13998 return MPI_File_open(comm, filename, amode, info, fh);
13999 }
14000
14001#endif
14002#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14004 return MPI_File_preallocate(fh, size);
14005 }
14006
14007#endif
14008#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14009 template<typename DATATYPE>
14010 inline int AMPI_File_read(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14011 return MPI_File_read(fh, buf, count, datatype->getModifiedMpiType(), status);
14012 }
14013
14014#endif
14015#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14016 template<typename DATATYPE>
14017 inline int AMPI_File_read_all(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14018 return MPI_File_read_all(fh, buf, count, datatype->getModifiedMpiType(), status);
14019 }
14020
14021#endif
14022#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14023 template<typename DATATYPE>
14024 inline int AMPI_File_read_all_begin(AMPI_File fh, void* buf, int count, DATATYPE* datatype) {
14025 return MPI_File_read_all_begin(fh, buf, count, datatype->getModifiedMpiType());
14026 }
14027
14028#endif
14029#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14030 inline int AMPI_File_read_all_end(AMPI_File fh, void* buf, AMPI_Status* status) {
14031 return MPI_File_read_all_end(fh, buf, status);
14032 }
14033
14034#endif
14035#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14036 template<typename DATATYPE>
14037 inline int AMPI_File_read_at(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
14038 AMPI_Status* status) {
14039 return MPI_File_read_at(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
14040 }
14041
14042#endif
14043#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14044 template<typename DATATYPE>
14045 inline int AMPI_File_read_at_all(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype,
14046 AMPI_Status* status) {
14047 return MPI_File_read_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
14048 }
14049
14050#endif
14051#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14052 template<typename DATATYPE>
14053 inline int AMPI_File_read_at_all_begin(AMPI_File fh, AMPI_Offset offset, void* buf, int count, DATATYPE* datatype) {
14054 return MPI_File_read_at_all_begin(fh, offset, buf, count, datatype->getModifiedMpiType());
14055 }
14056
14057#endif
14058#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14059 inline int AMPI_File_read_at_all_end(AMPI_File fh, void* buf, AMPI_Status* status) {
14060 return MPI_File_read_at_all_end(fh, buf, status);
14061 }
14062
14063#endif
14064#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14065 template<typename DATATYPE>
14066 inline int AMPI_File_read_ordered(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14067 return MPI_File_read_ordered(fh, buf, count, datatype->getModifiedMpiType(), status);
14068 }
14069
14070#endif
14071#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14072 template<typename DATATYPE>
14073 inline int AMPI_File_read_ordered_begin(AMPI_File fh, void* buf, int count, DATATYPE* datatype) {
14074 return MPI_File_read_ordered_begin(fh, buf, count, datatype->getModifiedMpiType());
14075 }
14076
14077#endif
14078#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14079 inline int AMPI_File_read_ordered_end(AMPI_File fh, void* buf, AMPI_Status* status) {
14080 return MPI_File_read_ordered_end(fh, buf, status);
14081 }
14082
14083#endif
14084#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14085 template<typename DATATYPE>
14086 inline int AMPI_File_read_shared(AMPI_File fh, void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14087 return MPI_File_read_shared(fh, buf, count, datatype->getModifiedMpiType(), status);
14088 }
14089
14090#endif
14091#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14092 inline int AMPI_File_seek(AMPI_File fh, AMPI_Offset offset, int whence) {
14093 return MPI_File_seek(fh, offset, whence);
14094 }
14095
14096#endif
14097#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14098 inline int AMPI_File_seek_shared(AMPI_File fh, AMPI_Offset offset, int whence) {
14099 return MPI_File_seek_shared(fh, offset, whence);
14100 }
14101
14102#endif
14103#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14104 inline int AMPI_File_set_atomicity(AMPI_File fh, int flag) {
14105 return MPI_File_set_atomicity(fh, flag);
14106 }
14107
14108#endif
14109#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14111 return MPI_File_set_info(fh, info);
14112 }
14113
14114#endif
14115#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14117 return MPI_File_set_size(fh, size);
14118 }
14119
14120#endif
14121#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14122 template<typename ETYPE, typename FILETYPE>
14123 inline int AMPI_File_set_view(AMPI_File fh, AMPI_Offset disp, ETYPE* etype, FILETYPE* filetype, const char* datarep,
14124 AMPI_Info info) {
14125 return MPI_File_set_view(fh, disp, etype->getModifiedMpiType(), filetype->getModifiedMpiType(), datarep, info);
14126 }
14127
14128#endif
14129#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14130 inline int AMPI_File_sync(AMPI_File fh) {
14131 return MPI_File_sync(fh);
14132 }
14133
14134#endif
14135#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14136 template<typename DATATYPE>
14137 inline int AMPI_File_write(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14138 return MPI_File_write(fh, buf, count, datatype->getModifiedMpiType(), status);
14139 }
14140
14141#endif
14142#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14143 template<typename DATATYPE>
14144 inline int AMPI_File_write_all(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14145 return MPI_File_write_all(fh, buf, count, datatype->getModifiedMpiType(), status);
14146 }
14147
14148#endif
14149#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14150 template<typename DATATYPE>
14151 inline int AMPI_File_write_all_begin(AMPI_File fh, const void* buf, int count, DATATYPE* datatype) {
14152 return MPI_File_write_all_begin(fh, buf, count, datatype->getModifiedMpiType());
14153 }
14154
14155#endif
14156#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14158 return MPI_File_write_all_end(fh, buf, status);
14159 }
14160
14161#endif
14162#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14163 template<typename DATATYPE>
14164 inline int AMPI_File_write_at(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
14165 AMPI_Status* status) {
14166 return MPI_File_write_at(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
14167 }
14168
14169#endif
14170#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14171 template<typename DATATYPE>
14172 inline int AMPI_File_write_at_all(AMPI_File fh, AMPI_Offset offset, const void* buf, int count, DATATYPE* datatype,
14173 AMPI_Status* status) {
14174 return MPI_File_write_at_all(fh, offset, buf, count, datatype->getModifiedMpiType(), status);
14175 }
14176
14177#endif
14178#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14179 template<typename DATATYPE>
14180 inline int AMPI_File_write_at_all_begin(AMPI_File fh, AMPI_Offset offset, const void* buf, int count,
14181 DATATYPE* datatype) {
14182 return MPI_File_write_at_all_begin(fh, offset, buf, count, datatype->getModifiedMpiType());
14183 }
14184
14185#endif
14186#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14188 return MPI_File_write_at_all_end(fh, buf, status);
14189 }
14190
14191#endif
14192#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14193 template<typename DATATYPE>
14194 inline int AMPI_File_write_ordered(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14195 return MPI_File_write_ordered(fh, buf, count, datatype->getModifiedMpiType(), status);
14196 }
14197
14198#endif
14199#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14200 template<typename DATATYPE>
14201 inline int AMPI_File_write_ordered_begin(AMPI_File fh, const void* buf, int count, DATATYPE* datatype) {
14202 return MPI_File_write_ordered_begin(fh, buf, count, datatype->getModifiedMpiType());
14203 }
14204
14205#endif
14206#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14208 return MPI_File_write_ordered_end(fh, buf, status);
14209 }
14210
14211#endif
14212#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14213 template<typename DATATYPE>
14214 inline int AMPI_File_write_shared(AMPI_File fh, const void* buf, int count, DATATYPE* datatype, AMPI_Status* status) {
14215 return MPI_File_write_shared(fh, buf, count, datatype->getModifiedMpiType(), status);
14216 }
14217
14218#endif
14219#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14221 AMPI_Datarep_conversion_function* read_conversion_fn, AMPI_Datarep_conversion_function* write_conversion_fn,
14222 AMPI_Datarep_extent_function* dtype_file_extent_fn, void* extra_state) {
14223 return MPI_Register_datarep(datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state);
14224 }
14225
14226#endif
14227#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14228 inline MPI_Fint AMPI_Comm_c2f(AMPI_Comm comm) {
14229 return MPI_Comm_c2f(comm);
14230 }
14231
14232#endif
14233#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14234 inline MPI_Comm AMPI_Comm_f2c(AMPI_Fint comm) {
14235 return MPI_Comm_f2c(comm);
14236 }
14237
14238#endif
14239#if MEDI_MPI_VERSION_2_1 <= MEDI_MPI_TARGET
14240 inline MPI_Fint AMPI_Errhandler_c2f(AMPI_Errhandler errhandler) {
14241 return MPI_Errhandler_c2f(errhandler);
14242 }
14243
14244#endif
14245#if MEDI_MPI_VERSION_2_1 <= MEDI_MPI_TARGET
14246 inline MPI_Errhandler AMPI_Errhandler_f2c(AMPI_Fint errhandler) {
14247 return MPI_Errhandler_f2c(errhandler);
14248 }
14249
14250#endif
14251#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14252 inline MPI_Fint AMPI_File_c2f(AMPI_File file) {
14253 return MPI_File_c2f(file);
14254 }
14255
14256#endif
14257#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14258 inline MPI_File AMPI_File_f2c(AMPI_Fint file) {
14259 return MPI_File_f2c(file);
14260 }
14261
14262#endif
14263#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14264 inline MPI_Fint AMPI_Group_c2f(AMPI_Group group) {
14265 return MPI_Group_c2f(group);
14266 }
14267
14268#endif
14269#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14270 inline MPI_Group AMPI_Group_f2c(AMPI_Fint group) {
14271 return MPI_Group_f2c(group);
14272 }
14273
14274#endif
14275#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14276 inline MPI_Fint AMPI_Info_c2f(AMPI_Info info) {
14277 return MPI_Info_c2f(info);
14278 }
14279
14280#endif
14281#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14282 inline MPI_Info AMPI_Info_f2c(AMPI_Fint info) {
14283 return MPI_Info_f2c(info);
14284 }
14285
14286#endif
14287#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14289 return MPI_Status_c2f(c_status, f_status);
14290 }
14291
14292#endif
14293#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14295 return MPI_Status_f2c(f_status, c_status);
14296 }
14297
14298#endif
14299#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14300 inline MPI_Fint AMPI_Win_c2f(AMPI_Win win) {
14301 return MPI_Win_c2f(win);
14302 }
14303
14304#endif
14305#if MEDI_MPI_VERSION_2_0 <= MEDI_MPI_TARGET
14306 inline MPI_Win AMPI_Win_f2c(AMPI_Fint win) {
14307 return MPI_Win_f2c(win);
14308 }
14309
14310#endif
14311#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14312 inline int AMPI_T_category_changed(int* stamp) {
14313 return MPI_T_category_changed(stamp);
14314 }
14315
14316#endif
14317#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14318 inline int AMPI_T_category_get_categories(int cat_index, int len, int* indices) {
14319 return MPI_T_category_get_categories(cat_index, len, indices);
14320 }
14321
14322#endif
14323#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14324 inline int AMPI_T_category_get_cvars(int cat_index, int len, int* indices) {
14325 return MPI_T_category_get_cvars(cat_index, len, indices);
14326 }
14327
14328#endif
14329#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
14330 inline int AMPI_T_category_get_index(const char* name, int* cat_index) {
14331 return MPI_T_category_get_index(name, cat_index);
14332 }
14333
14334#endif
14335#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14336 inline int AMPI_T_category_get_info(int cat_index, char* name, int* name_len, char* desc, int* desc_len, int* num_cvars,
14337 int* num_pvars, int* num_categories) {
14338 return MPI_T_category_get_info(cat_index, name, name_len, desc, desc_len, num_cvars, num_pvars, num_categories);
14339 }
14340
14341#endif
14342#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14343 inline int AMPI_T_category_get_num(int* num_cat) {
14344 return MPI_T_category_get_num(num_cat);
14345 }
14346
14347#endif
14348#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14349 inline int AMPI_T_category_get_pvars(int cat_index, int len, int* indices) {
14350 return MPI_T_category_get_pvars(cat_index, len, indices);
14351 }
14352
14353#endif
14354#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
14355 inline int AMPI_T_cvar_get_index(const char* name, int* cvar_index) {
14356 return MPI_T_cvar_get_index(name, cvar_index);
14357 }
14358
14359#endif
14360#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14361 inline int AMPI_T_cvar_get_num(int* num_cvar) {
14362 return MPI_T_cvar_get_num(num_cvar);
14363 }
14364
14365#endif
14366#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14367 inline int AMPI_T_cvar_handle_alloc(int cvar_index, void* obj_handle, AMPI_T_cvar_handle* handle, int* count) {
14368 return MPI_T_cvar_handle_alloc(cvar_index, obj_handle, handle, count);
14369 }
14370
14371#endif
14372#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14374 return MPI_T_cvar_handle_free(handle);
14375 }
14376
14377#endif
14378#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14379 inline int AMPI_T_cvar_read(AMPI_T_cvar_handle handle, void* buf) {
14380 return MPI_T_cvar_read(handle, buf);
14381 }
14382
14383#endif
14384#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14385 inline int AMPI_T_cvar_write(AMPI_T_cvar_handle handle, const void* buf) {
14386 return MPI_T_cvar_write(handle, buf);
14387 }
14388
14389#endif
14390#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14391 inline int AMPI_T_enum_get_info(AMPI_T_enum enumtype, int* num, char* name, int* name_len) {
14392 return MPI_T_enum_get_info(enumtype, num, name, name_len);
14393 }
14394
14395#endif
14396#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14397 inline int AMPI_T_enum_get_item(AMPI_T_enum enumtype, int index, int* value, char* name, int* name_len) {
14398 return MPI_T_enum_get_item(enumtype, index, value, name, name_len);
14399 }
14400
14401#endif
14402#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14403 inline int AMPI_T_finalize() {
14404 return MPI_T_finalize();
14405 }
14406
14407#endif
14408#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14409 inline int AMPI_T_init_thread(int required, int* provided) {
14410 return MPI_T_init_thread(required, provided);
14411 }
14412
14413#endif
14414#if MEDI_MPI_VERSION_3_1 <= MEDI_MPI_TARGET
14415 inline int AMPI_T_pvar_get_index(const char* name, int var_class, int* pvar_index) {
14416 return MPI_T_pvar_get_index(name, var_class, pvar_index);
14417 }
14418
14419#endif
14420#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14421 inline int AMPI_T_pvar_get_num(int* num_pvar) {
14422 return MPI_T_pvar_get_num(num_pvar);
14423 }
14424
14425#endif
14426#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14427 inline int AMPI_T_pvar_handle_alloc(AMPI_T_pvar_session session, int pvar_index, void* obj_handle,
14428 AMPI_T_pvar_handle* handle, int* count) {
14429 return MPI_T_pvar_handle_alloc(session, pvar_index, obj_handle, handle, count);
14430 }
14431
14432#endif
14433#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14435 return MPI_T_pvar_handle_free(session, handle);
14436 }
14437
14438#endif
14439#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14440 inline int AMPI_T_pvar_read(AMPI_T_pvar_session session, AMPI_T_pvar_handle handle, void* buf) {
14441 return MPI_T_pvar_read(session, handle, buf);
14442 }
14443
14444#endif
14445#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14446 inline int AMPI_T_pvar_readreset(AMPI_T_pvar_session session, AMPI_T_pvar_handle handle, void* buf) {
14447 return MPI_T_pvar_readreset(session, handle, buf);
14448 }
14449
14450#endif
14451#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14453 return MPI_T_pvar_reset(session, handle);
14454 }
14455
14456#endif
14457#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14459 return MPI_T_pvar_session_create(session);
14460 }
14461
14462#endif
14463#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14465 return MPI_T_pvar_session_free(session);
14466 }
14467
14468#endif
14469#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14471 return MPI_T_pvar_start(session, handle);
14472 }
14473
14474#endif
14475#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14477 return MPI_T_pvar_stop(session, handle);
14478 }
14479
14480#endif
14481#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
14482 inline int AMPI_T_pvar_write(AMPI_T_pvar_session session, AMPI_T_pvar_handle handle, const void* buf) {
14483 return MPI_T_pvar_write(session, handle, buf);
14484 }
14485
14486#endif
14487#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
14488 inline int AMPI_Address(void* location, AMPI_Aint* address) {
14489 return MPI_Address(location, address);
14490 }
14491
14492#endif
14493#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
14494 inline int AMPI_Attr_delete(AMPI_Comm comm, int keyval) {
14495 return MPI_Attr_delete(comm, keyval);
14496 }
14497
14498#endif
14499#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
14500 inline int AMPI_Attr_get(AMPI_Comm comm, int keyval, void* attribute_val, int* flag) {
14501 return MPI_Attr_get(comm, keyval, attribute_val, flag);
14502 }
14503
14504#endif
14505#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
14506 inline int AMPI_Attr_put(AMPI_Comm comm, int keyval, void* attribute_val) {
14507 return MPI_Attr_put(comm, keyval, attribute_val);
14508 }
14509
14510#endif
14511#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
14512 inline int AMPI_Keyval_create(AMPI_Copy_function* copy_fn, AMPI_Delete_function* delete_fn, int* keyval,
14513 void* extra_state) {
14514 return MPI_Keyval_create(copy_fn, delete_fn, keyval, extra_state);
14515 }
14516
14517#endif
14518#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
14519 inline int AMPI_Keyval_free(int* keyval) {
14520 return MPI_Keyval_free(keyval);
14521 }
14522
14523#endif
14524#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
14525 inline int AMPI_Errhandler_create(AMPI_Handler_function* function, AMPI_Errhandler* errhandler) {
14526 return MPI_Errhandler_create(function, errhandler);
14527 }
14528
14529#endif
14530#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
14531 inline int AMPI_Errhandler_get(AMPI_Comm comm, AMPI_Errhandler* errhandler) {
14532 return MPI_Errhandler_get(comm, errhandler);
14533 }
14534
14535#endif
14536#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
14537 inline int AMPI_Errhandler_set(AMPI_Comm comm, AMPI_Errhandler errhandler) {
14538 return MPI_Errhandler_set(comm, errhandler);
14539 }
14540
14541#endif
14542#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
14543 template<typename DATATYPE>
14544 inline int AMPI_Type_extent(DATATYPE* datatype, AMPI_Aint* extent) {
14545 return MPI_Type_extent(datatype->getModifiedMpiType(), extent);
14546 }
14547
14548#endif
14549#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
14550 template<typename DATATYPE>
14551 inline int AMPI_Type_lb(DATATYPE* datatype, AMPI_Aint* displacement) {
14552 return MPI_Type_lb(datatype->getModifiedMpiType(), displacement);
14553 }
14554
14555#endif
14556#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET && MEDI_MPI_TARGET < MEDI_MPI_VERSION_3_0
14557 template<typename DATATYPE>
14558 inline int AMPI_Type_ub(DATATYPE* datatype, AMPI_Aint* displacement) {
14559 return MPI_Type_ub(datatype->getModifiedMpiType(), displacement);
14560 }
14561
14562#endif
14563
14564#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
14565#define AMPI_Pcontrol MPI_Pcontrol
14566#endif
14567
14568
14569}
#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:10019
int AMPI_Comm_free_keyval(int *comm_keyval)
Definition ampiFunctions.hpp:13073
int AMPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len)
Definition ampiFunctions.hpp:14391
int AMPI_Info_dup(MPI_Info info, MPI_Info *newinfo)
Definition ampiFunctions.hpp:13680
MPI_Comm_errhandler_function AMPI_Comm_errhandler_function
Definition ampiDefinitions.h:848
void AMPI_Ialltoall_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:8414
int AMPI_Errhandler_free(MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:13548
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:13470
MPI_Win AMPI_Win_f2c(MPI_Fint win)
Definition ampiFunctions.hpp:14306
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:12005
void AMPI_Irsend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1420
void AMPI_Iscatter_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10984
void AMPI_Alltoallv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:5805
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:4585
void AMPI_Iscatter_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11028
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:13859
int AMPI_Send_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:3685
void AMPI_Igatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10114
int AMPI_File_create_errhandler(AMPI_File_errhandler_function *file_errhandler_fn, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:13572
int AMPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
Definition ampiFunctions.hpp:14476
int AMPI_Free_mem(void *base)
Definition ampiFunctions.hpp:13608
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:13808
int AMPI_File_write_all_begin(MPI_File fh, const void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:14151
MPI_Datarep_conversion_function AMPI_Datarep_conversion_function
Definition ampiDefinitions.h:878
void AMPI_Irecv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1123
int AMPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
Definition ampiFunctions.hpp:13199
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:13674
int AMPI_Get_elements(const MPI_Status *status, DATATYPE *datatype, int *count)
Definition ampiFunctions.hpp:12938
void AMPI_Igather_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9646
void AMPI_Ibcast_wrap_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9213
void AMPI_Isend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1671
MPI_Delete_function AMPI_Delete_function
Definition ampiDefinitions.h:884
void AMPI_Reduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11944
void AMPI_Bcast_wrap_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:6130
void AMPI_Iallreduce_global_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7873
void AMPI_Irsend_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:1486
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:2056
void AMPI_Send_init_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3494
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:543
int AMPI_File_write_all_end(MPI_File fh, const void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:14157
void AMPI_Gatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6731
int AMPI_Comm_delete_attr(MPI_Comm comm, int comm_keyval)
Definition ampiFunctions.hpp:13049
int AMPI_Type_get_true_extent_x(DATATYPE *datatype, MPI_Count *true_lb, MPI_Count *true_extent)
Definition ampiFunctions.hpp:12990
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:809
int AMPI_Close_port(const char *port_name)
Definition ampiFunctions.hpp:13722
int AMPI_T_pvar_start(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
Definition ampiFunctions.hpp:14470
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:13445
int AMPI_Attr_delete(MPI_Comm comm, int keyval)
Definition ampiFunctions.hpp:14494
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:12919
void AMPI_Iallgatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7519
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:2302
int AMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int *coords)
Definition ampiFunctions.hpp:13346
MPI_Aint AMPI_Aint_diff(MPI_Aint addr1, MPI_Aint addr2)
Definition ampiFunctions.hpp:12925
int AMPI_File_read_ordered(MPI_File fh, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:14066
void AMPI_Iscatterv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11527
int AMPI_Comm_join(int fd, MPI_Comm *intercomm)
Definition ampiFunctions.hpp:13754
int AMPI_T_finalize()
Definition ampiFunctions.hpp:14403
int AMPI_Comm_group(MPI_Comm comm, MPI_Group *group)
Definition ampiFunctions.hpp:13097
void AMPI_Issend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1998
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:13827
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:8170
int AMPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name, int *name_len)
Definition ampiFunctions.hpp:14397
void AMPI_Igather_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9622
void AMPI_Scatter_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:12330
void AMPI_Iallreduce_global_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:8018
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:13500
int AMPI_Open_port(MPI_Info info, char *port_name)
Definition ampiFunctions.hpp:13782
int AMPI_Barrier(MPI_Comm comm)
Definition ampiFunctions.hpp:13010
void AMPI_Send_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3344
void AMPI_Iscatterv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11431
int AMPI_Info_get_nthkey(MPI_Info info, int n, char *key)
Definition ampiFunctions.hpp:13704
void AMPI_Alltoall_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5396
void AMPI_Bsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:72
void AMPI_Imrecv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:825
int AMPI_Info_free(MPI_Info *info)
Definition ampiFunctions.hpp:13686
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_Alltoall_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:5490
void AMPI_Alltoallv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5690
int AMPI_Dist_graph_neighbors_count(MPI_Comm comm, int *indegree, int *outdegree, int *weighted)
Definition ampiFunctions.hpp:13426
void AMPI_Alltoallv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5759
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:13966
int AMPI_File_iread(MPI_File fh, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13922
int AMPI_Type_set_name(DATATYPE *datatype, const char *type_name)
Definition ampiFunctions.hpp:13297
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:13656
void AMPI_Iallgatherv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:7574
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_Scatterv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:12669
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:13895
int AMPI_T_pvar_readreset(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void *buf)
Definition ampiFunctions.hpp:14446
void AMPI_Ireduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10590
int AMPI_Ssend_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:4392
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:3089
int AMPI_Bsend_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:670
int AMPI_Bsend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:142
int AMPI_Iallgather_finish(HandleBase *handle)
Definition ampiFunctions.hpp:7304
int AMPI_File_get_position(MPI_File fh, MPI_Offset *offset)
Definition ampiFunctions.hpp:13889
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:13352
void AMPI_Ireduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10547
void AMPI_Gather_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6337
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:5815
int AMPI_Irsend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:1583
int AMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status)
Definition ampiFunctions.hpp:12901
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:14336
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:4884
int AMPI_Ialltoallv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:9033
int AMPI_File_get_size(MPI_File fh, MPI_Offset *size)
Definition ampiFunctions.hpp:13901
int AMPI_Add_error_class(int *errorclass)
Definition ampiFunctions.hpp:13494
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:6454
void AMPI_Issend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1969
void AMPI_Recv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2470
void AMPI_Iallgatherv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7434
int AMPI_Isend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:1863
MPI_File_errhandler_function AMPI_File_errhandler_function
Definition ampiDefinitions.h:854
int AMPI_Keyval_free(int *keyval)
Definition ampiFunctions.hpp:14519
void AMPI_Iallgather_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:7150
int AMPI_Is_thread_main(int *flag)
Definition ampiFunctions.hpp:13815
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:12997
void AMPI_Ialltoallv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8777
int AMPI_Comm_size(MPI_Comm comm, int *size)
Definition ampiFunctions.hpp:13145
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:13614
int AMPI_Iscatter_finish(HandleBase *handle)
Definition ampiFunctions.hpp:11259
int AMPI_Buffer_attach(void *buffer, int size)
Definition ampiFunctions.hpp:12870
int AMPI_T_pvar_read(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void *buf)
Definition ampiFunctions.hpp:14440
int AMPI_File_set_size(MPI_File fh, MPI_Offset size)
Definition ampiFunctions.hpp:14116
void AMPI_Ssend_init_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4201
void AMPI_Allgather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4535
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:9733
int AMPI_Send_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:3644
int AMPI_Rsend_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:3134
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:4224
int AMPI_Get_version(int *version, int *subversion)
Definition ampiFunctions.hpp:13626
void AMPI_Ibcast_wrap_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9278
int AMPI_Cart_rank(MPI_Comm comm, const int *coords, int *rank)
Definition ampiFunctions.hpp:13372
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:11113
int AMPI_File_get_atomicity(MPI_File fh, int *flag)
Definition ampiFunctions.hpp:13865
int AMPI_T_category_get_cvars(int cat_index, int len, int *indices)
Definition ampiFunctions.hpp:14324
int AMPI_Dims_create(int nnodes, int ndims, int *dims)
Definition ampiFunctions.hpp:13396
void AMPI_Ialltoall_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8337
int AMPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence)
Definition ampiFunctions.hpp:14098
void AMPI_Gather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6400
void AMPI_Scatter_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:12255
int AMPI_Comm_remote_group(MPI_Comm comm, MPI_Group *group)
Definition ampiFunctions.hpp:13115
int AMPI_Info_set(MPI_Info info, const char *key, const char *value)
Definition ampiFunctions.hpp:13716
int AMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int *index, int *edges)
Definition ampiFunctions.hpp:13439
void AMPI_Bcast_wrap_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6068
int AMPI_File_get_errhandler(MPI_File file, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:13584
void AMPI_Imrecv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:885
int AMPI_Attr_get(MPI_Comm comm, int keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:14500
int AMPI_Igather_finish(HandleBase *handle)
Definition ampiFunctions.hpp:9879
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:13915
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:12679
void AMPI_Sendrecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3777
int AMPI_Cartdim_get(MPI_Comm comm, int *ndims)
Definition ampiFunctions.hpp:13390
void AMPI_Ibcast_wrap_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9194
void AMPI_Imrecv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:893
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:9317
MPI_Comm AMPI_Comm_f2c(MPI_Fint comm)
Definition ampiFunctions.hpp:14234
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:13452
void AMPI_Mrecv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2245
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:1776
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_Send_init_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3503
void AMPI_Iscatterv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11405
int AMPI_File_iread_at(MPI_File fh, MPI_Offset offset, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13936
int AMPI_Win_create_errhandler(AMPI_Win_errhandler_function *win_errhandler_fn, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:13644
void AMPI_Iscatterv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11479
void AMPI_Igatherv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:10174
int AMPI_File_read_at_all_begin(MPI_File fh, MPI_Offset offset, void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:14053
void AMPI_Rsend_init_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3066
int AMPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info, MPI_File *fh)
Definition ampiFunctions.hpp:13996
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:13004
void AMPI_Ibsend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:282
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_Ssend_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4095
void AMPI_Mrecv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2263
void AMPI_Gather_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:6443
void AMPI_Ibcast_wrap_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:9295
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:14045
int AMPI_Comm_set_name(MPI_Comm comm, const char *comm_name)
Definition ampiFunctions.hpp:13139
int AMPI_Igatherv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:10358
int AMPI_Comm_set_info(MPI_Comm comm, MPI_Info info)
Definition ampiFunctions.hpp:13133
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:13255
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:13767
MPI_Fint AMPI_Win_c2f(MPI_Win win)
Definition ampiFunctions.hpp:14300
int AMPI_Win_get_name(MPI_Win win, char *win_name, int *resultlen)
Definition ampiFunctions.hpp:13328
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:14104
int AMPI_T_init_thread(int required, int *provided)
Definition ampiFunctions.hpp:14409
int AMPI_T_category_get_categories(int cat_index, int len, int *indices)
Definition ampiFunctions.hpp:14318
void AMPI_Iallgather_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7094
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:1297
int AMPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
Definition ampiFunctions.hpp:14506
void AMPI_Allreduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5122
void AMPI_Bsend_init_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:520
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:8436
int AMPI_Group_range_incl(MPI_Group group, int n, ::medi::common::Range *ranges, MPI_Group *newgroup)
Definition ampiFunctions.hpp:13211
int AMPI_File_delete(const char *filename, MPI_Info info)
Definition ampiFunctions.hpp:13853
int AMPI_Group_rank(MPI_Group group, int *rank)
Definition ampiFunctions.hpp:13217
int AMPI_Rsend_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:3216
void AMPI_Ialltoallv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8730
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_Scatter_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:12318
void AMPI_Ibcast_wrap_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9252
void AMPI_Irsend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1438
int AMPI_File_iwrite(MPI_File fh, const void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13959
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:10069
void AMPI_Ibcast_wrap_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9171
void AMPI_Irecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1092
int AMPI_File_set_info(MPI_File fh, MPI_Info info)
Definition ampiFunctions.hpp:14110
int AMPI_Status_set_elements_x(MPI_Status *status, DATATYPE *datatype, MPI_Count count)
Definition ampiFunctions.hpp:13841
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:13303
void AMPI_Isend_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:1766
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
void AMPI_Allreduce_global_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:5194
int AMPI_Comm_test_inter(MPI_Comm comm, int *flag)
Definition ampiFunctions.hpp:13163
int AMPI_Ssend_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:4351
int AMPI_Cart_map(MPI_Comm comm, int ndims, const int *dims, const int *periods, int *newrank)
Definition ampiFunctions.hpp:13365
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:13989
int AMPI_Comm_idup(MPI_Comm comm, MPI_Comm *newcomm, AMPI_Request *request)
Definition ampiFunctions.hpp:13103
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:13042
int AMPI_Cart_shift(MPI_Comm comm, int direction, int disp, int *rank_source, int *rank_dest)
Definition ampiFunctions.hpp:13378
void AMPI_Isend_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1744
double AMPI_Wtick()
Definition ampiFunctions.hpp:13476
int AMPI_Lookup_name(const char *service_name, MPI_Info info, char *port_name)
Definition ampiFunctions.hpp:13776
int AMPI_T_cvar_get_num(int *num_cvar)
Definition ampiFunctions.hpp:14361
void AMPI_Ssend_init_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4210
void AMPI_Ialltoallv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:8843
int AMPI_Comm_get_attr(MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:13079
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:13067
int AMPI_Recv_init_finish(HandleBase *handle)
Definition ampiFunctions.hpp:2780
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:1449
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:6097
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:13316
void AMPI_Ireduce_global_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:10652
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:13181
int AMPI_Request_get_status(AMPI_Request request, int *flag, MPI_Status *status)
Definition ampiFunctions.hpp:12907
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:8705
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:7172
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:12889
void AMPI_Iallgatherv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7502
ADToolInterface const * selectADTool(ADToolInterface const &tool)
Definition adToolInterface.h:363
int AMPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status)
Definition ampiFunctions.hpp:14294
int AMPI_File_set_errhandler(MPI_File file, MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:13590
void(* ForwardFunction)(HandleBase *h, AdjointInterface *a)
Definition typeDefinitions.h:49
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:369
MPI_Group AMPI_Group_f2c(MPI_Fint group)
Definition ampiFunctions.hpp:14270
int AMPI_File_read(MPI_File fh, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:14010
void AMPI_Irecv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1172
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:12285
int AMPI_Intercomm_merge(MPI_Comm intercomm, int high, MPI_Comm *newintracomm)
Definition ampiFunctions.hpp:13249
int AMPI_File_preallocate(MPI_File fh, MPI_Offset size)
Definition ampiFunctions.hpp:14003
void AMPI_Ssend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4051
void AMPI_Iallgather_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7072
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:13121
int AMPI_Type_delete_attr(DATATYPE *datatype, int type_keyval)
Definition ampiFunctions.hpp:13263
void AMPI_Ialltoall_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:8424
int AMPI_Status_set_elements(MPI_Status *status, DATATYPE *datatype, int count)
Definition ampiFunctions.hpp:13834
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:7032
int AMPI_Group_size(MPI_Group group, int *size)
Definition ampiFunctions.hpp:13223
void AMPI_Recv_init_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2628
MPI_Info AMPI_Info_f2c(MPI_Fint info)
Definition ampiFunctions.hpp:14282
void AMPI_Iallgather_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:7160
int AMPI_Info_create(MPI_Info *info)
Definition ampiFunctions.hpp:13668
int AMPI_T_category_get_pvars(int cat_index, int len, int *indices)
Definition ampiFunctions.hpp:14349
void AMPI_Ialltoallv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8824
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_Mrecv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2285
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:8567
int AMPI_Finalize()
Definition ampiFunctions.hpp:13596
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:10188
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:337
int AMPI_Issend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:2143
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:3834
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:13432
void AMPI_Allgather_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4480
int AMPI_Info_get(MPI_Info info, const char *key, int valuelen, char *value, int *flag)
Definition ampiFunctions.hpp:13692
MPI_Fint AMPI_Info_c2f(MPI_Info info)
Definition ampiFunctions.hpp:14276
int AMPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:13662
int AMPI_File_get_group(MPI_File fh, MPI_Group *group)
Definition ampiFunctions.hpp:13877
void AMPI_Bcast_wrap_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:6141
void AMPI_Ialltoallv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:8853
int AMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:13542
int AMPI_File_read_shared(MPI_File fh, void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:14086
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:14427
void AMPI_Irsend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1409
void AMPI_Irecv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:1183
void AMPI_Isend_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:1757
void AMPI_Allgather_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4575
void AMPI_Igather_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9576
int AMPI_Get_address(const void *location, MPI_Aint *address)
Definition ampiFunctions.hpp:12931
int AMPI_Win_set_attr(MPI_Win win, int win_keyval, void *attribute_val)
Definition ampiFunctions.hpp:13334
void AMPI_Imrecv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:853
int AMPI_Query_thread(int *provided)
Definition ampiFunctions.hpp:13821
int AMPI_File_sync(MPI_File fh)
Definition ampiFunctions.hpp:14130
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:5425
int AMPI_Rsend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:2968
void AMPI_Igather_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9600
void AMPI_Gatherv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:6769
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:3517
void AMPI_Igather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9663
int AMPI_Ssend(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:4103
int AMPI_T_pvar_reset(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
Definition ampiFunctions.hpp:14452
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:13632
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:7986
void AMPI_Igatherv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10095
int AMPI_Group_range_excl(MPI_Group group, int n, ::medi::common::Range *ranges, MPI_Group *newgroup)
Definition ampiFunctions.hpp:13205
int AMPI_Type_set_attr(DATATYPE *datatype, int type_keyval, void *attribute_val)
Definition ampiFunctions.hpp:13290
double AMPI_Wtime()
Definition ampiFunctions.hpp:13482
int AMPI_File_set_view(MPI_File fh, MPI_Offset disp, ETYPE *etype, FILETYPE *filetype, const char *datarep, MPI_Info info)
Definition ampiFunctions.hpp:14123
int AMPI_Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status)
Definition ampiFunctions.hpp:12895
void AMPI_Send_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3362
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:11045
void AMPI_Rsend_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2960
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:14421
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
void(*)(void *id, void *userData) CallbackFunc
Definition typeDefinitions.h:45
void AMPI_Allgatherv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4874
void AMPI_Ssend_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4086
int AMPI_File_write(MPI_File fh, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:14137
void AMPI_Iscatter_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11004
int AMPI_Iscatterv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:11741
int AMPI_Dist_graph_neighbors(MPI_Comm comm, int maxindegree, int *sources, int *sourceweights, int maxoutdegree, int *destinations, int *destweights)
Definition ampiFunctions.hpp:13419
void AMPI_Ssend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4033
int AMPI_Comm_get_name(MPI_Comm comm, char *comm_name, int *resultlen)
Definition ampiFunctions.hpp:13091
void AMPI_Scatterv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:12621
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
void AMPI_Issend_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2037
int AMPI_T_category_get_index(const char *name, int *cat_index)
Definition ampiFunctions.hpp:14330
void AMPI_Sendrecv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3874
void AMPI_Recv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2501
void AMPI_Ialltoall_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8399
void AMPI_Gather_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6371
int AMPI_Get_elements_x(const MPI_Status *status, DATATYPE *datatype, MPI_Count *count)
Definition ampiFunctions.hpp:12945
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:14246
int AMPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13055
int AMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
Definition ampiFunctions.hpp:13175
void AMPI_Iscatter_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10960
void AMPI_Scatterv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:12657
void AMPI_Ssend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4069
void AMPI_Alltoall_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:5480
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:13402
int AMPI_Grequest_complete(AMPI_Request request)
Definition ampiFunctions.hpp:13802
void AMPI_Iallgather_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7109
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:13229
void AMPI_Gather_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:6434
int AMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
Definition ampiFunctions.hpp:13024
void AMPI_Iallgatherv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:7564
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:14017
void AMPI_Irsend_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:1477
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:13518
int AMPI_Type_get_extent_x(DATATYPE *datatype, MPI_Count *lb, MPI_Count *extent)
Definition ampiFunctions.hpp:12976
int AMPI_Win_delete_attr(MPI_Win win, int win_keyval)
Definition ampiFunctions.hpp:13310
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:904
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:14252
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:5203
void AMPI_Igather_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:9692
MPI_Fint AMPI_Group_c2f(MPI_Group group)
Definition ampiFunctions.hpp:14264
void AMPI_Iscatterv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11453
void AMPI_Imrecv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:840
int AMPI_T_pvar_session_free(MPI_T_pvar_session *session)
Definition ampiFunctions.hpp:14464
int AMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int *nneighbors)
Definition ampiFunctions.hpp:13458
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:11570
void AMPI_Ibcast_wrap_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:9306
int AMPI_Ibsend_finish(HandleBase *handle)
Definition ampiFunctions.hpp:456
int AMPI_File_write_shared(MPI_File fh, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:14214
void AMPI_Ireduce_global_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:10643
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:8865
int AMPI_Info_get_valuelen(MPI_Info info, const char *key, int *valuelen, int *flag)
Definition ampiFunctions.hpp:13710
int AMPI_Win_set_name(MPI_Win win, const char *win_name)
Definition ampiFunctions.hpp:13340
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:13410
void AMPI_Irsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1391
void AMPI_Recv_init_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2620
void AMPI_Recv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2451
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:2643
int AMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13151
int AMPI_Type_get_true_extent(DATATYPE *datatype, MPI_Aint *true_lb, MPI_Aint *true_extent)
Definition ampiFunctions.hpp:12983
int AMPI_File_get_byte_offset(MPI_File fh, MPI_Offset offset, MPI_Offset *disp)
Definition ampiFunctions.hpp:13871
int AMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr)
Definition ampiFunctions.hpp:13512
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:13620
void AMPI_Rsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2898
int AMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13030
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:13742
int AMPI_Win_call_errhandler(MPI_Win win, int errorcode)
Definition ampiFunctions.hpp:13638
void AMPI_Igatherv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10045
int AMPI_T_pvar_handle_free(MPI_T_pvar_session session, MPI_T_pvar_handle *handle)
Definition ampiFunctions.hpp:14434
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:13536
int AMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13157
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
void AMPI_Bsend_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:134
void AMPI_Iscatterv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:11546
int AMPI_Add_error_string(int errorcode, const char *string)
Definition ampiFunctions.hpp:13506
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:1202
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:14220
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:2009
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:7054
MPI_Fint AMPI_Errhandler_c2f(MPI_Errhandler errhandler)
Definition ampiFunctions.hpp:14240
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:7586
int AMPI_Comm_get_parent(MPI_Comm *parent)
Definition ampiFunctions.hpp:13748
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:13193
int AMPI_Comm_set_attr(MPI_Comm comm, int comm_keyval, void *attribute_val)
Definition ampiFunctions.hpp:13127
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:4269
void AMPI_Iallgatherv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7458
void AMPI_Irecv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:1191
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:13760
int AMPI_Op_commutative(AMPI_Op op, int *commute)
Definition ampiFunctions.hpp:13016
void AMPI_Iscatter_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11072
void AMPI_Allgatherv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4831
int AMPI_Buffer_detach(void *buffer_addr, int *size)
Definition ampiFunctions.hpp:12876
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:13929
void AMPI_Rsend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2916
void AMPI_Issend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1951
void AMPI_Imrecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:794
int AMPI_Finalized(int *flag)
Definition ampiFunctions.hpp:13602
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:5500
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:14194
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:14037
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:14355
int AMPI_File_read_all_begin(MPI_File fh, void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:14024
int AMPI_Bcast_wrap(typename DATATYPE::Type *bufferSend, typename DATATYPE::Type *bufferRecv, int count, DATATYPE *datatype, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:6150
void AMPI_Allgatherv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4802
void AMPI_Iallreduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7917
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:13788
void AMPI_Rsend_init_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3075
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:11498
int AMPI_Imrecv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:995
void AMPI_Isend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1729
void AMPI_Allreduce_global_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5092
int AMPI_File_get_type_extent(MPI_File fh, DATATYPE *datatype, MPI_Aint *extent)
Definition ampiFunctions.hpp:13908
int AMPI_Recv_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:2689
void AMPI_Ialltoall_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8359
void AMPI_Rsend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2934
void AMPI_Ibsend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:293
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:13795
int AMPI_Bsend_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:711
void AMPI_Ibsend_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:264
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:12552
int AMPI_Rsend_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:3257
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:8030
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:6791
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:12588
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:10499
void AMPI_Gatherv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6698
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:13847
void AMPI_Ibsend_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:359
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:9236
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:9453
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:3807
int AMPI_T_pvar_session_create(MPI_T_pvar_session *session)
Definition ampiFunctions.hpp:14458
int AMPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
Definition ampiFunctions.hpp:13236
void AMPI_Alltoallv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5726
void AMPI_Send_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:3326
void AMPI_Iallreduce_global_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:8008
void AMPI_Reduce_global_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11913
int(* ContinueFunction)(HandleBase *h)
Definition typeDefinitions.h:52
void AMPI_Iscatterv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:11558
void AMPI_Reduce_global_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:11994
void AMPI_Iallreduce_global_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7897
void AMPI_Alltoallv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:5795
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:14187
int AMPI_Type_get_extent(DATATYPE *datatype, MPI_Aint *lb, MPI_Aint *extent)
Definition ampiFunctions.hpp:12969
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_Ibsend_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:350
void AMPI_Mrecv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2225
int AMPI_Test_cancelled(const MPI_Status *status, int *flag)
Definition ampiFunctions.hpp:12913
void AMPI_Iallreduce_global_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7941
void AMPI_Ireduce_global_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10572
void AMPI_Allgatherv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:4770
void AMPI_Rsend_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2951
void AMPI_Send_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3388
void AMPI_Iallgather_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7134
void AMPI_Allreduce_global_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:5185
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:13566
int AMPI_File_write_at_all_begin(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:14180
int AMPI_Type_get_envelope(DATATYPE *datatype, int *num_integers, int *num_addresses, int *num_datatypes, int *combiner)
Definition ampiFunctions.hpp:12961
int AMPI_Group_free(MPI_Group *group)
Definition ampiFunctions.hpp:13187
void AMPI_Ialltoall_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8374
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:6660
void AMPI_Iallgatherv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7478
void AMPI_Imrecv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:874
int AMPI_Cart_sub(MPI_Comm comm, const int *remain_dims, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13384
int AMPI_File_read_ordered_begin(MPI_File fh, void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:14073
void AMPI_Isend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1700
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:13883
int AMPI_File_iread_shared(MPI_File fh, void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13952
int AMPI_Comm_accept(const char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13728
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:14343
void AMPI_Alltoall_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5451
int AMPI_Recv_init_postEnd(HandleBase *handle)
Definition ampiFunctions.hpp:2827
MPI_Fint AMPI_Comm_c2f(MPI_Comm comm)
Definition ampiFunctions.hpp:14228
void AMPI_Issend_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2024
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:13944
void AMPI_Recv_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:2429
int AMPI_Send_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:3562
void AMPI_Isend_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1689
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:14172
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
void AMPI_Bsend_init_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:529
int AMPI_File_write_ordered_begin(MPI_File fh, const void *buf, int count, DATATYPE *datatype)
Definition ampiFunctions.hpp:14201
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:14288
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
void AMPI_Allgatherv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4864
int AMPI_Graphdims_get(MPI_Comm comm, int *nnodes, int *nedges)
Definition ampiFunctions.hpp:13464
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:7546
int AMPI_File_write_all(MPI_File fh, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:14144
int AMPI_Comm_connect(const char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13735
void AMPI_Bcast_wrap_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:6036
int AMPI_Type_get_name(DATATYPE *datatype, char *type_name, int *resultlen)
Definition ampiFunctions.hpp:13283
void AMPI_Ibsend_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:322
int AMPI_T_cvar_read(MPI_T_cvar_handle handle, void *buf)
Definition ampiFunctions.hpp:14379
void AMPI_Irecv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1151
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:13981
int AMPI_File_write_at(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype, MPI_Status *status)
Definition ampiFunctions.hpp:14164
void AMPI_Igatherv_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10145
void AMPI_Irecv_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1107
void AMPI_Gatherv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:6779
int AMPI_T_pvar_get_index(const char *name, int var_class, int *pvar_index)
Definition ampiFunctions.hpp:14415
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:10665
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:13242
int AMPI_Type_get_attr(DATATYPE *datatype, int type_keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:13276
void(* ReverseFunction)(HandleBase *h, AdjointInterface *a)
Definition typeDefinitions.h:48
int AMPI_Type_free_keyval(int *type_keyval)
Definition ampiFunctions.hpp:13269
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:1496
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:13488
void AMPI_Scatter_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:12222
int AMPI_File_iwrite_at(MPI_File fh, MPI_Offset offset, const void *buf, int count, DATATYPE *datatype, AMPI_Request *request)
Definition ampiFunctions.hpp:13973
int AMPI_Ireduce_global_finish(HandleBase *handle)
Definition ampiFunctions.hpp:10819
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:14367
int AMPI_Win_get_attr(MPI_Win win, int win_keyval, void *attribute_val, int *flag)
Definition ampiFunctions.hpp:13322
void AMPI_Sendrecv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3864
void AMPI_Allreduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:5149
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:2510
int AMPI_Comm_get_info(MPI_Comm comm, MPI_Info *info_used)
Definition ampiFunctions.hpp:13085
int AMPI_Bsend_init_preStart(HandleBase *handle)
Definition ampiFunctions.hpp:588
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:12340
void AMPI_Ialltoall_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8319
int AMPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int tag, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13036
MPI_File AMPI_File_f2c(MPI_Fint file)
Definition ampiFunctions.hpp:14258
int AMPI_File_read_ordered_end(MPI_File fh, void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:14079
void AMPI_Reduce_global_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:11877
void AMPI_Iallreduce_global_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:7958
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_Reduce_global_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:11985
void AMPI_Irsend_b_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1464
int AMPI_Iallgatherv_finish(HandleBase *handle)
Definition ampiFunctions.hpp:7742
void AMPI_Iscatter_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:11101
int AMPI_Error_string(int errorcode, char *string, int *resultlen)
Definition ampiFunctions.hpp:13560
int AMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm *newcomm)
Definition ampiFunctions.hpp:13061
int AMPI_T_cvar_handle_free(MPI_T_cvar_handle *handle)
Definition ampiFunctions.hpp:14373
int AMPI_Comm_create_errhandler(AMPI_Comm_errhandler_function *comm_errhandler_fn, MPI_Errhandler *errhandler)
Definition ampiFunctions.hpp:13524
int AMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence)
Definition ampiFunctions.hpp:14092
void AMPI_Bsend_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:125
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:12952
void AMPI_Send_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:3379
int AMPI_Cart_get(MPI_Comm comm, int maxdims, int *dims, int *periods, int *coords)
Definition ampiFunctions.hpp:13359
void AMPI_Ialltoallv_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8752
int AMPI_Send(const typename DATATYPE::Type *buf, int count, DATATYPE *datatype, int dest, int tag, MPI_Comm comm)
Definition ampiFunctions.hpp:3396
void AMPI_Issend_d(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1980
void AMPI_Ireduce_global_p_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:10524
int AMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
Definition ampiFunctions.hpp:13169
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:3884
void AMPI_Ialltoall_p(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8297
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:14312
void AMPI_Isend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1718
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:4509
int AMPI_Comm_rank(MPI_Comm comm, int *rank)
Definition ampiFunctions.hpp:13109
int AMPI_Info_get_nkeys(MPI_Info info, int *nkeys)
Definition ampiFunctions.hpp:13698
void AMPI_Mrecv_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2293
int AMPI_Cancel(AMPI_Request *request)
Definition ampiFunctions.hpp:12882
void AMPI_Allgather_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:4565
void AMPI_Ialltoallv_b(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:8796
void AMPI_Irecv_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:1138
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:14059
int AMPI_T_cvar_write(MPI_T_cvar_handle handle, const void *buf)
Definition ampiFunctions.hpp:14385
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:10621
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:14030
void AMPI_Igather_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:9709
void AMPI_Iscatter_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:11089
MPI_Comm_copy_attr_function AMPI_Comm_copy_attr_function
Definition ampiDefinitions.h:830
void AMPI_Issend_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2046
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
void AMPI_Recv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:2493
int AMPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, const void *buf)
Definition ampiFunctions.hpp:14482
void AMPI_Igatherv_iterIn(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:10164
int AMPI_Error_class(int errorcode, int *errorclass)
Definition ampiFunctions.hpp:13554
void AMPI_Ibsend_d_finish(HandleBase *handle, AdjointInterface *adjointInterface)
Definition ampiFunctions.hpp:311
void AMPI_Igather_iterOut(HandleBase *handle, CallbackFunc func, void *userData)
Definition ampiFunctions.hpp:9719
int AMPI_File_write_ordered_end(MPI_File fh, const void *buf, MPI_Status *status)
Definition ampiFunctions.hpp:14207
int AMPI_Keyval_create(AMPI_Copy_function *copy_fn, AMPI_Delete_function *delete_fn, int *keyval, void *extra_state)
Definition ampiFunctions.hpp:14512
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:4434
int sendbufTotalSize
Definition ampiFunctions.hpp:4435
int recvbufCountVec
Definition ampiFunctions.hpp:4449
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:4444
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:4445
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:4437
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:4436
int sendcount
Definition ampiFunctions.hpp:4441
void * recvbufAdjoints
Definition ampiFunctions.hpp:4447
int recvbufTotalSize
Definition ampiFunctions.hpp:4443
void * sendbufAdjoints
Definition ampiFunctions.hpp:4438
int recvbufCount
Definition ampiFunctions.hpp:4448
int recvcount
Definition ampiFunctions.hpp:4450
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:4446
~AMPI_Allgather_AdjointHandle()
Definition ampiFunctions.hpp:4454
int sendbufCountVec
Definition ampiFunctions.hpp:4440
int sendbufCount
Definition ampiFunctions.hpp:4439
RECVTYPE * recvtype
Definition ampiFunctions.hpp:4451
MPI_Comm comm
Definition ampiFunctions.hpp:4452
SENDTYPE * sendtype
Definition ampiFunctions.hpp:4442
Definition ampiFunctions.hpp:4718
int * recvbufCount
Definition ampiFunctions.hpp:4732
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:4721
int sendbufTotalSize
Definition ampiFunctions.hpp:4719
void * sendbufAdjoints
Definition ampiFunctions.hpp:4722
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:4720
MPI_Comm comm
Definition ampiFunctions.hpp:4738
void * recvbufAdjoints
Definition ampiFunctions.hpp:4731
int * recvbufDisplsVec
Definition ampiFunctions.hpp:4734
int * recvbufCountVec
Definition ampiFunctions.hpp:4733
int sendbufCountVec
Definition ampiFunctions.hpp:4724
SENDTYPE * sendtype
Definition ampiFunctions.hpp:4726
int sendcount
Definition ampiFunctions.hpp:4725
int recvbufTotalSize
Definition ampiFunctions.hpp:4727
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:4728
RECVTYPE * recvtype
Definition ampiFunctions.hpp:4737
~AMPI_Allgatherv_AdjointHandle()
Definition ampiFunctions.hpp:4740
int sendbufCount
Definition ampiFunctions.hpp:4723
const int * recvcounts
Definition ampiFunctions.hpp:4735
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:4730
const int * displs
Definition ampiFunctions.hpp:4736
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:4729
Definition ampiFunctions.hpp:5047
~AMPI_Allreduce_global_AdjointHandle()
Definition ampiFunctions.hpp:5066
void * sendbufAdjoints
Definition ampiFunctions.hpp:5051
void * recvbufAdjoints
Definition ampiFunctions.hpp:5058
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:5056
DATATYPE * datatype
Definition ampiFunctions.hpp:5062
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:5055
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:5049
int count
Definition ampiFunctions.hpp:5061
int sendbufCountVec
Definition ampiFunctions.hpp:5053
int recvbufCountVec
Definition ampiFunctions.hpp:5060
MPI_Comm comm
Definition ampiFunctions.hpp:5064
int sendbufTotalSize
Definition ampiFunctions.hpp:5048
int sendbufCount
Definition ampiFunctions.hpp:5052
int recvbufTotalSize
Definition ampiFunctions.hpp:5054
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:5050
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:5057
AMPI_Op op
Definition ampiFunctions.hpp:5063
int recvbufCount
Definition ampiFunctions.hpp:5059
Definition ampiFunctions.hpp:5350
void * sendbufAdjoints
Definition ampiFunctions.hpp:5354
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:5360
int sendbufCount
Definition ampiFunctions.hpp:5355
int sendbufTotalSize
Definition ampiFunctions.hpp:5351
int recvbufCountVec
Definition ampiFunctions.hpp:5365
int sendcount
Definition ampiFunctions.hpp:5357
SENDTYPE * sendtype
Definition ampiFunctions.hpp:5358
int recvcount
Definition ampiFunctions.hpp:5366
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:5361
int recvbufTotalSize
Definition ampiFunctions.hpp:5359
MPI_Comm comm
Definition ampiFunctions.hpp:5368
RECVTYPE * recvtype
Definition ampiFunctions.hpp:5367
int sendbufCountVec
Definition ampiFunctions.hpp:5356
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:5362
int recvbufCount
Definition ampiFunctions.hpp:5364
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:5353
~AMPI_Alltoall_AdjointHandle()
Definition ampiFunctions.hpp:5370
void * recvbufAdjoints
Definition ampiFunctions.hpp:5363
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:5352
Definition ampiFunctions.hpp:5632
const int * rdispls
Definition ampiFunctions.hpp:5652
int * recvbufCount
Definition ampiFunctions.hpp:5648
int * sendbufCount
Definition ampiFunctions.hpp:5637
MPI_Comm comm
Definition ampiFunctions.hpp:5654
~AMPI_Alltoallv_AdjointHandle()
Definition ampiFunctions.hpp:5656
void * recvbufAdjoints
Definition ampiFunctions.hpp:5647
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:5644
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:5645
SENDTYPE * sendtype
Definition ampiFunctions.hpp:5642
int * recvbufCountVec
Definition ampiFunctions.hpp:5649
const int * sdispls
Definition ampiFunctions.hpp:5641
int * sendbufDisplsVec
Definition ampiFunctions.hpp:5639
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:5635
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:5646
const int * sendcounts
Definition ampiFunctions.hpp:5640
void * sendbufAdjoints
Definition ampiFunctions.hpp:5636
int * recvbufDisplsVec
Definition ampiFunctions.hpp:5650
RECVTYPE * recvtype
Definition ampiFunctions.hpp:5653
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:5634
const int * recvcounts
Definition ampiFunctions.hpp:5651
int sendbufTotalSize
Definition ampiFunctions.hpp:5633
int * sendbufCountVec
Definition ampiFunctions.hpp:5638
int recvbufTotalSize
Definition ampiFunctions.hpp:5643
Definition ampiFunctions.hpp:5991
int bufferRecvCountVec
Definition ampiFunctions.hpp:6004
int bufferSendTotalSize
Definition ampiFunctions.hpp:5992
int bufferRecvCount
Definition ampiFunctions.hpp:6003
DATATYPE::PrimalType * bufferSendPrimals
Definition ampiFunctions.hpp:5994
void * bufferRecvAdjoints
Definition ampiFunctions.hpp:6002
int bufferSendCount
Definition ampiFunctions.hpp:5996
int bufferRecvTotalSize
Definition ampiFunctions.hpp:5998
int root
Definition ampiFunctions.hpp:6007
MPI_Comm comm
Definition ampiFunctions.hpp:6008
DATATYPE::PrimalType * bufferRecvPrimals
Definition ampiFunctions.hpp:6000
int count
Definition ampiFunctions.hpp:6005
void * bufferSendAdjoints
Definition ampiFunctions.hpp:5995
DATATYPE * datatype
Definition ampiFunctions.hpp:6006
int bufferSendCountVec
Definition ampiFunctions.hpp:5997
DATATYPE::PrimalType * bufferRecvOldPrimals
Definition ampiFunctions.hpp:6001
~AMPI_Bcast_wrap_AdjointHandle()
Definition ampiFunctions.hpp:6010
DATATYPE::IndexType * bufferRecvIndices
Definition ampiFunctions.hpp:5999
DATATYPE::IndexType * bufferSendIndices
Definition ampiFunctions.hpp:5993
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:507
AMPI_Request * request
Definition ampiFunctions.hpp:515
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:509
int count
Definition ampiFunctions.hpp:510
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:508
int tag
Definition ampiFunctions.hpp:513
DATATYPE * datatype
Definition ampiFunctions.hpp:511
int dest
Definition ampiFunctions.hpp:512
MPI_Comm comm
Definition ampiFunctions.hpp:514
Definition ampiFunctions.hpp:6290
int sendbufCount
Definition ampiFunctions.hpp:6295
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6298
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6307
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:6292
int sendcount
Definition ampiFunctions.hpp:6297
int sendbufTotalSize
Definition ampiFunctions.hpp:6291
int recvbufCountVec
Definition ampiFunctions.hpp:6305
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:6301
int recvcount
Definition ampiFunctions.hpp:6306
MPI_Comm comm
Definition ampiFunctions.hpp:6309
int sendbufCountVec
Definition ampiFunctions.hpp:6296
int root
Definition ampiFunctions.hpp:6308
int recvbufCount
Definition ampiFunctions.hpp:6304
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:6300
int recvbufTotalSize
Definition ampiFunctions.hpp:6299
~AMPI_Gather_AdjointHandle()
Definition ampiFunctions.hpp:6311
void * sendbufAdjoints
Definition ampiFunctions.hpp:6294
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:6302
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:6293
void * recvbufAdjoints
Definition ampiFunctions.hpp:6303
Definition ampiFunctions.hpp:6607
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6615
int sendcount
Definition ampiFunctions.hpp:6614
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:6617
const int * recvcounts
Definition ampiFunctions.hpp:6624
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6626
int sendbufCountVec
Definition ampiFunctions.hpp:6613
const int * displs
Definition ampiFunctions.hpp:6625
int root
Definition ampiFunctions.hpp:6627
int * recvbufCountVec
Definition ampiFunctions.hpp:6622
~AMPI_Gatherv_AdjointHandle()
Definition ampiFunctions.hpp:6630
void * recvbufAdjoints
Definition ampiFunctions.hpp:6620
void * sendbufAdjoints
Definition ampiFunctions.hpp:6611
int recvbufTotalSize
Definition ampiFunctions.hpp:6616
int * recvbufCount
Definition ampiFunctions.hpp:6621
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:6619
int sendbufCount
Definition ampiFunctions.hpp:6612
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:6610
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:6609
int * recvbufDisplsVec
Definition ampiFunctions.hpp:6623
int sendbufTotalSize
Definition ampiFunctions.hpp:6608
MPI_Comm comm
Definition ampiFunctions.hpp:6628
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:6618
Definition ampiFunctions.hpp:6973
int recvbufCount
Definition ampiFunctions.hpp:6987
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:6983
int sendcount
Definition ampiFunctions.hpp:6980
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:6984
int recvcount
Definition ampiFunctions.hpp:6989
int recvbufTotalSize
Definition ampiFunctions.hpp:6982
int recvbufCountVec
Definition ampiFunctions.hpp:6988
RECVTYPE * recvtype
Definition ampiFunctions.hpp:6990
void * sendbufAdjoints
Definition ampiFunctions.hpp:6977
SENDTYPE * sendtype
Definition ampiFunctions.hpp:6981
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:6975
int sendbufTotalSize
Definition ampiFunctions.hpp:6974
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:6976
int sendbufCount
Definition ampiFunctions.hpp:6978
~AMPI_Iallgather_AdjointHandle()
Definition ampiFunctions.hpp:6993
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:6985
int sendbufCountVec
Definition ampiFunctions.hpp:6979
void * recvbufAdjoints
Definition ampiFunctions.hpp:6986
MPI_Comm comm
Definition ampiFunctions.hpp:6991
Definition ampiFunctions.hpp:7018
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:7020
SENDTYPE * sendtype
Definition ampiFunctions.hpp:7022
MPI_Comm comm
Definition ampiFunctions.hpp:7027
int sendcount
Definition ampiFunctions.hpp:7021
RECVTYPE * recvtype
Definition ampiFunctions.hpp:7026
int recvcount
Definition ampiFunctions.hpp:7025
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:7019
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:7024
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:7023
AMPI_Request * request
Definition ampiFunctions.hpp:7028
Definition ampiFunctions.hpp:7367
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:7370
int * recvbufCount
Definition ampiFunctions.hpp:7381
MPI_Comm comm
Definition ampiFunctions.hpp:7387
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:7379
int * recvbufDisplsVec
Definition ampiFunctions.hpp:7383
const int * displs
Definition ampiFunctions.hpp:7385
int sendcount
Definition ampiFunctions.hpp:7374
void * sendbufAdjoints
Definition ampiFunctions.hpp:7371
int sendbufCountVec
Definition ampiFunctions.hpp:7373
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:7369
~AMPI_Iallgatherv_AdjointHandle()
Definition ampiFunctions.hpp:7389
SENDTYPE * sendtype
Definition ampiFunctions.hpp:7375
int sendbufTotalSize
Definition ampiFunctions.hpp:7368
void * recvbufAdjoints
Definition ampiFunctions.hpp:7380
int * recvbufCountVec
Definition ampiFunctions.hpp:7382
RECVTYPE * recvtype
Definition ampiFunctions.hpp:7386
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:7378
int sendbufCount
Definition ampiFunctions.hpp:7372
int recvbufTotalSize
Definition ampiFunctions.hpp:7376
const int * recvcounts
Definition ampiFunctions.hpp:7384
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:7377
Definition ampiFunctions.hpp:7418
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:7420
MPI_Comm comm
Definition ampiFunctions.hpp:7429
RECVTYPE * recvtype
Definition ampiFunctions.hpp:7428
SENDTYPE * sendtype
Definition ampiFunctions.hpp:7422
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:7419
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:7424
const int * recvcounts
Definition ampiFunctions.hpp:7426
int sendcount
Definition ampiFunctions.hpp:7421
AMPI_Request * request
Definition ampiFunctions.hpp:7430
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:7423
const int * displsMod
Definition ampiFunctions.hpp:7425
const int * displs
Definition ampiFunctions.hpp:7427
Definition ampiFunctions.hpp:7816
MPI_Comm comm
Definition ampiFunctions.hpp:7833
void * sendbufAdjoints
Definition ampiFunctions.hpp:7820
int recvbufCountVec
Definition ampiFunctions.hpp:7829
int count
Definition ampiFunctions.hpp:7830
~AMPI_Iallreduce_global_AdjointHandle()
Definition ampiFunctions.hpp:7835
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:7825
int recvbufTotalSize
Definition ampiFunctions.hpp:7823
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:7819
void * recvbufAdjoints
Definition ampiFunctions.hpp:7827
int recvbufCount
Definition ampiFunctions.hpp:7828
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:7818
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:7826
DATATYPE * datatype
Definition ampiFunctions.hpp:7831
int sendbufTotalSize
Definition ampiFunctions.hpp:7817
int sendbufCountVec
Definition ampiFunctions.hpp:7822
int sendbufCount
Definition ampiFunctions.hpp:7821
AMPI_Op op
Definition ampiFunctions.hpp:7832
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:7824
Definition ampiFunctions.hpp:7860
AMPI_Op op
Definition ampiFunctions.hpp:7867
DATATYPE * datatype
Definition ampiFunctions.hpp:7866
int count
Definition ampiFunctions.hpp:7865
DATATYPE::Type * recvbuf
Definition ampiFunctions.hpp:7863
DATATYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:7864
AMPI_Request * request
Definition ampiFunctions.hpp:7869
const DATATYPE::Type * sendbuf
Definition ampiFunctions.hpp:7861
MPI_Comm comm
Definition ampiFunctions.hpp:7868
DATATYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:7862
Definition ampiFunctions.hpp:8238
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8255
int sendcount
Definition ampiFunctions.hpp:8245
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:8248
int recvcount
Definition ampiFunctions.hpp:8254
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:8250
int recvbufTotalSize
Definition ampiFunctions.hpp:8247
int sendbufTotalSize
Definition ampiFunctions.hpp:8239
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:8249
MPI_Comm comm
Definition ampiFunctions.hpp:8256
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:8241
~AMPI_Ialltoall_AdjointHandle()
Definition ampiFunctions.hpp:8258
int sendbufCountVec
Definition ampiFunctions.hpp:8244
void * sendbufAdjoints
Definition ampiFunctions.hpp:8242
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8246
void * recvbufAdjoints
Definition ampiFunctions.hpp:8251
int sendbufCount
Definition ampiFunctions.hpp:8243
int recvbufCount
Definition ampiFunctions.hpp:8252
int recvbufCountVec
Definition ampiFunctions.hpp:8253
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:8240
Definition ampiFunctions.hpp:8283
MPI_Comm comm
Definition ampiFunctions.hpp:8292
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:8289
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:8284
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:8288
int sendcount
Definition ampiFunctions.hpp:8286
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:8285
AMPI_Request * request
Definition ampiFunctions.hpp:8293
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8291
int recvcount
Definition ampiFunctions.hpp:8290
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8287
Definition ampiFunctions.hpp:8630
int * sendbufCountVec
Definition ampiFunctions.hpp:8636
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8640
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:8632
const int * sdispls
Definition ampiFunctions.hpp:8639
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:8643
int * recvbufCountVec
Definition ampiFunctions.hpp:8647
~AMPI_Ialltoallv_AdjointHandle()
Definition ampiFunctions.hpp:8654
const int * recvcounts
Definition ampiFunctions.hpp:8649
MPI_Comm comm
Definition ampiFunctions.hpp:8652
int * recvbufDisplsVec
Definition ampiFunctions.hpp:8648
void * recvbufAdjoints
Definition ampiFunctions.hpp:8645
int sendbufTotalSize
Definition ampiFunctions.hpp:8631
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8651
const int * sendcounts
Definition ampiFunctions.hpp:8638
int * sendbufDisplsVec
Definition ampiFunctions.hpp:8637
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:8633
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:8644
int recvbufTotalSize
Definition ampiFunctions.hpp:8641
int * sendbufCount
Definition ampiFunctions.hpp:8635
int * recvbufCount
Definition ampiFunctions.hpp:8646
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:8642
void * sendbufAdjoints
Definition ampiFunctions.hpp:8634
const int * rdispls
Definition ampiFunctions.hpp:8650
Definition ampiFunctions.hpp:8687
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:8695
const int * rdisplsMod
Definition ampiFunctions.hpp:8696
const int * rdispls
Definition ampiFunctions.hpp:8698
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:8694
AMPI_Request * request
Definition ampiFunctions.hpp:8701
RECVTYPE * recvtype
Definition ampiFunctions.hpp:8699
SENDTYPE * sendtype
Definition ampiFunctions.hpp:8693
const int * sendcounts
Definition ampiFunctions.hpp:8691
const int * sdisplsMod
Definition ampiFunctions.hpp:8690
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:8689
const int * sdispls
Definition ampiFunctions.hpp:8692
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:8688
const int * recvcounts
Definition ampiFunctions.hpp:8697
MPI_Comm comm
Definition ampiFunctions.hpp:8700
Definition ampiFunctions.hpp:9114
int bufferSendTotalSize
Definition ampiFunctions.hpp:9115
DATATYPE::PrimalType * bufferRecvPrimals
Definition ampiFunctions.hpp:9123
~AMPI_Ibcast_wrap_AdjointHandle()
Definition ampiFunctions.hpp:9133
DATATYPE::PrimalType * bufferSendPrimals
Definition ampiFunctions.hpp:9117
MPI_Comm comm
Definition ampiFunctions.hpp:9131
int bufferSendCountVec
Definition ampiFunctions.hpp:9120
int bufferSendCount
Definition ampiFunctions.hpp:9119
int count
Definition ampiFunctions.hpp:9128
int bufferRecvTotalSize
Definition ampiFunctions.hpp:9121
DATATYPE::IndexType * bufferSendIndices
Definition ampiFunctions.hpp:9116
int root
Definition ampiFunctions.hpp:9130
void * bufferRecvAdjoints
Definition ampiFunctions.hpp:9125
DATATYPE::PrimalType * bufferRecvOldPrimals
Definition ampiFunctions.hpp:9124
DATATYPE * datatype
Definition ampiFunctions.hpp:9129
int bufferRecvCountVec
Definition ampiFunctions.hpp:9127
void * bufferSendAdjoints
Definition ampiFunctions.hpp:9118
DATATYPE::IndexType * bufferRecvIndices
Definition ampiFunctions.hpp:9122
int bufferRecvCount
Definition ampiFunctions.hpp:9126
Definition ampiFunctions.hpp:9158
DATATYPE::Type * bufferRecv
Definition ampiFunctions.hpp:9161
AMPI_Request * request
Definition ampiFunctions.hpp:9167
DATATYPE * datatype
Definition ampiFunctions.hpp:9164
int root
Definition ampiFunctions.hpp:9165
DATATYPE::ModifiedType * bufferSendMod
Definition ampiFunctions.hpp:9160
MPI_Comm comm
Definition ampiFunctions.hpp:9166
DATATYPE::ModifiedType * bufferRecvMod
Definition ampiFunctions.hpp:9162
DATATYPE::Type * bufferSend
Definition ampiFunctions.hpp:9159
int count
Definition ampiFunctions.hpp:9163
Definition ampiFunctions.hpp:226
int dest
Definition ampiFunctions.hpp:235
int bufCount
Definition ampiFunctions.hpp:231
int count
Definition ampiFunctions.hpp:233
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:229
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:228
int tag
Definition ampiFunctions.hpp:236
~AMPI_Ibsend_AdjointHandle()
Definition ampiFunctions.hpp:239
DATATYPE * datatype
Definition ampiFunctions.hpp:234
void * bufAdjoints
Definition ampiFunctions.hpp:230
MPI_Comm comm
Definition ampiFunctions.hpp:237
int bufTotalSize
Definition ampiFunctions.hpp:227
int bufCountVec
Definition ampiFunctions.hpp:232
Definition ampiFunctions.hpp:252
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:253
int count
Definition ampiFunctions.hpp:255
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:254
MPI_Comm comm
Definition ampiFunctions.hpp:259
AMPI_Request * request
Definition ampiFunctions.hpp:260
int dest
Definition ampiFunctions.hpp:257
int tag
Definition ampiFunctions.hpp:258
DATATYPE * datatype
Definition ampiFunctions.hpp:256
Definition ampiFunctions.hpp:9515
SENDTYPE * sendtype
Definition ampiFunctions.hpp:9523
int sendbufTotalSize
Definition ampiFunctions.hpp:9516
int sendbufCount
Definition ampiFunctions.hpp:9520
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:9527
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:9517
int sendbufCountVec
Definition ampiFunctions.hpp:9521
int root
Definition ampiFunctions.hpp:9533
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:9526
int recvbufCount
Definition ampiFunctions.hpp:9529
int recvbufCountVec
Definition ampiFunctions.hpp:9530
void * recvbufAdjoints
Definition ampiFunctions.hpp:9528
RECVTYPE * recvtype
Definition ampiFunctions.hpp:9532
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:9518
~AMPI_Igather_AdjointHandle()
Definition ampiFunctions.hpp:9536
void * sendbufAdjoints
Definition ampiFunctions.hpp:9519
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:9525
int sendcount
Definition ampiFunctions.hpp:9522
int recvcount
Definition ampiFunctions.hpp:9531
int recvbufTotalSize
Definition ampiFunctions.hpp:9524
MPI_Comm comm
Definition ampiFunctions.hpp:9534
Definition ampiFunctions.hpp:9561
AMPI_Request * request
Definition ampiFunctions.hpp:9572
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:9567
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:9563
MPI_Comm comm
Definition ampiFunctions.hpp:9571
int sendcount
Definition ampiFunctions.hpp:9564
RECVTYPE * recvtype
Definition ampiFunctions.hpp:9569
int recvcount
Definition ampiFunctions.hpp:9568
int root
Definition ampiFunctions.hpp:9570
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:9562
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:9566
SENDTYPE * sendtype
Definition ampiFunctions.hpp:9565
Definition ampiFunctions.hpp:9950
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:9962
int sendcount
Definition ampiFunctions.hpp:9957
~AMPI_Igatherv_AdjointHandle()
Definition ampiFunctions.hpp:9973
int * recvbufCount
Definition ampiFunctions.hpp:9964
const int * recvcounts
Definition ampiFunctions.hpp:9967
int root
Definition ampiFunctions.hpp:9970
void * sendbufAdjoints
Definition ampiFunctions.hpp:9954
int sendbufCountVec
Definition ampiFunctions.hpp:9956
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:9961
int * recvbufDisplsVec
Definition ampiFunctions.hpp:9966
void * recvbufAdjoints
Definition ampiFunctions.hpp:9963
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:9952
int sendbufCount
Definition ampiFunctions.hpp:9955
MPI_Comm comm
Definition ampiFunctions.hpp:9971
const int * displs
Definition ampiFunctions.hpp:9968
int recvbufTotalSize
Definition ampiFunctions.hpp:9959
SENDTYPE * sendtype
Definition ampiFunctions.hpp:9958
int sendbufTotalSize
Definition ampiFunctions.hpp:9951
RECVTYPE * recvtype
Definition ampiFunctions.hpp:9969
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:9960
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:9953
int * recvbufCountVec
Definition ampiFunctions.hpp:9965
Definition ampiFunctions.hpp:10002
MPI_Comm comm
Definition ampiFunctions.hpp:10014
int root
Definition ampiFunctions.hpp:10013
const int * displsMod
Definition ampiFunctions.hpp:10009
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:10007
AMPI_Request * request
Definition ampiFunctions.hpp:10015
int sendcount
Definition ampiFunctions.hpp:10005
RECVTYPE * recvtype
Definition ampiFunctions.hpp:10012
SENDTYPE * sendtype
Definition ampiFunctions.hpp:10006
const int * displs
Definition ampiFunctions.hpp:10011
const int * recvcounts
Definition ampiFunctions.hpp:10010
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:10008
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:10003
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:10004
Definition ampiFunctions.hpp:753
void * bufAdjoints
Definition ampiFunctions.hpp:758
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:757
int bufCountVec
Definition ampiFunctions.hpp:760
DATATYPE * datatype
Definition ampiFunctions.hpp:762
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:764
int bufCount
Definition ampiFunctions.hpp:759
int bufTotalSize
Definition ampiFunctions.hpp:754
~AMPI_Imrecv_AdjointHandle()
Definition ampiFunctions.hpp:766
int count
Definition ampiFunctions.hpp:761
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:756
AMPI_Message message
Definition ampiFunctions.hpp:763
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:755
Definition ampiFunctions.hpp:783
int count
Definition ampiFunctions.hpp:786
DATATYPE::Type * buf
Definition ampiFunctions.hpp:784
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:785
DATATYPE * datatype
Definition ampiFunctions.hpp:787
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:790
AMPI_Request * request
Definition ampiFunctions.hpp:789
AMPI_Message * message
Definition ampiFunctions.hpp:788
Definition ampiFunctions.hpp:1047
int bufCount
Definition ampiFunctions.hpp:1053
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:1049
int source
Definition ampiFunctions.hpp:1057
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:1060
int bufTotalSize
Definition ampiFunctions.hpp:1048
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:1051
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:1050
int tag
Definition ampiFunctions.hpp:1058
void * bufAdjoints
Definition ampiFunctions.hpp:1052
int bufCountVec
Definition ampiFunctions.hpp:1054
DATATYPE * datatype
Definition ampiFunctions.hpp:1056
MPI_Comm comm
Definition ampiFunctions.hpp:1059
int count
Definition ampiFunctions.hpp:1055
~AMPI_Irecv_AdjointHandle()
Definition ampiFunctions.hpp:1062
Definition ampiFunctions.hpp:1079
int count
Definition ampiFunctions.hpp:1082
int source
Definition ampiFunctions.hpp:1084
DATATYPE::Type * buf
Definition ampiFunctions.hpp:1080
int tag
Definition ampiFunctions.hpp:1085
DATATYPE * datatype
Definition ampiFunctions.hpp:1083
MPI_Comm comm
Definition ampiFunctions.hpp:1086
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1081
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:1088
AMPI_Request * request
Definition ampiFunctions.hpp:1087
Definition ampiFunctions.hpp:10440
int sendbufCount
Definition ampiFunctions.hpp:10445
~AMPI_Ireduce_global_AdjointHandle()
Definition ampiFunctions.hpp:10460
AMPI_Op op
Definition ampiFunctions.hpp:10456
DATATYPE * datatype
Definition ampiFunctions.hpp:10455
void * recvbufAdjoints
Definition ampiFunctions.hpp:10451
int root
Definition ampiFunctions.hpp:10457
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:10443
MPI_Comm comm
Definition ampiFunctions.hpp:10458
int sendbufTotalSize
Definition ampiFunctions.hpp:10441
int count
Definition ampiFunctions.hpp:10454
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:10450
void * sendbufAdjoints
Definition ampiFunctions.hpp:10444
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:10442
int sendbufCountVec
Definition ampiFunctions.hpp:10446
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:10449
int recvbufCountVec
Definition ampiFunctions.hpp:10453
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:10448
int recvbufTotalSize
Definition ampiFunctions.hpp:10447
int recvbufCount
Definition ampiFunctions.hpp:10452
Definition ampiFunctions.hpp:10485
const DATATYPE::Type * sendbuf
Definition ampiFunctions.hpp:10486
DATATYPE * datatype
Definition ampiFunctions.hpp:10491
DATATYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:10487
MPI_Comm comm
Definition ampiFunctions.hpp:10494
AMPI_Request * request
Definition ampiFunctions.hpp:10495
DATATYPE::Type * recvbuf
Definition ampiFunctions.hpp:10488
DATATYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:10489
int root
Definition ampiFunctions.hpp:10493
int count
Definition ampiFunctions.hpp:10490
AMPI_Op op
Definition ampiFunctions.hpp:10492
Definition ampiFunctions.hpp:1353
int bufCountVec
Definition ampiFunctions.hpp:1359
DATATYPE * datatype
Definition ampiFunctions.hpp:1361
int bufCount
Definition ampiFunctions.hpp:1358
MPI_Comm comm
Definition ampiFunctions.hpp:1364
int bufTotalSize
Definition ampiFunctions.hpp:1354
void * bufAdjoints
Definition ampiFunctions.hpp:1357
~AMPI_Irsend_AdjointHandle()
Definition ampiFunctions.hpp:1366
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:1355
int dest
Definition ampiFunctions.hpp:1362
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:1356
int tag
Definition ampiFunctions.hpp:1363
int count
Definition ampiFunctions.hpp:1360
Definition ampiFunctions.hpp:1379
int dest
Definition ampiFunctions.hpp:1384
AMPI_Request * request
Definition ampiFunctions.hpp:1387
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1381
DATATYPE * datatype
Definition ampiFunctions.hpp:1383
int count
Definition ampiFunctions.hpp:1382
MPI_Comm comm
Definition ampiFunctions.hpp:1386
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:1380
int tag
Definition ampiFunctions.hpp:1385
Definition ampiFunctions.hpp:10899
MPI_Comm comm
Definition ampiFunctions.hpp:10918
void * sendbufAdjoints
Definition ampiFunctions.hpp:10903
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:10911
SENDTYPE * sendtype
Definition ampiFunctions.hpp:10907
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:10901
int sendbufTotalSize
Definition ampiFunctions.hpp:10900
int sendbufCount
Definition ampiFunctions.hpp:10904
RECVTYPE * recvtype
Definition ampiFunctions.hpp:10916
int recvbufCountVec
Definition ampiFunctions.hpp:10914
~AMPI_Iscatter_AdjointHandle()
Definition ampiFunctions.hpp:10920
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:10909
int recvcount
Definition ampiFunctions.hpp:10915
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:10910
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:10902
int recvbufTotalSize
Definition ampiFunctions.hpp:10908
int root
Definition ampiFunctions.hpp:10917
void * recvbufAdjoints
Definition ampiFunctions.hpp:10912
int sendcount
Definition ampiFunctions.hpp:10906
int recvbufCount
Definition ampiFunctions.hpp:10913
int sendbufCountVec
Definition ampiFunctions.hpp:10905
Definition ampiFunctions.hpp:10945
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:10951
int root
Definition ampiFunctions.hpp:10954
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:10950
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:10947
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:10946
SENDTYPE * sendtype
Definition ampiFunctions.hpp:10949
RECVTYPE * recvtype
Definition ampiFunctions.hpp:10953
int sendcount
Definition ampiFunctions.hpp:10948
AMPI_Request * request
Definition ampiFunctions.hpp:10956
int recvcount
Definition ampiFunctions.hpp:10952
MPI_Comm comm
Definition ampiFunctions.hpp:10955
Definition ampiFunctions.hpp:11336
int recvcount
Definition ampiFunctions.hpp:11354
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:11348
const int * sendcounts
Definition ampiFunctions.hpp:11344
int sendbufTotalSize
Definition ampiFunctions.hpp:11337
int * sendbufCount
Definition ampiFunctions.hpp:11341
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:11338
int recvbufCountVec
Definition ampiFunctions.hpp:11353
RECVTYPE * recvtype
Definition ampiFunctions.hpp:11355
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:11350
int * sendbufCountVec
Definition ampiFunctions.hpp:11342
void * sendbufAdjoints
Definition ampiFunctions.hpp:11340
int * sendbufDisplsVec
Definition ampiFunctions.hpp:11343
SENDTYPE * sendtype
Definition ampiFunctions.hpp:11346
MPI_Comm comm
Definition ampiFunctions.hpp:11357
int root
Definition ampiFunctions.hpp:11356
int recvbufCount
Definition ampiFunctions.hpp:11352
void * recvbufAdjoints
Definition ampiFunctions.hpp:11351
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:11339
int recvbufTotalSize
Definition ampiFunctions.hpp:11347
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:11349
~AMPI_Iscatterv_AdjointHandle()
Definition ampiFunctions.hpp:11359
const int * displs
Definition ampiFunctions.hpp:11345
Definition ampiFunctions.hpp:11388
MPI_Comm comm
Definition ampiFunctions.hpp:11400
int root
Definition ampiFunctions.hpp:11399
RECVTYPE::ModifiedType * recvbufMod
Definition ampiFunctions.hpp:11396
RECVTYPE * recvtype
Definition ampiFunctions.hpp:11398
int recvcount
Definition ampiFunctions.hpp:11397
const int * displsMod
Definition ampiFunctions.hpp:11391
const SENDTYPE::Type * sendbuf
Definition ampiFunctions.hpp:11389
const int * displs
Definition ampiFunctions.hpp:11393
const int * sendcounts
Definition ampiFunctions.hpp:11392
AMPI_Request * request
Definition ampiFunctions.hpp:11401
SENDTYPE::ModifiedType * sendbufMod
Definition ampiFunctions.hpp:11390
RECVTYPE::Type * recvbuf
Definition ampiFunctions.hpp:11395
SENDTYPE * sendtype
Definition ampiFunctions.hpp:11394
Definition ampiFunctions.hpp:1633
int bufCountVec
Definition ampiFunctions.hpp:1639
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:1636
int tag
Definition ampiFunctions.hpp:1643
void * bufAdjoints
Definition ampiFunctions.hpp:1637
int count
Definition ampiFunctions.hpp:1640
~AMPI_Isend_AdjointHandle()
Definition ampiFunctions.hpp:1646
DATATYPE * datatype
Definition ampiFunctions.hpp:1641
int dest
Definition ampiFunctions.hpp:1642
MPI_Comm comm
Definition ampiFunctions.hpp:1644
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:1635
int bufCount
Definition ampiFunctions.hpp:1638
int bufTotalSize
Definition ampiFunctions.hpp:1634
Definition ampiFunctions.hpp:1659
int count
Definition ampiFunctions.hpp:1662
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:1660
int dest
Definition ampiFunctions.hpp:1664
DATATYPE * datatype
Definition ampiFunctions.hpp:1663
AMPI_Request * request
Definition ampiFunctions.hpp:1667
int tag
Definition ampiFunctions.hpp:1665
MPI_Comm comm
Definition ampiFunctions.hpp:1666
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1661
Definition ampiFunctions.hpp:1913
~AMPI_Issend_AdjointHandle()
Definition ampiFunctions.hpp:1926
int bufCountVec
Definition ampiFunctions.hpp:1919
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:1916
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:1915
int bufCount
Definition ampiFunctions.hpp:1918
MPI_Comm comm
Definition ampiFunctions.hpp:1924
int tag
Definition ampiFunctions.hpp:1923
int dest
Definition ampiFunctions.hpp:1922
void * bufAdjoints
Definition ampiFunctions.hpp:1917
int bufTotalSize
Definition ampiFunctions.hpp:1914
int count
Definition ampiFunctions.hpp:1920
DATATYPE * datatype
Definition ampiFunctions.hpp:1921
Definition ampiFunctions.hpp:1939
int count
Definition ampiFunctions.hpp:1942
AMPI_Request * request
Definition ampiFunctions.hpp:1947
int tag
Definition ampiFunctions.hpp:1945
int dest
Definition ampiFunctions.hpp:1944
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:1941
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:1940
DATATYPE * datatype
Definition ampiFunctions.hpp:1943
MPI_Comm comm
Definition ampiFunctions.hpp:1946
Stores additional information for a MPI_Message.
Definition message.hpp:44
MPI_Message message
Definition message.hpp:45
Definition ampiFunctions.hpp:2193
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:2196
~AMPI_Mrecv_AdjointHandle()
Definition ampiFunctions.hpp:2207
int bufTotalSize
Definition ampiFunctions.hpp:2194
int count
Definition ampiFunctions.hpp:2201
RecvAdjCall reverse_send
Definition ampiFunctions.hpp:2205
int bufCountVec
Definition ampiFunctions.hpp:2200
AMPI_Message message
Definition ampiFunctions.hpp:2203
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:2197
DATATYPE * datatype
Definition ampiFunctions.hpp:2202
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:2195
int bufCount
Definition ampiFunctions.hpp:2199
void * bufAdjoints
Definition ampiFunctions.hpp:2198
MPI_Status * status
Definition ampiFunctions.hpp:2204
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:2396
~AMPI_Recv_AdjointHandle()
Definition ampiFunctions.hpp:2411
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:2399
int count
Definition ampiFunctions.hpp:2404
RecvAdjCall reverse_send
Definition ampiFunctions.hpp:2409
MPI_Comm comm
Definition ampiFunctions.hpp:2408
int source
Definition ampiFunctions.hpp:2406
DATATYPE::PrimalType * bufOldPrimals
Definition ampiFunctions.hpp:2400
int bufCountVec
Definition ampiFunctions.hpp:2403
void * bufAdjoints
Definition ampiFunctions.hpp:2401
int bufTotalSize
Definition ampiFunctions.hpp:2397
int bufCount
Definition ampiFunctions.hpp:2402
DATATYPE * datatype
Definition ampiFunctions.hpp:2405
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:2398
int tag
Definition ampiFunctions.hpp:2407
Definition ampiFunctions.hpp:2606
MPI_Comm comm
Definition ampiFunctions.hpp:2613
DATATYPE::Type * buf
Definition ampiFunctions.hpp:2607
int count
Definition ampiFunctions.hpp:2609
int tag
Definition ampiFunctions.hpp:2612
AMPI_Request * request
Definition ampiFunctions.hpp:2614
int source
Definition ampiFunctions.hpp:2611
IrecvAdjCall reverse_send
Definition ampiFunctions.hpp:2615
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:2608
DATATYPE * datatype
Definition ampiFunctions.hpp:2610
Definition ampiFunctions.hpp:11831
DATATYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:11841
int sendbufTotalSize
Definition ampiFunctions.hpp:11832
int recvbufCountVec
Definition ampiFunctions.hpp:11844
DATATYPE * datatype
Definition ampiFunctions.hpp:11846
int recvbufTotalSize
Definition ampiFunctions.hpp:11838
DATATYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:11834
int count
Definition ampiFunctions.hpp:11845
DATATYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:11840
void * sendbufAdjoints
Definition ampiFunctions.hpp:11835
int sendbufCountVec
Definition ampiFunctions.hpp:11837
~AMPI_Reduce_global_AdjointHandle()
Definition ampiFunctions.hpp:11851
DATATYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:11833
AMPI_Op op
Definition ampiFunctions.hpp:11847
void * recvbufAdjoints
Definition ampiFunctions.hpp:11842
MPI_Comm comm
Definition ampiFunctions.hpp:11849
int root
Definition ampiFunctions.hpp:11848
int recvbufCount
Definition ampiFunctions.hpp:11843
int sendbufCount
Definition ampiFunctions.hpp:11836
DATATYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:11839
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:2871
MPI_Comm comm
Definition ampiFunctions.hpp:2882
int count
Definition ampiFunctions.hpp:2878
int bufCountVec
Definition ampiFunctions.hpp:2877
DATATYPE * datatype
Definition ampiFunctions.hpp:2879
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:2873
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:2874
~AMPI_Rsend_AdjointHandle()
Definition ampiFunctions.hpp:2884
int tag
Definition ampiFunctions.hpp:2881
int bufTotalSize
Definition ampiFunctions.hpp:2872
int bufCount
Definition ampiFunctions.hpp:2876
void * bufAdjoints
Definition ampiFunctions.hpp:2875
int dest
Definition ampiFunctions.hpp:2880
Definition ampiFunctions.hpp:3053
DATATYPE * datatype
Definition ampiFunctions.hpp:3057
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:3055
int tag
Definition ampiFunctions.hpp:3059
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:3054
MPI_Comm comm
Definition ampiFunctions.hpp:3060
AMPI_Request * request
Definition ampiFunctions.hpp:3061
int count
Definition ampiFunctions.hpp:3056
int dest
Definition ampiFunctions.hpp:3058
Definition ampiFunctions.hpp:12175
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:12177
void * sendbufAdjoints
Definition ampiFunctions.hpp:12179
int recvbufTotalSize
Definition ampiFunctions.hpp:12184
RECVTYPE * recvtype
Definition ampiFunctions.hpp:12192
int sendbufCountVec
Definition ampiFunctions.hpp:12181
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:12185
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:12187
void * recvbufAdjoints
Definition ampiFunctions.hpp:12188
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:12178
int recvbufCountVec
Definition ampiFunctions.hpp:12190
int sendbufTotalSize
Definition ampiFunctions.hpp:12176
SENDTYPE * sendtype
Definition ampiFunctions.hpp:12183
int recvcount
Definition ampiFunctions.hpp:12191
int root
Definition ampiFunctions.hpp:12193
~AMPI_Scatter_AdjointHandle()
Definition ampiFunctions.hpp:12196
int recvbufCount
Definition ampiFunctions.hpp:12189
int sendcount
Definition ampiFunctions.hpp:12182
int sendbufCount
Definition ampiFunctions.hpp:12180
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:12186
MPI_Comm comm
Definition ampiFunctions.hpp:12194
Definition ampiFunctions.hpp:12499
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:12513
int root
Definition ampiFunctions.hpp:12519
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:12501
int recvcount
Definition ampiFunctions.hpp:12517
void * recvbufAdjoints
Definition ampiFunctions.hpp:12514
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:12511
RECVTYPE * recvtype
Definition ampiFunctions.hpp:12518
~AMPI_Scatterv_AdjointHandle()
Definition ampiFunctions.hpp:12522
const int * sendcounts
Definition ampiFunctions.hpp:12507
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:12502
SENDTYPE * sendtype
Definition ampiFunctions.hpp:12509
int recvbufTotalSize
Definition ampiFunctions.hpp:12510
int recvbufCountVec
Definition ampiFunctions.hpp:12516
int * sendbufCountVec
Definition ampiFunctions.hpp:12505
MPI_Comm comm
Definition ampiFunctions.hpp:12520
int * sendbufDisplsVec
Definition ampiFunctions.hpp:12506
int * sendbufCount
Definition ampiFunctions.hpp:12504
int recvbufCount
Definition ampiFunctions.hpp:12515
int sendbufTotalSize
Definition ampiFunctions.hpp:12500
void * sendbufAdjoints
Definition ampiFunctions.hpp:12503
const int * displs
Definition ampiFunctions.hpp:12508
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:12512
Definition ampiFunctions.hpp:3299
~AMPI_Send_AdjointHandle()
Definition ampiFunctions.hpp:3312
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:3302
void * bufAdjoints
Definition ampiFunctions.hpp:3303
MPI_Comm comm
Definition ampiFunctions.hpp:3310
DATATYPE * datatype
Definition ampiFunctions.hpp:3307
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:3301
int dest
Definition ampiFunctions.hpp:3308
int bufTotalSize
Definition ampiFunctions.hpp:3300
int count
Definition ampiFunctions.hpp:3306
int bufCount
Definition ampiFunctions.hpp:3304
int bufCountVec
Definition ampiFunctions.hpp:3305
int tag
Definition ampiFunctions.hpp:3309
Definition ampiFunctions.hpp:3481
DATATYPE * datatype
Definition ampiFunctions.hpp:3485
MPI_Comm comm
Definition ampiFunctions.hpp:3488
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:3482
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:3483
AMPI_Request * request
Definition ampiFunctions.hpp:3489
int tag
Definition ampiFunctions.hpp:3487
int count
Definition ampiFunctions.hpp:3484
int dest
Definition ampiFunctions.hpp:3486
Definition ampiFunctions.hpp:3727
SENDTYPE::IndexType * sendbufIndices
Definition ampiFunctions.hpp:3729
void * sendbufAdjoints
Definition ampiFunctions.hpp:3731
int sendcount
Definition ampiFunctions.hpp:3734
int recvbufCountVec
Definition ampiFunctions.hpp:3744
SENDTYPE::PrimalType * sendbufPrimals
Definition ampiFunctions.hpp:3730
int source
Definition ampiFunctions.hpp:3747
int recvcount
Definition ampiFunctions.hpp:3745
MPI_Comm comm
Definition ampiFunctions.hpp:3749
RECVTYPE * recvtype
Definition ampiFunctions.hpp:3746
int recvbufTotalSize
Definition ampiFunctions.hpp:3738
~AMPI_Sendrecv_AdjointHandle()
Definition ampiFunctions.hpp:3751
RECVTYPE::IndexType * recvbufIndices
Definition ampiFunctions.hpp:3739
int recvbufCount
Definition ampiFunctions.hpp:3743
int recvtag
Definition ampiFunctions.hpp:3748
SENDTYPE * sendtype
Definition ampiFunctions.hpp:3735
RECVTYPE::PrimalType * recvbufOldPrimals
Definition ampiFunctions.hpp:3741
int sendbufCountVec
Definition ampiFunctions.hpp:3733
int sendbufTotalSize
Definition ampiFunctions.hpp:3728
int sendtag
Definition ampiFunctions.hpp:3737
void * recvbufAdjoints
Definition ampiFunctions.hpp:3742
RECVTYPE::PrimalType * recvbufPrimals
Definition ampiFunctions.hpp:3740
int dest
Definition ampiFunctions.hpp:3736
int sendbufCount
Definition ampiFunctions.hpp:3732
Definition ampiFunctions.hpp:4006
MPI_Comm comm
Definition ampiFunctions.hpp:4017
int count
Definition ampiFunctions.hpp:4013
DATATYPE * datatype
Definition ampiFunctions.hpp:4014
void * bufAdjoints
Definition ampiFunctions.hpp:4010
int tag
Definition ampiFunctions.hpp:4016
int bufCount
Definition ampiFunctions.hpp:4011
DATATYPE::PrimalType * bufPrimals
Definition ampiFunctions.hpp:4009
DATATYPE::IndexType * bufIndices
Definition ampiFunctions.hpp:4008
int bufCountVec
Definition ampiFunctions.hpp:4012
int bufTotalSize
Definition ampiFunctions.hpp:4007
~AMPI_Ssend_AdjointHandle()
Definition ampiFunctions.hpp:4019
int dest
Definition ampiFunctions.hpp:4015
Definition ampiFunctions.hpp:4188
int dest
Definition ampiFunctions.hpp:4193
AMPI_Request * request
Definition ampiFunctions.hpp:4196
int tag
Definition ampiFunctions.hpp:4194
MPI_Comm comm
Definition ampiFunctions.hpp:4195
DATATYPE::ModifiedType * bufMod
Definition ampiFunctions.hpp:4190
DATATYPE * datatype
Definition ampiFunctions.hpp:4192
int count
Definition ampiFunctions.hpp:4191
const DATATYPE::Type * buf
Definition ampiFunctions.hpp:4189
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:57
PrimalFunction funcPrimal
Definition typeDefinitions.h:64
IterateIdsFunction funcIterateOutputIds
Definition typeDefinitions.h:67
IterateIdsFunction funcIterateInputIds
Definition typeDefinitions.h:66
ReverseFunction funcReverse
Definition typeDefinitions.h:62
HandleBase()
Definition typeDefinitions.h:69
ForwardFunction funcForward
Definition typeDefinitions.h:63
Definition async.hpp:114