Go to the documentation of this file.
3 #ifndef DUNE_COMMON_PARALLEL_COMMUNICATION_HH
4 #define DUNE_COMMON_PARALLEL_COMMUNICATION_HH
79 template<
typename Communicator>
110 int send(
const T& data,
int dest_rank,
int tag){
132 T
recv(T&& data,
int source_rank,
int tag,
void* status = 0){
152 T
rrecv(T&& data,
int source_rank,
int tag,
void* status = 0)
const
175 int sum (T* inout,
int len)
const
197 int prod (T* inout,
int len)
const
219 int min (T* inout,
int len)
const
241 int max (T* inout,
int len)
const
281 return {std::forward<T>(data)};
298 int gather (
const T* in, T* out,
int len,
int root)
const
301 for (
int i=0; i<len; i++)
309 template<
class TIN,
class TOUT = std::vector<TIN>>
311 *(data_out.begin()) = std::forward<TIN>(data_in);
312 return {std::forward<TOUT>(data_out)};
336 int gatherv (
const T* in,
int sendlen, T* out,
int* recvlen,
int* displ,
int root)
const
340 for (
int i=*displ; i<sendlen; i++)
362 for (
int i=0; i<len; i++)
370 template<
class TIN,
class TOUT = TIN>
372 data_out = *(std::forward<TIN>(data_in).begin());
373 return {std::forward<TOUT>(data_out)};
395 int scatterv (
const T*
send,
int* sendlen,
int* displ, T*
recv,
int recvlen,
int root)
const
399 for (
int i=*displ; i<*sendlen; i++)
420 for(
const T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf)
429 template<
class TIN,
class TOUT = TIN>
431 return {std::forward<TOUT>(data_out)};
451 int allgatherv (
const T* in,
int sendlen, T* out,
int* recvlen,
int* displ)
const
454 for (
int i=*displ; i<sendlen; i++)
471 template<
typename BinaryFunction,
typename Type>
483 template<
class BinaryFunction,
class TIN,
class TOUT = TIN>
485 data_out = std::forward<TIN>(data_in);
486 return {std::forward<TOUT>(data_out)};
493 template<
class BinaryFunction,
class T>
495 return {std::forward<T>(data)};
512 template<
typename BinaryFunction,
typename Type>
515 std::copy(in, in+len, out);
A few common exception classes.
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:268
PseudoFuture< TOUT > iallreduce(TIN &&data_in, TOUT &&data_out)
Compute something over all processes nonblocking.
Definition: communication.hh:484
int scatter(const T *send, T *recv, int len, int root) const
Scatter array from a root to all other task.
Definition: communication.hh:359
PseudoFuture< void > ibarrier() const
Nonblocking barrier.
Definition: communication.hh:259
Communication()
Construct default object.
Definition: communication.hh:84
A wrapper-class for a object which is ready immediately.
Definition: future.hh:20
int size() const
Number of processes in set, is greater than 0.
Definition: communication.hh:101
Default exception if an error in the parallel communication of the program occurred.
Definition: exceptions.hh:285
PseudoFuture< T > isend(const T &&data, int dest_rank, int tag)
Sends the data to the dest_rank nonblocking.
Definition: communication.hh:121
Definition: future.hh:158
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:25
T recv(T &&data, int source_rank, int tag, void *status=0)
Receives the data from the source_rank.
Definition: communication.hh:132
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:164
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:230
T rrecv(T &&data, int source_rank, int tag, void *status=0) const
Definition: communication.hh:152
PseudoFuture< TOUT > igather(TIN &&data_in, TOUT &&data_out, int root)
Gather arrays on root task nonblocking.
Definition: communication.hh:310
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:241
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:472
Communication(const Communicator &)
Constructor with a given communicator.
Definition: communication.hh:91
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:219
PseudoFuture< TOUT > iscatter(TIN &&data_in, TOUT &&data_out, int root)
Scatter array from a root to all other task nonblocking.
Definition: communication.hh:371
int barrier() const
Wait until all processes have arrived at this point in the program.
Definition: communication.hh:251
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:513
PseudoFuture< T > ibroadcast(T &&data, int root) const
Distribute an array from the process with rank root to all other processes nonblocking.
Definition: communication.hh:280
PseudoFuture< T > irecv(T &&data, int source_rank, int tag)
Receives the data from the source_rank nonblocking.
Definition: communication.hh:144
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:208
Communication< T > CollectiveCommunication
Definition: communication.hh:525
Definition: communication.hh:45
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:186
PseudoFuture< T > iallreduce(T &&data)
Compute something over all processes nonblocking and in-place.
Definition: communication.hh:494
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
int gatherv(const T *in, int sendlen, T *out, int *recvlen, int *displ, int root) const
Gather arrays of variable size on root task.
Definition: communication.hh:336
int gather(const T *in, T *out, int len, int root) const
Gather arrays on root task.
Definition: communication.hh:298
int rank() const
Return rank, is between 0 and size()-1.
Definition: communication.hh:95
int allgatherv(const T *in, int sendlen, T *out, int *recvlen, int *displ) const
Gathers data of variable length from all tasks and distribute it to all.
Definition: communication.hh:451
Collective communication interface and sequential default implementation.
Definition: communication.hh:80
int send(const T &data, int dest_rank, int tag)
Sends the data to the dest_rank.
Definition: communication.hh:110
helper classes to provide unique types for standard functions
PseudoFuture< TOUT > iallgather(TIN &&data_in, TOUT &&data_out)
Gathers data from all tasks and distribute it to all nonblocking.
Definition: communication.hh:430
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
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:175
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:197
int allgather(const T *sbuf, int count, T *rbuf) const
Gathers data from all tasks and distribute it to all.
Definition: communication.hh:418
int scatterv(const T *send, int *sendlen, int *displ, T *recv, int recvlen, int root) const
Scatter arrays of variable length from a root to all other tasks.
Definition: communication.hh:395
Dune namespace.
Definition: alignedallocator.hh:13