5#ifndef DUNE_COMMON_PARALLEL_COMMUNICATION_HH
6#define DUNE_COMMON_PARALLEL_COMMUNICATION_HH
98 template<
typename Communicator>
135 int send([[maybe_unused]]
const T& data,
136 [[maybe_unused]]
int dest_rank,
137 [[maybe_unused]]
int tag)
const
147 [[maybe_unused]]
int dest_rank,
148 [[maybe_unused]]
int tag)
const
157 T
recv([[maybe_unused]] T&& data,
158 [[maybe_unused]]
int source_rank,
159 [[maybe_unused]]
int tag,
160 [[maybe_unused]]
void* status = 0)
const
170 [[maybe_unused]]
int source_rank,
171 [[maybe_unused]]
int tag)
const
178 [[maybe_unused]]
int source_rank,
179 [[maybe_unused]]
int tag,
180 [[maybe_unused]]
void* status = 0)
const
199 int sum ([[maybe_unused]] T* inout, [[maybe_unused]]
int len)
const
219 int prod ([[maybe_unused]] T* inout, [[maybe_unused]]
int len)
const
239 int min ([[maybe_unused]] T* inout, [[maybe_unused]]
int len)
const
259 int max ([[maybe_unused]] T* inout, [[maybe_unused]]
int len)
const
285 [[maybe_unused]]
int len,
286 [[maybe_unused]]
int root)
const
296 return {std::forward<T>(data)};
313 int gather (
const T* in, T* out,
int len,
int )
const
315 for (
int i=0; i<len; i++)
323 template<
class TIN,
class TOUT = std::vector<TIN>>
325 *(data_out.begin()) = std::forward<TIN>(data_in);
326 return {std::forward<TOUT>(data_out)};
353 [[maybe_unused]]
int* recvDataLen,
355 [[maybe_unused]]
int root)
const
357 for (
int i=*displ; i<sendDataLen; i++)
376 int scatter (
const T* sendData, T* recvData,
int len,
int )
const
378 for (
int i=0; i<len; i++)
379 recvData[i] = sendData[i];
386 template<
class TIN,
class TOUT = TIN>
388 data_out = *(std::forward<TIN>(data_in).begin());
389 return {std::forward<TOUT>(data_out)};
411 int scatterv (
const T* sendData,
int* sendDataLen,
int* displ, T* recvData,
412 [[maybe_unused]]
int recvDataLen, [[maybe_unused]]
int root)
const
414 for (
int i=*displ; i<*sendDataLen; i++)
415 recvData[i] = sendData[i];
435 for(
const T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf)
444 template<
class TIN,
class TOUT = TIN>
446 return {std::forward<TOUT>(data_out)};
466 int allgatherv (
const T* in,
int sendDataLen, T* out, [[maybe_unused]]
int* recvDataLen,
int* displ)
const
468 for (
int i=*displ; i<sendDataLen; i++)
485 template<
typename BinaryFunction,
typename Type>
486 int allreduce([[maybe_unused]] Type* inout, [[maybe_unused]]
int len)
const
495 template<
class BinaryFunction,
class TIN,
class TOUT = TIN>
497 data_out = std::forward<TIN>(data_in);
498 return {std::forward<TOUT>(data_out)};
505 template<
class BinaryFunction,
class T>
507 return {std::forward<T>(data)};
524 template<
typename BinaryFunction,
typename Type>
527 std::copy(in, in+len, out);
A few common exception classes.
helper classes to provide unique types for standard functions
#define DUNE_THROW(E,...)
Definition exceptions.hh:314
Dune namespace
Definition alignedallocator.hh:13
constexpr auto operator!=(const HybridMultiIndex< S... > &lhs, const HybridMultiIndex< T... > &rhs)
Compare two HybridMultiIndexs for inequality.
Definition hybridmultiindex.hh:441
constexpr bool operator==(const HybridMultiIndex< S... > &lhs, const HybridMultiIndex< T... > &rhs)
Compare two HybridMultiIndexs for value equality.
Definition hybridmultiindex.hh:404
Default exception if an error in the parallel communication of the program occurred.
Definition exceptions.hh:381
Definition communication.hh:46
PseudoFuture< T > ibroadcast(T &&data, int) const
Distribute an array from the process with rank root to all other processes nonblocking.
Definition communication.hh:295
PseudoFuture< TOUT > iallreduce(TIN &&data_in, TOUT &&data_out)
Compute something over all processes nonblocking.
Definition communication.hh:496
int allreduce(const Type *in, Type *out, int len) const
Compute something over all processes for each component of an array and return the result in every pr...
Definition communication.hh:525
T max(const T &in) const
Compute the maximum of the argument over all processes and return the result in every process....
Definition communication.hh:248
int rank() const
Return rank, is between 0 and size()-1.
Definition communication.hh:114
T sum(const T &in) const
Compute the sum of the argument over all processes and return the result in every process....
Definition communication.hh:188
int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int recvDataLen, int root) const
Scatter arrays of variable length from a root to all other tasks.
Definition communication.hh:411
int prod(T *inout, int len) const
Compute the product over all processes for each component of an array and return the result in every ...
Definition communication.hh:219
PseudoFuture< void > ibarrier() const
Nonblocking barrier.
Definition communication.hh:275
int allreduce(Type *inout, int len) const
Compute something over all processes for each component of an array and return the result in every pr...
Definition communication.hh:486
int scatter(const T *sendData, T *recvData, int len, int) const
Scatter array from a root to all other task.
Definition communication.hh:376
PseudoFuture< TOUT > iallgather(TIN &&, TOUT &&data_out)
Gathers data from all tasks and distribute it to all nonblocking.
Definition communication.hh:445
int send(const T &data, int dest_rank, int tag) const
Sends the data to the dest_rank.
Definition communication.hh:135
int size() const
Number of processes in set, is greater than 0.
Definition communication.hh:126
PseudoFuture< TOUT > iscatter(TIN &&data_in, TOUT &&data_out, int)
Scatter array from a root to all other task nonblocking.
Definition communication.hh:387
PseudoFuture< T > irecv(T &&data, int source_rank, int tag) const
Receives the data from the source_rank nonblocking.
Definition communication.hh:169
int sum(T *inout, int len) const
Compute the sum over all processes for each component of an array and return the result in every proc...
Definition communication.hh:199
int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ) const
Gathers data of variable length from all tasks and distribute it to all.
Definition communication.hh:466
T min(const T &in) const
Compute the minimum of the argument over all processes and return the result in every process....
Definition communication.hh:228
PseudoFuture< T > isend(T &&data, int dest_rank, int tag) const
Sends the data to the dest_rank nonblocking.
Definition communication.hh:146
int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, int root) const
Gather arrays of variable size on root task.
Definition communication.hh:350
int allgather(const T *sbuf, int count, T *rbuf) const
Gathers data from all tasks and distribute it to all.
Definition communication.hh:433
int gather(const T *in, T *out, int len, int) const
Gather arrays on root task.
Definition communication.hh:313
T recv(T &&data, int source_rank, int tag, void *status=0) const
Receives the data from the source_rank.
Definition communication.hh:157
PseudoFuture< T > iallreduce(T &&data)
Compute something over all processes nonblocking and in-place.
Definition communication.hh:506
PseudoFuture< TOUT > igather(TIN &&data_in, TOUT &&data_out, int)
Gather arrays on root task nonblocking.
Definition communication.hh:324
Communication(const Communicator &)
Constructor with a given communicator.
Definition communication.hh:110
int max(T *inout, int len) const
Compute the maximum over all processes for each component of an array and return the result in every ...
Definition communication.hh:259
T prod(const T &in) const
Compute the product of the argument over all processes and return the result in every process....
Definition communication.hh:208
int broadcast(T *inout, int len, int root) const
Distribute an array from the process with rank root to all other processes.
Definition communication.hh:284
T rrecv(T &&data, int source_rank, int tag, void *status=0) const
Definition communication.hh:177
int min(T *inout, int len) const
Compute the minimum over all processes for each component of an array and return the result in every ...
Definition communication.hh:239
int barrier() const
Wait until all processes have arrived at this point in the program.
Definition communication.hh:267
Communication()
Construct default object.
Definition communication.hh:103
A wrapper-class for a object which is ready immediately.
Definition future.hh:124