25 #include <queso/MpiComm.h>
26 #include <queso/Environment.h>
37 "MpiComm::constructor()",
38 "should not be called");
44 #ifdef QUESO_HAS_TRILINOS
45 m_epetraMpiComm( new Epetra_MpiComm(inputRawComm) ),
47 m_rawComm (inputRawComm),
52 int mpiRC = MPI_Comm_rank(inputRawComm,&
m_worldRank);
55 "MpiComm::constructor()",
56 "failed MPI_Comm_rank() on full rank");
58 mpiRC = MPI_Comm_rank(inputRawComm,&
m_myPid);
61 "MpiComm::constructor()",
62 "failed MPI_Comm_rank() on inputRawComm");
64 mpiRC = MPI_Comm_size(inputRawComm,&
m_numProc);
67 "MpiComm::constructor()",
68 "failed MPI_Comm_size() on inputRawComm");
75 #ifdef QUESO_HAS_TRILINOS
86 #ifdef QUESO_HAS_TRILINOS
87 delete m_epetraMpiComm;
88 m_epetraMpiComm = NULL;
105 #ifdef QUESO_HAS_TRILINOS
106 return m_epetraMpiComm->Comm();
114 #ifdef QUESO_HAS_TRILINOS
115 return m_epetraMpiComm->MyPID();
123 #ifdef QUESO_HAS_TRILINOS
124 return m_epetraMpiComm->NumProc();
133 int mpiRC = MPI_Allreduce(sendbuf, recvbuf, count, datatype, op,
m_rawComm);
145 #ifdef QUESO_HAS_TRILINOS
146 return m_epetraMpiComm->Barrier();
151 "MPIComm::Barrier()",
152 "mpiRC indicates failure");
159 int mpiRC = MPI_Bcast(buffer, count, datatype, root,
m_rawComm);
172 const char* whereMsg,
const char* whatMsg)
const
177 int mpiRC = MPI_Gather(sendbuf, sendcnt, sendtype,
178 recvbuf, recvcount, recvtype,
192 const char* whereMsg,
const char* whatMsg)
const
197 int mpiRC = MPI_Gatherv(sendbuf, sendcnt, sendtype,
198 recvbuf, recvcnts, displs, recvtype,
210 const char* whereMsg,
const char* whatMsg)
const
212 int mpiRC = MPI_Recv(buf, count, datatype, source, tag,
m_rawComm, status);
223 const char* whereMsg,
const char* whatMsg)
const
225 int mpiRC = MPI_Send(buf, count, datatype, dest, tag,
m_rawComm);
238 for (
int i = 0; i < this->
NumProc(); ++i) {
239 if (i == this->
MyPID()) {
259 #ifdef QUESO_HAS_TRILINOS
260 const Epetra_MpiComm&
261 MpiComm::epetraMpiComm()
const
263 return *m_epetraMpiComm;
271 #ifdef QUESO_HAS_TRILINOS
272 delete m_epetraMpiComm;
273 m_epetraMpiComm =
new Epetra_MpiComm(*src.m_epetraMpiComm);
void Bcast(void *buffer, int count, RawType_MPI_Datatype datatype, int root, const char *whereMsg, const char *whatMsg) const
Broadcast values from the root process to the slave processes.
int m_worldRank
World rank.
The QUESO MPI Communicator Class.
int subRank() const
Access function for sub-rank.
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
MpiComm()
Default Constructor.
unsigned int syncVerbosity() const
Access function to private attribute m_syncVerbosity.
int inter0Rank() const
Returns the process inter0 rank.
const BaseEnvironment & m_env
int NumProc() const
Returns total number of processes.
int m_myPid
Process ID of this process.
MPI_Datatype RawType_MPI_Datatype
This class sets up the environment underlying the use of the QUESO library by an executable.
MPI_Status RawType_MPI_Status
void Allreduce(void *sendbuf, void *recvbuf, int count, RawType_MPI_Datatype datatype, RawType_MPI_Op op, const char *whereMsg, const char *whatMsg) const
Combines values from all processes and distributes the result back to all processes.
const int UQ_UNAVAILABLE_RANK
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
void Send(void *buf, int count, RawType_MPI_Datatype datatype, int dest, int tag, const char *whereMsg, const char *whatMsg) const
Possibly blocking send of data from this process to another process.
void Gather(void *sendbuf, int sendcnt, RawType_MPI_Datatype sendtype, void *recvbuf, int recvcount, RawType_MPI_Datatype recvtype, int root, const char *whereMsg, const char *whatMsg) const
Gather values from each process to collect on all processes.
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
MpiComm & operator=(const MpiComm &rhs)
Assignment operator.
MPI_Comm RawType_MPI_Comm
void Gatherv(void *sendbuf, int sendcnt, RawType_MPI_Datatype sendtype, void *recvbuf, int *recvcnts, int *displs, RawType_MPI_Datatype recvtype, int root, const char *whereMsg, const char *whatMsg) const
Gathers into specified locations from all processes in a group.
int fullRank() const
Returns the process full rank.
void syncPrintDebugMsg(const char *msg, unsigned int msgVerbosity, unsigned int numUSecs) const
Synchronizes all the processes and print debug message.
int MyPID() const
Return my process ID.
void copy(const MpiComm &src)
Copies from an existing MpiComm instance.
void Recv(void *buf, int count, RawType_MPI_Datatype datatype, int source, int tag, RawType_MPI_Status *status, const char *whereMsg, const char *whatMsg) const
Blocking receive of data from this process to another process.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
RawType_MPI_Comm Comm() const
Extract MPI Communicator from a MpiComm object.