SUNphi  1.0
SUNphi::Mpi Class Reference

Class wrapping all MPI functionalities. More...

#include <Mpi.hpp>

Inheritance diagram for SUNphi::Mpi:
SUNphi::SingleInstance< Mpi >

Public Member Functions

 Mpi ()
 Initialize MPI.
 
bool isInitialized () const
 Check initialization flag.
 
 ~Mpi ()
 Finalize MPI.
 
int getRank () const
 Get current rank calling explicitly MPI.
 
int rank () const
 Cached value of current rank. More...
 
int getNRanks () const
 Get the total number of ranks, calling explicitly MPI.
 
bool isMasterRank () const
 Check if this is the master rank. More...
 
int nRanks () const
 Cached value of total number of ranks. More...
 
template<typename T >
allReduce (const T &in) const
 Reduces among all MPI process.
 
template<typename T , TypeIf<(isTriviallyCopyable< T >), void * > = nullptr>
void broadcast (T *x, const size_t &size, int root=MASTER_RANK) const
 
template<typename T , TypeIf<(isTriviallyCopyable< T >), void * > = nullptr>
void broadcast (T &x, int root=MASTER_RANK) const
 
template<typename T , TypeIf<(isBinarizable< T >), void * > = nullptr>
void broadcast (T &&val, int root=MASTER_RANK) const
 

Static Public Attributes

static constexpr int MASTER_RANK
 Id of master rank. More...
 
static constexpr int ALL_RANKS
 Placeholder for all ranks. More...
 

Private Member Functions

template<typename... Args>
int crashOnError (const int line, const char *file, const char *function, const int rc, Args &&...args) const
 

Detailed Description

Class wrapping all MPI functionalities.

Definition at line 57 of file Mpi.hpp.

Member Function Documentation

template<typename T , TypeIf<(isTriviallyCopyable< T >), void * > = nullptr>
void SUNphi::Mpi::broadcast ( T *  x,
const size_t &  size,
int  root = MASTER_RANK 
) const
inline

Broadcast among all MPI process

This is a simple wrapper around the MPI_Bcast function

Parameters
xQuantity to broadcast
sizeSize of the quantity to broadcast
rootRank from which to broadcast

Definition at line 267 of file Mpi.hpp.

template<typename T , TypeIf<(isTriviallyCopyable< T >), void * > = nullptr>
void SUNphi::Mpi::broadcast ( T &  x,
int  root = MASTER_RANK 
) const
inline

Broadcast among all MPI process

Accepts trivially copyable structures

Parameters
xQuantity to broadcast
rootRank from which to broadcast

Definition at line 283 of file Mpi.hpp.

template<typename T , TypeIf<(isBinarizable< T >), void * > = nullptr>
void SUNphi::Mpi::broadcast ( T &&  val,
int  root = MASTER_RANK 
) const
inline

Broadcast among all MPI process

Accepts all binarizable classes

Parameters
valQuantity to broadcast
rootRank from which to broadcast

Definition at line 295 of file Mpi.hpp.

template<typename... Args>
int SUNphi::Mpi::crashOnError ( const int  line,
const char *  file,
const char *  function,
const int  rc,
Args &&...  args 
) const
inlineprivate

Decrypt the returned value of an MPI call

Returns the value of rc

Parameters
lineLine of file where the error needs to be checked
fileFile where the error must be checked
functionFunction where the error was possibly raised
rcExit condition of the called routine
argsOther arguments

Definition at line 69 of file Mpi.hpp.

bool SUNphi::Mpi::isMasterRank ( ) const
inline

Check if this is the master rank.

Store the result

Definition at line 212 of file Mpi.hpp.

int SUNphi::Mpi::nRanks ( ) const
inline

Cached value of total number of ranks.

Stored value

Definition at line 224 of file Mpi.hpp.

int SUNphi::Mpi::rank ( ) const
inline

Cached value of current rank.

Stored value

Definition at line 178 of file Mpi.hpp.

Member Data Documentation

constexpr int SUNphi::Mpi::ALL_RANKS
static
Initial value:
=
-1

Placeholder for all ranks.

Definition at line 104 of file Mpi.hpp.

constexpr int SUNphi::Mpi::MASTER_RANK
static
Initial value:
=
0

Id of master rank.

Definition at line 99 of file Mpi.hpp.


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