IBAMR  IBAMR version 0.19.
Classes | Public Types | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes | List of all members
SAMRAI::tbox::SAMRAI_MPI Struct Reference

Provides C++ wrapper around MPI routines. More...

#include <tbox/SAMRAI_MPI.h>

Classes

struct  DoubleIntStruct
 
struct  FloatIntStruct
 
struct  IntIntStruct
 

Public Types

typedef MPI_Comm comm
 
typedef MPI_Group group
 
typedef MPI_Request request
 
typedef MPI_Status status
 

Static Public Member Functions

static void setCallAbortInSerialInsteadOfExit (bool flag=true)
 
static void abort ()
 
static void init (int *argc, char **argv[])
 
static void finalize ()
 
static void initialize ()
 
static void setCommunicator (SAMRAI_MPI::comm communicator)
 
static SAMRAI_MPI::comm getCommunicator ()
 
static int getRank ()
 
static int getNodes ()
 
static void updateOutgoingStatistics (const int messages, const int bytes)
 
static void updateIncomingStatistics (const int messages, const int bytes)
 
static int getOutgoingMessages ()
 
static int getOutgoingBytes ()
 
static int getIncomingMessages ()
 
static int getIncomingBytes ()
 
static int getTreeDepth ()
 
static void barrier ()
 
static double sumReduction (const double x)
 
static void sumReduction (double *x, const int n=1)
 
static float sumReduction (const float x)
 
static void sumReduction (float *x, const int n=1)
 
static dcomplex sumReduction (const dcomplex x)
 
static void sumReduction (dcomplex *x, const int n=1)
 
static int sumReduction (const int x)
 
static void sumReduction (int *x, const int n=1)
 
static double minReduction (const double x, int *rank_of_min=NULL)
 
static void minReduction (double *x, const int n=1, int *rank_of_min=NULL)
 
static float minReduction (const float x, int *rank_of_min=NULL)
 
static void minReduction (float *x, const int n=1, int *rank_of_min=NULL)
 
static int minReduction (const int x, int *rank_of_min=NULL)
 
static void minReduction (int *x, const int n=1, int *rank_of_min=NULL)
 
static double maxReduction (const double x, int *rank_of_max=NULL)
 
static void maxReduction (double *x, const int n=1, int *rank_of_max=NULL)
 
static float maxReduction (const float x, int *rank_of_max=NULL)
 
static void maxReduction (float *x, const int n=1, int *rank_of_max=NULL)
 
static int maxReduction (const int x, int *rank_of_max=NULL)
 
static void maxReduction (int *x, const int n=1, int *rank_of_max=NULL)
 
static void allToOneSumReduction (int *x, const int n, const int root=0)
 
static int bcast (const int x, const int root)
 
static void bcast (int *x, int &length, const int root)
 
static void bcast (char *x, int &length, const int root)
 
static void send (const int *buf, const int length, const int receiving_proc_number, const bool send_length=true, int tag=-1)
 This function sends an MPI message with an integer array to another processer. More...
 
static void sendBytes (const void *buf, const int number_bytes, const int receiving_proc_number)
 This function sends an MPI message with an array of bytes (MPI_BYTES) to receiving_proc_number. More...
 
static int recvBytes (void *buf, int number_bytes)
 This function receives an MPI message with an array of max size number_bytes (MPI_BYTES) from any processer. More...
 
static void recv (int *buf, int &length, const int sending_proc_number, const bool get_length=true, int tag=-1)
 This function receives an MPI message with an integer array from another processer. More...
 
static void allGather (const int *x_in, int size_in, int *x_out, int size_out)
 
static void allGather (const double *x_in, int size_in, double *x_out, int size_out)
 
static void allGather (int x_in, int *x_out)
 
static void allGather (double x_in, double *x_out)
 

Static Public Attributes

static comm commWorld
 
static comm commNull
 

Static Private Member Functions

static void allGatherSetup (int size_in, int size_out, int *&rcounts, int *&disps)
 

Static Private Attributes

static SAMRAI_MPI::comm s_communicator
 
static int s_outgoing_messages
 
static int s_outgoing_bytes
 
static int s_incoming_messages
 
static int s_incoming_bytes
 
static int s_initialized
 

Detailed Description

Class SAMRAI_MPI groups common MPI routines into one globally-accessible location. It provides small, simple routines that are common in MPI code. In some cases, the calling syntax has been simplified for convenience. Moreover, there is no reason to include the preprocessor ifdef/endif guards around these calls, since the MPI libraries are not called in these routines if the MPI libraries are not being used (e.g., when writing serial code).

Note that this class is a utility class to group function calls in one name space (all calls are to static functions). Thus, you should never attempt to instantiate a class of type MPI; simply call the functions as static functions using the MPI::function(...) syntax.

Member Typedef Documentation

◆ comm

MPI Types

◆ group

◆ request

typedef MPI_Request SAMRAI::tbox::SAMRAI_MPI::request

◆ status

Member Function Documentation

◆ setCallAbortInSerialInsteadOfExit()

static void SAMRAI::tbox::SAMRAI_MPI::setCallAbortInSerialInsteadOfExit ( bool  flag = true)
static

This function does nothing and exists for backwards compatibility.

◆ abort()

static void SAMRAI::tbox::SAMRAI_MPI::abort ( )
static

Call std::abort() in serial and MPI_Abort() in parallel.

◆ init()

static void SAMRAI::tbox::SAMRAI_MPI::init ( int argc,
char **  argv[] 
)
static

Call MPI_Init. Use of this function avoids guarding MPI init calls in application code.

◆ finalize()

static void SAMRAI::tbox::SAMRAI_MPI::finalize ( )
static

Call MPI_Finalize. Use of this function avoids guarding MPI finalize calls in application code.

◆ initialize()

static void SAMRAI::tbox::SAMRAI_MPI::initialize ( )
static

Initialize the MPI utility class. The MPI utility class must be initialized after the call to MPI_Init or SAMRAI_MPI::init.

◆ setCommunicator()

static void SAMRAI::tbox::SAMRAI_MPI::setCommunicator ( SAMRAI_MPI::comm  communicator)
static

Set the communicator that is used for the MPI communication routines. The default communicator is MPI_COMM_WORLD.

◆ getCommunicator()

static SAMRAI_MPI::comm SAMRAI::tbox::SAMRAI_MPI::getCommunicator ( )
static

Get the current MPI communicator. The default communicator is MPI_COMM_WORLD.

◆ getRank()

static int SAMRAI::tbox::SAMRAI_MPI::getRank ( )
static

Return the processor rank (identifier) from 0 through the number of processors minus one.

◆ getNodes()

static int SAMRAI::tbox::SAMRAI_MPI::getNodes ( )
static

Return the number of processors (nodes).

◆ updateOutgoingStatistics()

static void SAMRAI::tbox::SAMRAI_MPI::updateOutgoingStatistics ( const int  messages,
const int  bytes 
)
static

Update the statistics for outgoing messages. Statistics are automatically updated for the reduction calls in MPI.

◆ updateIncomingStatistics()

static void SAMRAI::tbox::SAMRAI_MPI::updateIncomingStatistics ( const int  messages,
const int  bytes 
)
static

Update the statistics for incoming messages. Statistics are automatically updated for the reduction calls in MPI.

◆ getOutgoingMessages()

static int SAMRAI::tbox::SAMRAI_MPI::getOutgoingMessages ( )
static

Return the number of outgoing messages.

◆ getOutgoingBytes()

static int SAMRAI::tbox::SAMRAI_MPI::getOutgoingBytes ( )
static

Return the number of outgoing message bytes.

◆ getIncomingMessages()

static int SAMRAI::tbox::SAMRAI_MPI::getIncomingMessages ( )
static

Return the number of incoming messages.

◆ getIncomingBytes()

static int SAMRAI::tbox::SAMRAI_MPI::getIncomingBytes ( )
static

Return the number of incoming message bytes.

◆ getTreeDepth()

static int SAMRAI::tbox::SAMRAI_MPI::getTreeDepth ( )
static

Get the depth of the reduction trees given the current number of MPI processors.

◆ barrier()

static void SAMRAI::tbox::SAMRAI_MPI::barrier ( )
static

Perform a global barrier across all processors.

◆ sumReduction() [1/8]

static double SAMRAI::tbox::SAMRAI_MPI::sumReduction ( const double  x)
static

Perform a scalar sum reduction on a double across all nodes. Each processor contributes a value x of type double, and the sum is returned from the function.

◆ sumReduction() [2/8]

static void SAMRAI::tbox::SAMRAI_MPI::sumReduction ( double x,
const int  n = 1 
)
static

Perform an array sum reduction on doubles across all nodes. Each processor contributes an array of values of type double, and the element-wise sum is returned in the same array.

◆ sumReduction() [3/8]

static float SAMRAI::tbox::SAMRAI_MPI::sumReduction ( const float  x)
static

Perform a scalar sum reduction on a float across all nodes. Each processor contributes a value x of type float, and the sum is returned from the function.

◆ sumReduction() [4/8]

static void SAMRAI::tbox::SAMRAI_MPI::sumReduction ( float *  x,
const int  n = 1 
)
static

Perform an array sum reduction on floats across all nodes. Each processor contributes an array of values of type float, and the element-wise sum is returned in the same array.

◆ sumReduction() [5/8]

static dcomplex SAMRAI::tbox::SAMRAI_MPI::sumReduction ( const dcomplex  x)
static

Perform a scalar sum reduction on a dcomplex across all nodes. Each processor contributes a value x of type dcomplex, and the sum is returned from the function.

◆ sumReduction() [6/8]

static void SAMRAI::tbox::SAMRAI_MPI::sumReduction ( dcomplex x,
const int  n = 1 
)
static

Perform an array sum reduction on dcomplexes across all nodes. Each processor contributes an array of values of type dcomplex, and the element-wise sum is returned in the same array.

◆ sumReduction() [7/8]

static int SAMRAI::tbox::SAMRAI_MPI::sumReduction ( const int  x)
static

Perform a scalar sum reduction on an integer across all nodes. Each processor contributes a value x of type int, and the sum is returned from the function.

◆ sumReduction() [8/8]

static void SAMRAI::tbox::SAMRAI_MPI::sumReduction ( int x,
const int  n = 1 
)
static

Perform an array sum reduction on integers across all nodes. Each processor contributes an array of values of type int, and the element-wise sum is returned in the same array.

◆ minReduction() [1/6]

static double SAMRAI::tbox::SAMRAI_MPI::minReduction ( const double  x,
int rank_of_min = NULL 
)
static

Perform a scalar min reduction on a double across all nodes. Each processor contributes a value x of type double, and the minimum is returned from the function.

If a 'rank_of_min' argument is provided, it will set it to the rank of process holding the minimum value.

◆ minReduction() [2/6]

static void SAMRAI::tbox::SAMRAI_MPI::minReduction ( double x,
const int  n = 1,
int rank_of_min = NULL 
)
static

Perform an array min reduction on doubles across all nodes. Each processor contributes an array of values of type double, and the element-wise minimum is returned in the same array.

If a 'rank_of_min' argument is provided, it will set the array to the rank of process holding the minimum value. Like the double argument, the size of the supplied 'rank_of_min' array should be n.

◆ minReduction() [3/6]

static float SAMRAI::tbox::SAMRAI_MPI::minReduction ( const float  x,
int rank_of_min = NULL 
)
static

Perform a scalar min reduction on a float across all nodes. Each processor contributes a value x of type float, and the minimum is returned from the function.

If a 'rank_of_min' argument is provided, it will set it to the rank of process holding the minimum value.

◆ minReduction() [4/6]

static void SAMRAI::tbox::SAMRAI_MPI::minReduction ( float *  x,
const int  n = 1,
int rank_of_min = NULL 
)
static

Perform an array min reduction on floats across all nodes. Each processor contributes an array of values of type float, and the element-wise minimum is returned in the same array.

If a 'rank_of_min' argument is provided, it will set the array to the rank of process holding the minimum value. Like the double argument, the size of the supplied 'rank_of_min' array should be n.

◆ minReduction() [5/6]

static int SAMRAI::tbox::SAMRAI_MPI::minReduction ( const int  x,
int rank_of_min = NULL 
)
static

Perform a scalar min reduction on an integer across all nodes. Each processor contributes a value x of type int, and the minimum is returned from the function.

If a 'rank_of_min' argument is provided, it will set it to the rank of process holding the minimum value.

◆ minReduction() [6/6]

static void SAMRAI::tbox::SAMRAI_MPI::minReduction ( int x,
const int  n = 1,
int rank_of_min = NULL 
)
static

Perform an array min reduction on integers across all nodes. Each processor contributes an array of values of type int, and the element-wise minimum is returned in the same array.

If a 'rank_of_min' argument is provided, it will set the array to the rank of process holding the minimum value. Like the double argument, the size of the supplied 'rank_of_min' array should be n.

◆ maxReduction() [1/6]

static double SAMRAI::tbox::SAMRAI_MPI::maxReduction ( const double  x,
int rank_of_max = NULL 
)
static

Perform a scalar max reduction on a double across all nodes. Each processor contributes a value x of type double, and the maximum is returned from the function.

If a 'rank_of_max' argument is provided, it will set it to the rank of process holding the maximum value.

◆ maxReduction() [2/6]

static void SAMRAI::tbox::SAMRAI_MPI::maxReduction ( double x,
const int  n = 1,
int rank_of_max = NULL 
)
static

Perform an array max reduction on doubles across all nodes. Each processor contributes an array of values of type double, and the element-wise maximum is returned in the same array.

If a 'rank_of_max' argument is provided, it will set the array to the rank of process holding the maximum value. Like the double argument, the size of the supplied 'rank_of_max' array should be n.

◆ maxReduction() [3/6]

static float SAMRAI::tbox::SAMRAI_MPI::maxReduction ( const float  x,
int rank_of_max = NULL 
)
static

Perform a scalar max reduction on a float across all nodes. Each processor contributes a value x of type float, and the maximum is returned from the function.

If a 'rank_of_max' argument is provided, it will set it to the rank of process holding the maximum value.

◆ maxReduction() [4/6]

static void SAMRAI::tbox::SAMRAI_MPI::maxReduction ( float *  x,
const int  n = 1,
int rank_of_max = NULL 
)
static

Perform an array max reduction on floats across all nodes. Each processor contributes an array of values of type float, and the element-wise maximum is returned in the same array.

If a 'rank_of_max' argument is provided, it will set the array to the rank of process holding the maximum value. Like the double argument, the size of the supplied 'rank_of_max' array should be n.

◆ maxReduction() [5/6]

static int SAMRAI::tbox::SAMRAI_MPI::maxReduction ( const int  x,
int rank_of_max = NULL 
)
static

Perform a scalar max reduction on an integer across all nodes. Each processor contributes a value x of type int, and the maximum is returned from the function.

If a 'rank_of_max' argument is provided, it will set it to the rank of process holding the maximum value.

◆ maxReduction() [6/6]

static void SAMRAI::tbox::SAMRAI_MPI::maxReduction ( int x,
const int  n = 1,
int rank_of_max = NULL 
)
static

Perform an array max reduction on integers across all nodes. Each processor contributes an array of values of type int, and the element-wise maximum is returned in the same array.

If a 'rank_of_max' argument is provided, it will set the array to the rank of process holding the maximum value. Like the double argument, the size of the supplied 'rank_of_max' array should be n.

◆ allToOneSumReduction()

static void SAMRAI::tbox::SAMRAI_MPI::allToOneSumReduction ( int x,
const int  n,
const int  root = 0 
)
static

Perform an all-to-one sum reduction on an integer array. The final result is only available on the root processor.

◆ bcast() [1/3]

static int SAMRAI::tbox::SAMRAI_MPI::bcast ( const int  x,
const int  root 
)
static

Broadcast integer from specified root process to all other processes. All processes other than root, receive a copy of the integer value.

◆ bcast() [2/3]

static void SAMRAI::tbox::SAMRAI_MPI::bcast ( int x,
int length,
const int  root 
)
static

Broadcast integer array from specified root processor to all other processors. For the root processor, "array" and "length" are treated as const.

◆ bcast() [3/3]

static void SAMRAI::tbox::SAMRAI_MPI::bcast ( char *  x,
int length,
const int  root 
)
static

Broadcast char array from specified root processor to all other processors. For the root processor, "array" and "length" are treated as const.

◆ send()

static void SAMRAI::tbox::SAMRAI_MPI::send ( const int buf,
const int  length,
const int  receiving_proc_number,
const bool  send_length = true,
int  tag = -1 
)
static

If the receiving processor knows in advance the length of the array, use "send_length = false;" otherwise, this processor will first send the length of the array, then send the data. This call must be paired with a matching call to SAMRAI_MPI::recv.

Parameters
bufPointer to integer array buffer with length integers.
lengthNumber of integers in buf that we want to send.
receiving_proc_numberReceiving processor number.
send_lengthOptional boolean argument specifiying if we first need to send a message with the array size. Default value is true.
tagOptional integer argument specifying an integer tag to be sent with this message. Default tag is 0.

◆ sendBytes()

static void SAMRAI::tbox::SAMRAI_MPI::sendBytes ( const void *  buf,
const int  number_bytes,
const int  receiving_proc_number 
)
static

This call must be paired with a matching call to SAMRAI_MPI::recvBytes.

Parameters
bufVoid pointer to an array of number_bytes bytes to send.
number_bytesInteger number of bytes to send.
receiving_proc_numberReceiving processor number.

◆ recvBytes()

static int SAMRAI::tbox::SAMRAI_MPI::recvBytes ( void *  buf,
int  number_bytes 
)
static

This call must be paired with a matching call to SAMRAI_MPI::sendBytes.

This function returns the processor number of the sender.

Parameters
bufVoid pointer to a buffer of size number_bytes bytes.
number_bytesInteger number specifing size of buf in bytes.

◆ recv()

static void SAMRAI::tbox::SAMRAI_MPI::recv ( int buf,
int length,
const int  sending_proc_number,
const bool  get_length = true,
int  tag = -1 
)
static

If this processor knows in advance the length of the array, use "get_length = false;" otherwise, the sending processor will first send the length of the array, then send the data. This call must be paired with a matching call to SAMRAI_MPI::send.

Parameters
bufPointer to integer array buffer with capacity of length integers.
lengthMaximum number of integers that can be stored in buf.
sending_proc_numberProcessor number of sender.
get_lengthOptional boolean argument specifiying if we first need to send a message to determine the array size. Default value is true.
tagOptional integer argument specifying a tag which must be matched by the tag of the incoming message. Default tag is 0.

◆ allGather() [1/4]

static void SAMRAI::tbox::SAMRAI_MPI::allGather ( const int x_in,
int  size_in,
int x_out,
int  size_out 
)
static

Each processor sends an array of integers or doubles to all other processors; each processor's array may differ in length. The x_out array must be pre-allocated to the correct length (this is a bit cumbersome, but is necessary to avoid th allGather function from allocating memory that is freed elsewhere). To properly preallocate memory, before calling this method, call

size_out = SAMRAI_MPI::sumReduction(size_in)

then allocate the x_out array.

◆ allGather() [2/4]

static void SAMRAI::tbox::SAMRAI_MPI::allGather ( const double x_in,
int  size_in,
double x_out,
int  size_out 
)
static

◆ allGather() [3/4]

static void SAMRAI::tbox::SAMRAI_MPI::allGather ( int  x_in,
int x_out 
)
static

Each processor sends every other processor an integer or double. The x_out array should be preallocated to a length equal to the number of processors.

◆ allGather() [4/4]

static void SAMRAI::tbox::SAMRAI_MPI::allGather ( double  x_in,
double x_out 
)
static

◆ allGatherSetup()

static void SAMRAI::tbox::SAMRAI_MPI::allGatherSetup ( int  size_in,
int  size_out,
int *&  rcounts,
int *&  disps 
)
staticprivate

Performs common functions needed by some of the allToAll methods.

Member Data Documentation

◆ commWorld

comm SAMRAI::tbox::SAMRAI_MPI::commWorld
static

MPI constants

◆ commNull

comm SAMRAI::tbox::SAMRAI_MPI::commNull
static

◆ s_communicator

SAMRAI_MPI::comm SAMRAI::tbox::SAMRAI_MPI::s_communicator
staticprivate

◆ s_outgoing_messages

int SAMRAI::tbox::SAMRAI_MPI::s_outgoing_messages
staticprivate

◆ s_outgoing_bytes

int SAMRAI::tbox::SAMRAI_MPI::s_outgoing_bytes
staticprivate

◆ s_incoming_messages

int SAMRAI::tbox::SAMRAI_MPI::s_incoming_messages
staticprivate

◆ s_incoming_bytes

int SAMRAI::tbox::SAMRAI_MPI::s_incoming_bytes
staticprivate

◆ s_initialized

int SAMRAI::tbox::SAMRAI_MPI::s_initialized
staticprivate

The documentation for this struct was generated from the following file: