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_RCP.hpp"
00040
00041
00042
00043 namespace Teuchos
00044 {
00051 class MPIComm
00052 {
00053 public:
00054
00056 MPIComm();
00057
00058 #ifdef HAVE_MPI
00060 MPIComm(MPI_Comm comm);
00061 #endif
00062
00064 static MPIComm& world();
00065
00067 int getRank() const {return myRank_;}
00068
00070 int getNProc() const {return nProc_;}
00071
00073 void synchronize() const ;
00074
00076
00077
00079 void allToAll(void* sendBuf, int sendCount, int sendType,
00080 void* recvBuf, int recvCount, int recvType) const ;
00081
00083 void allToAllv(void* sendBuf, int* sendCount, int* sendDisplacements,
00084 int sendType,
00085 void* recvBuf, int* recvCount,
00086 int* recvDisplacements,
00087 int recvType) const ;
00088
00090 void allReduce(void* input, void* result, int inputCount, int type,
00091 int op) const ;
00092
00093
00095 void gather(void* sendBuf, int sendCount, int sendType,
00096 void* recvBuf, int recvCount, int recvType,
00097 int root) const ;
00098
00100 void gatherv(void* sendBuf, int sendCount, int sendType,
00101 void* recvBuf, int* recvCount, int* displacements,
00102 int recvType, int root) const ;
00103
00105 void allGather(void* sendBuf, int sendCount, int sendType,
00106 void* recvBuf, int recvCount, int recvType) const ;
00107
00109 void allGatherv(void* sendBuf, int sendCount, int sendType,
00110 void* recvBuf, int* recvCount, int* recvDisplacements,
00111 int recvType) const ;
00112
00114 void bcast(void* msg, int length, int type, int src) const ;
00115
00117
00118 #ifdef HAVE_MPI
00120 MPI_Comm getComm() const {return comm_;}
00121 #endif
00122
00124
00125
00126 const static int INT;
00128 const static int FLOAT;
00130 const static int DOUBLE;
00132 const static int CHAR;
00134
00136
00137
00138 const static int SUM;
00140 const static int MIN;
00142 const static int MAX;
00144 const static int PROD;
00146
00147
00148
00149 static void errCheck(int errCode, const std::string& methodName);
00150
00151 #ifdef HAVE_MPI
00153 static MPI_Datatype getDataType(int type);
00154
00156 static MPI_Op getOp(int op);
00157 #endif
00158 private:
00159 #ifdef HAVE_MPI
00160 MPI_Comm comm_;
00161 #endif
00162
00163 int nProc_;
00164 int myRank_;
00165
00167 void init();
00168
00170 int mpiIsRunning() const ;
00171 };
00172 }
00173 #endif
00174