G+Smo  23.12.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsSerialComm Class Reference

Detailed Description

A serial communication class.

This communicator can be used if no MPI is available or one wants to run sequentially even if MPI is available and used.

Public Member Functions

gsSerialComm duplicate () const
 Duplicates the communicator.
 
int rank () const
 return rank of process, i.e. zero More...
 
gsSerialComm split (int color, int key) const
 Splits the communicator into two.
 

Static Public Member Functions

template<typename T >
static int allgather (T *sbuf, int count, T *rbuf)
 Gathers data from all tasks and distribute it to all. More...
 
template<typename T >
static int allgatherv (T *in, int sendlen, T *out, int *recvlen, int *displ)
 Gathers data of variable length from all tasks and distribute it to all. More...
 
template<typename BinaryFunction , typename Type >
static int allreduce (Type *inout, int len)
 Compute something over all processes for each component of an array and return the result in every process. More...
 
template<typename BinaryFunction , typename Type >
static void allreduce (Type *in, Type *out, int len)
 Compute something over all processes for each component of an array and return the result in every process. More...
 
static int barrier ()
 Wait until all processes have arrived at this point in the program.
 
template<typename T >
static int broadcast (T *inout, int len, int root)
 Distribute an array from the process with rank root to all other processes.
 
static int compare (gsSerialComm comm)
 Compares two communicators.
 
template<typename T >
static int gather (T *in, T *out, int len, int)
 Gather arrays on root task. More...
 
template<typename T >
static int gatherv (T *in, int sendlen, T *out, int *recvlen, int *displ, int root)
 Gather arrays of variable size on root task. More...
 
static int group (const MPI_Group *group_)
 Returns the group of the communicator.
 
static gsSerialStatus iprobe (int source, int *flag, int tag=0)
 Query the status from a source process with a defined tag (non-blocking) More...
 
template<typename T >
static int irecv (T *out, int len, int source, MPI_Request request, int tag=0)
 Receives data from a source process with a defined tag (non-blocking) More...
 
template<typename T >
static int isend (T *in, int len, int dest, MPI_Request request, int tag=0)
 Sends data to a destination process with a defined tag (non-blocking) More...
 
template<typename T >
static T max (T &in)
 Compute the maximum of the argument over all processes and return the result in every process. Assumes that T has an operator<.
 
template<typename T >
static int max (T *inout, int len)
 Compute the maximum over all processes for each component of an array and return the result in every process. Assumes that T has an operator<.
 
template<typename T >
static T min (T &in)
 Compute the minimum of the argument over all processes and return the result in every process. Assumes that T has an operator<.
 
template<typename T >
static int min (T *inout, int len)
 Compute the minimum over all processes for each component of an array and return the result in every process. Assumes that T has an operator<.
 
static std::string name ()
 Returns the name of the communicator.
 
static gsSerialStatus probe (int source, int tag=0)
 Query the status from a source process with a defined tag (blocking) More...
 
template<typename T >
static T prod (T &in)
 Compute the product of the argument over all processes and return the result in every process. Assumes that T has an operator*.
 
template<typename T >
static int prod (T *inout, int len)
 Compute the product over all processes for each component of an array and return the result in every process. Assumes that T has an operator*.
 
template<typename T >
static int recv (T *, int, int, int=0, const void *=NULL)
 Receives data from a source process with a defined tag (blocking) More...
 
template<typename T >
static int scatter (T *send, T *recv, int len, int root)
 Scatter array from a root to all other task. More...
 
template<typename T >
static int scatterv (T *send, int *sendlen, int *displ, T *recv, int recvlen, int root)
 Scatter arrays of variable length from a root to all other tasks. More...
 
template<typename T >
static int send (T *, int, int, int=0)
 Sends data to a destination process with a defined tag (blocking) More...
 
static int size ()
 return rank of process, i.e. one
 
template<typename T >
static T sum (T &in)
 Compute the sum of the argument over all processes and return the result in every process. Assumes that T has an operator+.
 
template<typename T >
static int sum (T *inout, int len)
 Compute the sum over all processes for each component of an array and return the result in every process. Assumes that T has an operator+.
 

Member Function Documentation

static int allgather ( T *  sbuf,
int  count,
T *  rbuf 
)
inlinestatic

Gathers data from all tasks and distribute it to all.

The block of data sent from the jth process is received by every process and placed in the jth block of the buffer recvbuf.

Parameters
[in]sbufThe buffer with the data to send. Has to be the same for each task.
[in]countThe number of elements to send by any process.
[out]rbufThe receive buffer for the data. Has to be of size notasks*count, with notasks being the number of tasks in the communicator.
static int allgatherv ( T *  in,
int  sendlen,
T *  out,
int *  recvlen,
int *  displ 
)
inlinestatic

Gathers data of variable length from all tasks and distribute it to all.

The block of data sent from the jth process is received by every process and placed in the jth block of the buffer out.

Parameters
[in]inThe send buffer with the data to send.
[in]sendlenThe number of elements to send on each task.
[out]outThe buffer to store the received data in.
[in]recvlenAn array with size equal to the number of processes containing the number of elements to recieve from process i at position i, i.e. the number that is passed as sendlen argument to this function in process i.
[in]displAn array with size equal to the number of processes. Data recieved from process i will be written starting at out+displ[i].
static int allreduce ( Type *  inout,
int  len 
)
inlinestatic

Compute something over all processes for each component of an array and return the result in every process.

The template parameter BinaryFunction is the type of the binary function to use for the computation

Parameters
inoutThe array to compute on.
lenThe number of components in the array
static void allreduce ( Type *  in,
Type *  out,
int  len 
)
inlinestatic

Compute something over all processes for each component of an array and return the result in every process.

The template parameter BinaryFunction is the type of the binary function to use for the computation

Parameters
inThe array to compute on.
outThe array to store the results in.
lenThe number of components in the array
static int gather ( T *  in,
T *  out,
int  len,
int   
)
inlinestatic

Gather arrays on root task.

Each process sends its in array of length len to the root process (including the root itself). In the root process these arrays are stored in rank order in the out array which must have size len * number of processes.

Parameters
[in]inThe send buffer with the data to send.
[out]outThe buffer to store the received data in. Might have length zero on non-root tasks.
[in]lenThe number of elements to send on each task.
[in]root The root task that gathers the data.
static int gatherv ( T *  in,
int  sendlen,
T *  out,
int *  recvlen,
int *  displ,
int  root 
)
inlinestatic

Gather arrays of variable size on root task.

Each process sends its in array of length sendlen to the root process (including the root itself). In the root process these arrays are stored in rank order in the out array.

Parameters
[in]inThe send buffer with the data to be sent
[in]sendlenThe number of elements to send on each task
[out]outThe buffer to store the received data in. May have length zero on non-root tasks.
[in]recvlenAn array with size equal to the number of processes containing the number of elements to receive from process i at position i, i.e. the number that is passed as sendlen argument to this function in process i. May have length zero on non-root tasks.
[out]displAn array with size equal to the number of processes. Data received from process i will be written starting at out+displ[i] on the root process. May have length zero on non-root tasks.
[in]rootThe root task that gathers the data.
static gsSerialStatus iprobe ( int  source,
int *  flag,
int  tag = 0 
)
inlinestatic

Query the status from a source process with a defined tag (non-blocking)

One process queries the status of receiving data from the source process source. The argument tag specifies the message ID.

Parameters
[in]sourceThe rank of the process which sended the message
[out]flagTrue if a message with the specified source, tag, and communicator is available (logical)
[in]tagSpecifies the message ID
static int irecv ( T *  out,
int  len,
int  source,
MPI_Request  request,
int  tag = 0 
)
inlinestatic

Receives data from a source process with a defined tag (non-blocking)

One process receives data of length len from the source process source. The argument tag specifies the message ID.

Parameters
[out]outThe buffer to store the received data in
[in]lenThe number of elements which will be received
[in]sourceThe rank of the process which sended the message
[out]requestcommunication request
[in]tagSpecifies the message ID
static int isend ( T *  in,
int  len,
int  dest,
MPI_Request  request,
int  tag = 0 
)
inlinestatic

Sends data to a destination process with a defined tag (non-blocking)

One process sends data of length len to the destination process dest. The argument tag specifies the message ID.

Parameters
[in]inThe send buffer with the data to send
[in]lenThe number of elements which will be sent
[in]destThe rank of the process which should receive the message
[out]requestcommunication request
[in]tagSpecifies the message ID
static gsSerialStatus probe ( int  source,
int  tag = 0 
)
inlinestatic

Query the status from a source process with a defined tag (blocking)

One process queries the status of receiving data from the source process source. The argument tag specifies the message ID.

Parameters
[in]sourceThe rank of the process which sended the message
[in]tagSpecifies the message ID
int rank ( ) const
inline

return rank of process, i.e. zero

This function is intentionally left non-static to avoid compiler warnings of unused object.

static int recv ( T *  ,
int  ,
int  ,
int  = 0,
const void *  = NULL 
)
inlinestatic

Receives data from a source process with a defined tag (blocking)

One process receives data of length len from the source process source. The argument tag specifies the message ID.

Parameters
[out]outThe buffer to store the received data in
[in]lenThe number of elements which will be received
[in]sourceThe rank of the process which sended the message
[in]tagSpecifies the message ID
static int scatter ( T *  send,
T *  recv,
int  len,
int  root 
)
inlinestatic

Scatter array from a root to all other task.

The root process sends the elements with index from k*len to (k+1)*len-1 in its array to task k, which stores it at index 0 to len-1.

Parameters
[in]sendThe array to scatter. Might have length zero on non-root tasks.
[out]recvThe buffer to store the received data in. Upon completion of the method each task will have same data stored there as the one in send buffer of the root task before.
[in]lenThe number of elements in the recv buffer.
[in]rootThe root task that gathers the data.
static int scatterv ( T *  send,
int *  sendlen,
int *  displ,
T *  recv,
int  recvlen,
int  root 
)
inlinestatic

Scatter arrays of variable length from a root to all other tasks.

The root process sends the elements with index from send+displ[k] to send+displ[k]-1 in * its array to task k, which stores it at index 0 to recvlen-1.

Parameters
[in]sendThe array to scatter. May have length zero on non-root tasks.
[in]sendlenAn array with size equal to the number of processes containing the number of elements to scatter to process i at position i, i.e. the number that is passed as recvlen argument to this function in process i.
[in]displAn array with size equal to the number of processes. Data scattered to process i will be read starting at send+displ[i] on root the process.
[out]recvThe buffer to store the received data in. Upon completion of the method each task will have the same data stored there as the one in send buffer of the root task before.
[in]recvlenThe number of elements in the recv buffer.
[in]rootThe root task that gathers the data.
static int send ( T *  ,
int  ,
int  ,
int  = 0 
)
inlinestatic

Sends data to a destination process with a defined tag (blocking)

One process sends data of length len to the destination process dest. The argument tag specifies the message ID.

Parameters
[in]inThe send buffer with the data to send
[in]lenThe number of elements which will be sent
[in]destThe rank of the process which should receive the message
[in]tagSpecifies the message ID