JDFTx  1.7.0
MPIUtil Class Reference

MPI wrapper class. More...

#include <MPIUtil.h>

Classes

struct  ProcDivision
 Helper for dividing MPI processes into groups. More...
 

Public Types

enum  ReduceOp {
  ReduceMin , ReduceMax , ReduceSum , ReduceProd ,
  ReduceLAnd , ReduceBAnd , ReduceLOr , ReduceBOr ,
  ReduceLXor , ReduceBXor
}
 
typedef int Request
 
typedef FILE * File
 

Public Member Functions

int iProcess () const
 rank of current process
 
int nProcesses () const
 number of processes
 
bool isHead () const
 whether this is the root process (makes code more readable)
 
 MPIUtil (int argc, char **argv, ProcDivision procDivision=ProcDivision())
 
 MPIUtil (const MPIUtil *mpiUtil, std::vector< int > ranks)
 create a sub-communicator from listed ranks in parent communicator
 
void exit (int errCode) const
 global exit (kill other MPI processes as well)
 
void checkErrors (const ostringstream &) const
 collect error messages from all processes; if any, display them and quit
 
template<typename T >
void sendData (const ManagedMemory< T > &v, int dest, int tag, Request *request=0) const
 managed memory send
 
template<typename T >
void sendData (const std::vector< T > &v, int dest, int tag, Request *request=0) const
 vector send
 
template<typename T >
void send (const T *data, size_t nData, int dest, int tag, Request *request=0) const
 generic array send
 
template<typename T >
void send (const T &data, int dest, int tag, Request *request=0) const
 generic scalar send
 
void send (const bool *data, size_t nData, int dest, int tag, Request *request=0) const
 send specialization for bool which is not natively supported by MPI
 
void send (const string &s, int dest, int tag, Request *request=0) const
 send string
 
template<typename T >
void recvData (ManagedMemory< T > &v, int dest, int tag, Request *request=0) const
 managed memory receive
 
template<typename T >
void recvData (std::vector< T > &v, int dest, int tag, Request *request=0) const
 vector receive
 
template<typename T >
void recv (T *data, size_t nData, int src, int tag, Request *request=0) const
 generic array receive
 
template<typename T >
void recv (T &data, int src, int tag, Request *request=0) const
 generic scalar receive
 
void recv (bool *data, size_t nData, int src, int tag, Request *request=0) const
 receive specialization for bool which is not natively supported by MPI
 
void recv (string &s, int src, int tag, Request *request=0) const
 send string
 
template<typename T >
void bcastData (ManagedMemory< T > &v, int root=0, Request *request=0) const
 managed memory broadcast
 
template<typename T >
void bcastData (std::vector< T > &v, int root=0, Request *request=0) const
 vector broadcast
 
template<typename T >
void bcast (T *data, size_t nData, int root=0, Request *request=0) const
 generic array broadcast
 
template<typename T >
void bcast (T &data, int root=0, Request *request=0) const
 generic scalar broadcast
 
void bcast (bool *data, size_t nData, int root=0, Request *request=0) const
 specialization for bool which is not natively supported by MPI
 
void bcast (string &s, int root=0, Request *request=0) const
 broadcast string
 
template<typename T >
void allReduceData (ManagedMemory< T > &v, ReduceOp op, bool safeMode=false, Request *request=0) const
 managed memory reduction
 
template<typename T >
void allReduceData (std::vector< T > &v, ReduceOp op, bool safeMode=false, Request *request=0) const
 vector reduction
 
template<typename T >
void allReduce (T *data, size_t nData, ReduceOp op, bool safeMode=false, Request *request=0) const
 generic array reduction
 
template<typename T >
void allReduce (T &data, ReduceOp op, bool safeMode=false, Request *request=0) const
 generic scalar reduction
 
void allReduce (bool *data, size_t nData, ReduceOp op, bool safeMode=false, Request *request=0) const
 specialization for bool which is not natively supported by MPI
 
template<typename T >
void allReduce (T &data, int &index, ReduceOp op) const
 maximum / minimum with index location (MAXLOC / MINLOC modes); use op = ReduceMin or ReduceMax
 
template<typename T >
void reduceData (ManagedMemory< T > &v, ReduceOp op, int root=0, Request *request=0) const
 managed memory reduction
 
template<typename T >
void reduceData (std::vector< T > &v, ReduceOp op, int root=0, Request *request=0) const
 vector reduction
 
template<typename T >
void reduce (T *data, size_t nData, ReduceOp op, int root=0, Request *request=0) const
 generic array reduction
 
template<typename T >
void reduce (T &data, ReduceOp op, int root=0, Request *request=0) const
 generic scalar reduction
 
void reduce (bool *data, size_t nData, ReduceOp op, int root=0, Request *request=0) const
 specialization for bool which is not natively supported by MPI
 
template<typename T >
void reduce (T &data, int &index, ReduceOp op, int root=0) const
 maximum / minimum with index location (MAXLOC / MINLOC modes); use op = ReduceMin or ReduceMax
 
void fopenRead (File &fp, const char *fname, size_t fsizeExpected=0, const char *fsizeErrMsg=0) const
 open file for reading and optionally check file size
 
void fopenWrite (File &fp, const char *fname) const
 open file for writing
 
void fopenAppend (File &fp, const char *fname) const
 open file for appending to the end. Implied barrier on exit.
 
void fclose (File &fp) const
 
void fseek (File fp, long offset, int whence) const
 syntax consistent with fseek from stdio
 
void fread (void *ptr, size_t size, size_t nmemb, File fp) const
 
void fwrite (const void *ptr, size_t size, size_t nmemb, File fp) const
 
template<typename T >
void freadData (ManagedMemory< T > &v, File fp) const
 
template<typename T >
void freadData (std::vector< T > &v, File fp) const
 
template<typename T >
void fwriteData (const ManagedMemory< T > &v, File fp) const
 
template<typename T >
void fwriteData (const std::vector< T > &v, File fp) const
 

Static Public Member Functions

static void wait (Request request)
 wait till request finishes
 
static void waitAll (const std::vector< Request > &requests)
 wait till all requests finish
 

Public Attributes

const struct MPIUtil::ProcDivision procDivision
 

Detailed Description

MPI wrapper class.


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