43#if MEDI_MPI_VERSION_1_0 <= MEDI_MPI_TARGET
44 template<
typename DATATYPE>
45 int AMPI_Bcast_wrap(
typename DATATYPE::Type* bufferSend,
typename DATATYPE::Type* bufferRecv,
int count, DATATYPE* datatype,
int root,
AMPI_Comm comm);
47 template<
typename DATATYPE>
48 inline int AMPI_Bcast(
typename DATATYPE::Type* buffer,
int count, DATATYPE* datatype,
int root,
AMPI_Comm comm) {
49 return AMPI_Bcast_wrap<DATATYPE>(
AMPI_IN_PLACE, buffer, count, datatype, root, comm);
52 inline int MPI_Bcast_wrap(
void* bufferSend,
void* bufferRecv,
int count, MPI_Datatype type,
int root, MPI_Comm comm) {
54 return MPI_Bcast(bufferRecv, count, type, root, comm);
58#if MEDI_MPI_VERSION_3_0 <= MEDI_MPI_TARGET
60 template<
typename DATATYPE>
61 int AMPI_Ibcast_wrap(
typename DATATYPE::Type* bufferSend,
typename DATATYPE::Type* bufferRecv,
int count, DATATYPE* datatype,
int root,
AMPI_Comm comm, AMPI_Request* request);
63 template<
typename DATATYPE>
65 return AMPI_Ibcast_wrap<DATATYPE>(
AMPI_IN_PLACE, buffer, count, datatype, root, comm, request);
68 inline int MPI_Ibcast_wrap(
void* bufferSend,
void* bufferRecv,
int count, MPI_Datatype type,
int root, MPI_Comm comm, MPI_Request* request) {
70 return MPI_Ibcast(bufferRecv, count, type, root, comm, request);
74 template<
typename DATATYPE>
92 template<
typename DATATYPE>
94 template<
typename SENDTYPE,
typename RECVTYPE>
95 int AMPI_Gather(
MEDI_OPTIONAL_CONST typename SENDTYPE::Type* sendbuf,
int sendcount, SENDTYPE* sendtype,
typename RECVTYPE::Type* recvbuf,
int recvcount, RECVTYPE* recvtype,
int root,
AMPI_Comm comm);
96 template<
typename DATATYPE>
98 template<
typename SENDTYPE,
typename RECVTYPE>
100 template<
typename DATATYPE>
102 template<
typename SENDTYPE,
typename RECVTYPE>
104 template<
typename DATATYPE>
106 template<
typename SENDTYPE,
typename RECVTYPE>
109 template<
typename DATATYPE>
110 inline void performReduce(
typename DATATYPE::Type* tempbuf,
typename DATATYPE::Type* recvbuf,
int count, DATATYPE* datatype,
AMPI_Op op,
int root,
AMPI_Comm comm,
int reduceSize) {
113 if(-1 == root || root == commRank) {
114 datatype->performReduce(tempbuf, recvbuf, count, op, reduceSize);
118 template<
typename DATATYPE>
123 typename DATATYPE::Type* tempbuf = NULL;
124 if(-1 == root || root == commRank) {
125 datatype->createTypeBuffer(tempbuf, count * commSize);
130 sendbufGather = recvbuf;
135 rValue = AMPI_Allgather<DATATYPE, DATATYPE>(sendbufGather, count, datatype, tempbuf, count, datatype, comm);
137 rValue = AMPI_Gather<DATATYPE, DATATYPE>(sendbufGather, count, datatype, tempbuf, count, datatype, root, comm);
140 performReduce<DATATYPE>(tempbuf, recvbuf, count, datatype, op, root, comm, reduceSize);
142 if(-1 == root || root == commRank) {
143 datatype->deleteTypeBuffer(tempbuf, count * commSize);
149 template<
typename DATATYPE>
166 if(-1 == h->
root || h->
root == commRank) {
175 template<
typename DATATYPE>
180 typename DATATYPE::Type* tempbuf = NULL;
181 if(-1 == root || root == commRank) {
182 datatype->createTypeBuffer(tempbuf, count * commSize);
187 sendbufGather = recvbuf;
192 rValue = AMPI_Iallgather<DATATYPE, DATATYPE>(sendbufGather, count, datatype, tempbuf, count, datatype, comm, request);
194 rValue = AMPI_Igather<DATATYPE, DATATYPE>(sendbufGather, count, datatype, tempbuf, count, datatype, root, comm, request);
197 curHandle->
comm = comm;
198 curHandle->
root = root;
199 curHandle->
count = count;
210 request->
handle = curHandle;
216 template<
typename DATATYPE>
221 if (reduceHandle !=
nullptr) {
230 template<
typename DATATYPE>
242 template<
typename DATATYPE>
258 template<
typename DATATYPE>
260 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
262 if(!datatype->getADTool().isActiveType()) {
263 return AMPI_Reduce_global<DATATYPE>(sendbuf, recvbuf, count, datatype, convOp, root, comm);
268 typename DATATYPE::Type* tempBuf = recvbuf;
270 datatype->createTypeBuffer(tempBuf, count);
272 int result = AMPI_Allreduce_global<DATATYPE>(sendbuf, tempBuf, count, datatype, convOp, comm);
274 datatype->deleteTypeBuffer(tempBuf, count);
280 return AMPI_Reduce_global<DATATYPE>(sendbuf, recvbuf, count, datatype, convOp, root, comm);
288 template<
typename DATATYPE>
290 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
292 if(!datatype->getADTool().isActiveType()) {
293 return AMPI_Ireduce_global<DATATYPE>(sendbuf, recvbuf, count, datatype, convOp, root, comm, request);
297 typename DATATYPE::Type* tempBuf = recvbuf;
299 datatype->createTypeBuffer(tempBuf, count);
301 int result = AMPI_Iallreduce_global<DATATYPE>(sendbuf, tempBuf, count, datatype, convOp, comm, request);
304 curHandle->
comm = comm;
305 curHandle->
root = root;
306 curHandle->
count = count;
313 request->
handle = curHandle;
319 return AMPI_Ireduce_global<DATATYPE>(sendbuf, recvbuf, count, datatype, convOp, root, comm, request);
327 template<
typename DATATYPE>
329 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
331 if(convOp.
hasAdjoint || !datatype->getADTool().isActiveType()) {
332 return AMPI_Allreduce_global<DATATYPE>(sendbuf, recvbuf, count, datatype, convOp, comm);
339 template<
typename DATATYPE>
341 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
343 if(convOp.
hasAdjoint || !datatype->getADTool().isActiveType()) {
344 return AMPI_Iallreduce_global<DATATYPE>(sendbuf, recvbuf, count, datatype, convOp, comm, request);
351 template<
typename DATATYPE>
352 inline int AMPI_Exscan(
const typename DATATYPE::Type* sendbuf,
typename DATATYPE::Type* recvbuf,
int count, DATATYPE* datatype,
AMPI_Op op,
AMPI_Comm comm) {
353 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
355 if(!datatype->getADTool().isActiveType()) {
356 return MPI_Exscan(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.
primalFunction, comm);
363 template<
typename DATATYPE>
365 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
367 if(!datatype->getADTool().isActiveType()) {
368 return MPI_Iexscan(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.
primalFunction, comm, &request->
request);
375 template<
typename DATATYPE>
376 inline int AMPI_Scan(
const typename DATATYPE::Type* sendbuf,
typename DATATYPE::Type* recvbuf,
int count, DATATYPE* datatype,
AMPI_Op op,
AMPI_Comm comm) {
377 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
379 if(!datatype->getADTool().isActiveType()) {
380 return MPI_Scan(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.
primalFunction, comm);
387 template<
typename DATATYPE>
389 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
391 if(!datatype->getADTool().isActiveType()) {
392 return MPI_Iscan(sendbuf, recvbuf, count, datatype->getMpiType(), convOp.
primalFunction, comm, &request->
request);
406 int result = MPI_Init(argc, argv);
414 int result = MPI_Init_thread(argc, argv, required, provided);
421 template<
typename DATATYPE>
423 AMPI_Op convOp = datatype->getADTool().convertOperator(op);
425 return MPI_Reduce_local(inbuf, inoutbuf, count, datatype->getMpiType(), convOp.
primalFunction);
#define AMPI_Comm
Definition ampiDefinitions.h:778
#define MEDI_OPTIONAL_CONST
Definition macros.h:70
#define MEDI_UNUSED(name)
Definition macros.h:108
Global namespace for MeDiPack - Message Differentiation Package.
Definition adjointInterface.hpp:37
void AMPI_Init_common()
Definition wrappers.hpp:399
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:10845
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:4061
void performReduce(typename DATATYPE::Type *tempbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm, int reduceSize)
Definition wrappers.hpp:110
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_Iexscan(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm, AMPI_Request *request)
Definition wrappers.hpp:364
void(* CustomFunction)(void *data)
Definition typeDefinitions.h:51
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:5758
void initializeOperators()
Definition ampiDefinitions.cpp:196
int AMPI_Reduce_local(const typename DATATYPE::Type *inbuf, typename DATATYPE::Type *inoutbuf, int count, DATATYPE *datatype, MPI_Comm comm, AMPI_Op op)
Definition wrappers.hpp:422
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:8753
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:8375
int AMPI_Exscan(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm)
Definition wrappers.hpp:352
const AMPI_IN_PLACE_IMPL AMPI_IN_PLACE
This structure is able to be cast to any type.
Definition ampi.cpp:40
int MPI_Bcast_wrap(void *bufferSend, void *bufferRecv, int count, MPI_Datatype type, int root, MPI_Comm comm)
Definition wrappers.hpp:52
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:6410
int IgatherAndPerformOperationLocal(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm, AMPI_Request *request, int reduceSize)
Definition wrappers.hpp:176
int GatherAndPerformOperationLocal(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm, int reduceSize)
Definition wrappers.hpp:119
int AMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
Definition wrappers.hpp:413
int AMPI_Allreduce(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm)
Definition wrappers.hpp:328
int AMPI_Ireduce(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 wrappers.hpp:289
int IgatherAndPerformOperationLocal_finish(HandleBase *handle)
Definition wrappers.hpp:150
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:4623
void initTypes()
Definition ampiDefinitions.cpp:241
int getCommSize(MPI_Comm comm)
Helper function that gets the number of ranks from the communicator.
Definition mpiTools.h:64
int getCommRank(MPI_Comm comm)
Helper function that gets the own rank number from the communicator.
Definition mpiTools.h:52
int AMPI_Reduce(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, int root, MPI_Comm comm)
Definition wrappers.hpp:259
int AMPI_Ibcast(typename DATATYPE::Type *buffer, int count, DATATYPE *datatype, int root, MPI_Comm comm, AMPI_Request *request)
Definition wrappers.hpp:64
int AMPI_Bcast_wrap(typename DATATYPE::Type *bufferSend, typename DATATYPE::Type *bufferRecv, int count, DATATYPE *datatype, int root, MPI_Comm comm)
Definition ampiFunctions.hpp:5483
bool addCustomOperationPriorToLocalReduce(AMPI_Request *request, CustomFunction func, void *data)
Definition wrappers.hpp:217
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:7196
int AMPI_Iscan(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm, AMPI_Request *request)
Definition wrappers.hpp:388
int(* ContinueFunction)(HandleBase *h)
Definition typeDefinitions.h:48
int AMPI_Bcast(typename DATATYPE::Type *buffer, int count, DATATYPE *datatype, int root, MPI_Comm comm)
Definition wrappers.hpp:48
int AMPI_Init(int *argc, char ***argv)
Definition wrappers.hpp:405
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:9611
int AMPI_Scan(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm)
Definition wrappers.hpp:376
int AMPI_Iallreduce(const typename DATATYPE::Type *sendbuf, typename DATATYPE::Type *recvbuf, int count, DATATYPE *datatype, AMPI_Op op, MPI_Comm comm, AMPI_Request *request)
Definition wrappers.hpp:340
int AMPI_Ireduce_modified_finish(HandleBase *handle)
Definition wrappers.hpp:243
Definition wrappers.hpp:75
DATATYPE::Type * tempbuf
Definition wrappers.hpp:82
ContinueFunction origFunc
Definition wrappers.hpp:85
CustomFunction customOpPriorToLocalReduce
Definition wrappers.hpp:88
HandleBase * origHandle
Definition wrappers.hpp:84
DATATYPE * datatype
Definition wrappers.hpp:79
int reduceSize
Definition wrappers.hpp:86
DATATYPE::Type * recvbuf
Definition wrappers.hpp:81
AMPI_Op op
Definition wrappers.hpp:80
void * customDataPriorToLocalReduce
Definition wrappers.hpp:89
MPI_Comm comm
Definition wrappers.hpp:76
int root
Definition wrappers.hpp:77
int count
Definition wrappers.hpp:78
Definition wrappers.hpp:231
ContinueFunction origFunc
Definition wrappers.hpp:239
DATATYPE * datatype
Definition wrappers.hpp:233
DATATYPE::Type * tempBuf
Definition wrappers.hpp:232
int root
Definition wrappers.hpp:234
MPI_Comm comm
Definition wrappers.hpp:236
int count
Definition wrappers.hpp:235
HandleBase * origHandle
Definition wrappers.hpp:238
Structure for the special handling of the MPI_Op structure.
Definition op.hpp:50
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 requiresPrimalSend
Indicates if the primal on the receiving side needs to be send to the sending side.
Definition op.hpp:60
bool hasAdjoint
Indicates if the user has provided a specialized adjoint handling for the operator.
Definition op.hpp:92
AsyncHandle * handle
Definition async.hpp:47
MPI_Request request
Definition async.hpp:46
ContinueFunction func
Definition async.hpp:48
AsyncAdjointHandle * toolHandle
Definition async.hpp:103
Definition typeDefinitions.h:53