00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TEUCHOS_MPICOMM_H
00030 #define TEUCHOS_MPICOMM_H
00031
00036 #include "Teuchos_ConfigDefs.hpp"
00037 #include "Teuchos_Array.hpp"
00038 #include "Teuchos_MPISession.hpp"
00039 #include "Teuchos_RefCountPtr.hpp"
00040
00041
00042 namespace Teuchos
00043 {
00050 class MPIComm
00051 {
00052 public:
00053
00055 MPIComm();
00056
00057 #ifdef HAVE_MPI
00058
00059 MPIComm(MPI_Comm comm);
00060 #endif
00061
00063 static MPIComm& world();
00064
00066 int getRank() const {return myRank_;}
00067
00069 int getNProc() const {return nProc_;}
00070
00072 void synchronize() const ;
00073
00076
00078 void allToAll(void* sendBuf, int sendCount, int sendType,
00079 void* recvBuf, int recvCount, int recvType) const ;
00080
00082 void allToAllv(void* sendBuf, int* sendCount, int* sendDisplacements,
00083 int sendType,
00084 void* recvBuf, int* recvCount,
00085 int* recvDisplacements,
00086 int recvType) const ;
00087
00089 void allReduce(void* input, void* result, int inputCount, int type,
00090 int op) const ;
00091
00093 void gather(void* sendBuf, int sendCount, int sendType,
00094 void* recvBuf, int recvCount, int recvType,
00095 int root) const ;
00096
00098 void allGather(void* sendBuf, int sendCount, int sendType,
00099 void* recvBuf, int recvCount, int recvType) const ;
00100
00102 void allGatherv(void* sendBuf, int sendCount, int sendType,
00103 void* recvBuf, int* recvCount, int* recvDisplacements,
00104 int recvType) const ;
00105
00107 void bcast(void* msg, int length, int type, int src) const ;
00108
00110
00111 #ifdef HAVE_MPI
00112
00113 MPI_Comm getComm() const {return comm_;}
00114 #endif
00115
00117
00118 const static int INT;
00120 const static int FLOAT;
00122 const static int DOUBLE;
00124 const static int CHAR;
00126
00128
00129 const static int SUM;
00131 const static int MIN;
00133 const static int MAX;
00135 const static int PROD;
00137
00138
00139
00140 static void errCheck(int errCode, const string& methodName);
00141
00142 #ifdef HAVE_MPI
00143
00144 static MPI_Datatype getDataType(int type);
00145
00147 static MPI_Op getOp(int op);
00148 #endif
00149 private:
00150 #ifdef HAVE_MPI
00151 MPI_Comm comm_;
00152 #endif
00153
00154 int nProc_;
00155 int myRank_;
00156
00158 void init();
00159 };
00160 }
00161 #endif
00162