JDFTx  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 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())
 
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 send (const T *data, size_t nData, int dest, int tag) const
 generic array send
 
template<typename T >
void recv (T *data, size_t nData, int src, int tag) const
 generic array receive
 
template<typename T >
void send (const T &data, int dest, int tag) const
 generic scalar send
 
template<typename T >
void recv (T &data, int src, int tag) const
 generic scalar receive
 
void send (const complex *data, size_t nData, int dest, int tag) const
 send specialization for complex which is not natively supported by MPI
 
void recv (complex *data, size_t nData, int src, int tag) const
 receive specialization for complex which is not natively supported by MPI
 
void send (const bool *data, size_t nData, int dest, int tag) const
 send specialization for bool which is not natively supported by MPI
 
void recv (bool *data, size_t nData, int src, int tag) const
 receive specialization for bool which is not natively supported by MPI
 
void send (const string &s, int dest, int tag) const
 send string
 
void recv (string &s, int src, int tag) const
 send string
 
template<typename T >
void bcast (T *data, size_t nData, int root=0) const
 generic array broadcast
 
template<typename T >
void bcast (T &data, int root=0) const
 generic scalar broadcast
 
void bcast (complex *data, size_t nData, int root=0) const
 specialization for complex which is not natively supported by MPI
 
void bcast (bool *data, size_t nData, int root=0) const
 specialization for bool which is not natively supported by MPI
 
void bcast (string &s, int root=0) const
 broadcast string
 
template<typename T >
void allReduce (T *data, size_t nData, ReduceOp op, bool safeMode=false) const
 generic array reduction
 
template<typename T >
void allReduce (T &data, ReduceOp op, bool safeMode=false) const
 generic scalar reduction
 
void allReduce (complex *data, size_t nData, ReduceOp op, bool safeMode=false) const
 specialization for complex which is not natively supported by MPI
 
void allReduce (bool *data, size_t nData, ReduceOp op, bool safeMode=false) 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
 
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
 

Public Attributes

struct MPIUtil::ProcDivision procDivision
 

Detailed Description

MPI wrapper class.


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