queso-0.55.0
Private Member Functions | Private Attributes | List of all members
QUESO::MpiComm Class Reference

The QUESO MPI Communicator Class. More...

#include <MpiComm.h>

Collaboration diagram for QUESO::MpiComm:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 MpiComm (const BaseEnvironment &env, RawType_MPI_Comm inputRawComm)
 QUESO MpiComm MPI parallel constructor. More...
 
 MpiComm (const BaseEnvironment &env)
 QUESO MpiComm MPI serial constructor. More...
 
 MpiComm (const MpiComm &src)
 Copy Constructor. More...
 
 ~MpiComm ()
 Destructor. More...
 
Set methods
MpiCommoperator= (const MpiComm &rhs)
 Assignment operator. More...
 
Attribute Accessor Methods
RawType_MPI_Comm Comm () const
 Extract MPI Communicator from a MpiComm object. More...
 
int MyPID () const
 Return my process ID. More...
 
int NumProc () const
 Returns total number of processes. More...
 
Methods Overridden from Comm
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. More...
 
template<typename T >
void Allreduce (const T *sendbuf, T *recvbuf, int count, RawType_MPI_Op op, const char *whereMsg, const char *whatMsg) const
 Combines values from all processes and distributes the result back to all processes. More...
 
void Barrier () const
 Pause every process in *this communicator until all the processes reach this point. More...
 
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. More...
 
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. More...
 
template<typename T >
void Gather (const T *sendbuf, int sendcnt, T *recvbuf, int recvcount, int root, const char *whereMsg, const char *whatMsg) const
 Gather values from each process to collect on all processes. More...
 
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. More...
 
template<typename T >
void Gatherv (const T *sendbuf, int sendcnt, T *recvbuf, int *recvcnts, int *displs, int root, const char *whereMsg, const char *whatMsg) const
 Gathers into specified locations from all processes in a group. More...
 
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. More...
 
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. More...
 
Miscellaneous Methods
void syncPrintDebugMsg (const char *msg, unsigned int msgVerbosity, unsigned int numUSecs) const
 Synchronizes all the processes and print debug message. More...
 

Private Member Functions

 MpiComm ()
 Default Constructor. More...
 
void copy (const MpiComm &src)
 Copies from an existing MpiComm instance. More...
 

Private Attributes

const BaseEnvironmentm_env
 
RawType_MPI_Comm m_rawComm
 Embedded wrapped opaque MPI_Comm object. More...
 
int m_worldRank
 World rank. More...
 
int m_myPid
 Process ID of this process. More...
 
int m_numProc
 

Detailed Description

The QUESO MPI Communicator Class.

This class uses MPI (the Message Passing Interface) for distributed-memory communication between one or more parallel processes. It is meant to insulate the user from the specifics of communication that are not required for normal manipulation of linear algebra objects.

Definition at line 203 of file MpiComm.h.

Constructor & Destructor Documentation

QUESO::MpiComm::MpiComm ( const BaseEnvironment env,
RawType_MPI_Comm  inputRawComm 
)

QUESO MpiComm MPI parallel constructor.

This constructs an MpiComm that uses the given "raw" MPI communicator underneath. MPI_Init must have been called before instantiating an object of this type.

The MPI_Comm must be valid for the lifetime of this MpiComm.

Definition at line 33 of file MpiComm.C.

References m_myPid, m_numProc, m_worldRank, and queso_require_equal_to_msg.

34  :
35  m_env (env),
36 #ifdef QUESO_HAS_TRILINOS
37  m_epetraMpiComm( new Epetra_MpiComm(inputRawComm) ),
38 #endif
39  m_rawComm (inputRawComm),
40  m_worldRank (-1),
41  m_myPid (-1),
42  m_numProc (-1)
43 {
44 #ifdef QUESO_HAS_MPI
45  int mpiRC = MPI_Comm_rank(inputRawComm,&m_worldRank);
46  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Comm_rank() on full rank");
47 
48  mpiRC = MPI_Comm_rank(inputRawComm,&m_myPid);
49  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Comm_rank() on inputRawComm");
50 
51  mpiRC = MPI_Comm_size(inputRawComm,&m_numProc);
52  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Comm_size() on inputRawComm");
53 #else
54  m_worldRank = 0;
55  m_myPid = 0;
56  m_numProc = 1;
57 #endif
58 }
int m_worldRank
World rank.
Definition: MpiComm.h:403
int m_myPid
Process ID of this process.
Definition: MpiComm.h:406
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
const BaseEnvironment & m_env
Definition: MpiComm.h:393
QUESO::MpiComm::MpiComm ( const BaseEnvironment env)

QUESO MpiComm MPI serial constructor.

This constructs an MpiComm that defaults to MPI_COMM_SELF underneath. MPI_Init need not be called before using this constructor.

The MPI_Comm must be valid for the lifetime of this MpiComm.

Definition at line 60 of file MpiComm.C.

61  :
62  m_env (env),
63 #ifdef QUESO_HAS_TRILINOS
64  m_epetraMpiComm( new Epetra_MpiComm(MPI_COMM_SELF) ),
65 #endif
67  m_worldRank (0),
68  m_myPid (0),
69  m_numProc (1)
70 {
71 }
int m_worldRank
World rank.
Definition: MpiComm.h:403
int m_myPid
Process ID of this process.
Definition: MpiComm.h:406
#define RawValue_MPI_COMM_SELF
Definition: MpiComm.h:63
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
const BaseEnvironment & m_env
Definition: MpiComm.h:393
QUESO::MpiComm::MpiComm ( const MpiComm src)

Copy Constructor.

Makes an exact copy of an existing MpiComm instance.

Definition at line 74 of file MpiComm.C.

References copy().

75  :
76  m_env (src.m_env)
77 #ifdef QUESO_HAS_TRILINOS
78  ,
79  m_epetraMpiComm(NULL)
80 #endif
81 {
82  this->copy(src);
83 }
void copy(const MpiComm &src)
Copies from an existing MpiComm instance.
Definition: MpiComm.C:358
const BaseEnvironment & m_env
Definition: MpiComm.h:393
QUESO::MpiComm::~MpiComm ( )

Destructor.

Definition at line 86 of file MpiComm.C.

87 {
88 #ifdef QUESO_HAS_TRILINOS
89  delete m_epetraMpiComm;
90  m_epetraMpiComm = NULL;
91 #endif
92 }
QUESO::MpiComm::MpiComm ( )
private

Default Constructor.

It should not be used by user.

Member Function Documentation

void QUESO::MpiComm::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.

Parameters
sendbufstarting address of send buffer
countnumber of elements in send buffer
datatypedata type of elements of send buffer
opoperation
recvbuf(output) starting address of receive buffer

This method is deprecated. Use the templated Allreduce method instead.

Definition at line 133 of file MpiComm.C.

References m_rawComm, NumProc(), queso_deprecated, and queso_require_equal_to_msg.

Referenced by QUESO::MiscCheckForSameValueInAllNodes(), QUESO::GslVector::mpiAllReduce(), QUESO::GslVector::mpiBcast(), QUESO::MHRawChainInfoStruct::mpiSum(), and QUESO::GslMatrix::mpiSum().

134 {
136  if (NumProc() > 1) { // Necessarily true if QUESO_HAS_MPI
137 #ifdef QUESO_HAS_MPI
138  int mpiRC = MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, m_rawComm);
139  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
140 #endif
141  }
142 }
#define queso_deprecated()
Definition: Defines.h:134
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
template<typename T >
void QUESO::MpiComm::Allreduce ( const T *  sendbuf,
T *  recvbuf,
int  count,
RawType_MPI_Op  op,
const char *  whereMsg,
const char *  whatMsg 
) const

Combines values from all processes and distributes the result back to all processes.

Parameters
sendbufstarting address of send buffer containing elements of type T
countnumber of elements in send buffer
opoperation
recvbuf(output) starting address of receive buffer containing elements of type T

Definition at line 146 of file MpiComm.C.

References m_rawComm, NumProc(), and queso_require_equal_to_msg.

148 {
149  if (NumProc() > 1) { // Necessarily true if QUESO_HAS_MPI
150 #ifdef QUESO_HAS_MPI
151  T * sendbuf_noconst = const_cast<T *>(sendbuf);
152  int mpiRC = MPI_Allreduce(sendbuf_noconst, recvbuf, count, StandardType<T>(sendbuf), op, m_rawComm);
153  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
154 #endif
155  }
156  else {
157  size_t dataTypeSize = sizeof(T);
158  size_t dataTotal = dataTypeSize*count;
159  std::memcpy(recvbuf, sendbuf, dataTotal);
160  }
161 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
void QUESO::MpiComm::Barrier ( ) const

Pause every process in *this communicator until all the processes reach this point.

Blocks the caller until all processes in the communicator have called it; that is, the call returns at any process only after all members of the communicator have entered the call.

Definition at line 164 of file MpiComm.C.

References m_rawComm, NumProc(), and queso_require_equal_to_msg.

Referenced by QUESO::ComputeCovCorrMatricesBetweenVectorSequences(), QUESO::FullEnvironment::FullEnvironment(), QUESO::MiscCheckForSameValueInAllNodes(), QUESO::GslVector::mpiBcast(), and syncPrintDebugMsg().

165 {
166 #ifdef QUESO_HAS_TRILINOS
167  return m_epetraMpiComm->Barrier();
168 #endif
169 
170  if (NumProc() > 1) { // Necessarily true if QUESO_HAS_MPI
171 #ifdef QUESO_HAS_MPI
172  int mpiRC = MPI_Barrier(m_rawComm);
173  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "mpiRC indicates failure"); // whatMsg);
174 #endif
175  }
176 
177  return;
178 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
void QUESO::MpiComm::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.

Broadcasts a message from the process with rank "root" to all other processes of the communicator.

Parameters
buffer(input/output) starting address of buffer
countnumber of entries in buffer
datatypedata type of buffer
rootrank of broadcast root

Definition at line 181 of file MpiComm.C.

References m_rawComm, NumProc(), and queso_require_equal_to_msg.

Referenced by QUESO::MiscCheckForSameValueInAllNodes(), QUESO::GslVector::mpiAllQuantile(), QUESO::GslVector::mpiBcast(), QUESO::InterpolationSurrogateIOASCII< V, M >::read(), and QUESO::InterpolationSurrogateData< V, M >::sync_values().

182 {
183  if (NumProc() > 1) { // Necesarrily true if QUESO_HAS_MPI
184 #ifdef QUESO_HAS_MPI
185  int mpiRC = MPI_Bcast(buffer, count, datatype, root, m_rawComm);
186  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
187 #endif
188  }
189 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
RawType_MPI_Comm QUESO::MpiComm::Comm ( ) const

Extract MPI Communicator from a MpiComm object.

Definition at line 105 of file MpiComm.C.

References m_rawComm.

106 {
107 #ifdef QUESO_HAS_TRILINOS
108  return m_epetraMpiComm->Comm();
109 #endif
110  return m_rawComm;
111 }
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
void QUESO::MpiComm::copy ( const MpiComm src)
private

Copies from an existing MpiComm instance.

Definition at line 358 of file MpiComm.C.

References m_myPid, m_numProc, m_rawComm, and m_worldRank.

Referenced by MpiComm(), and operator=().

359 {
360 #ifdef QUESO_HAS_TRILINOS
361  delete m_epetraMpiComm;
362  m_epetraMpiComm = new Epetra_MpiComm(*src.m_epetraMpiComm);
363 #endif
364  m_rawComm = src.m_rawComm;
365  m_worldRank = src.m_worldRank;
366  m_myPid = src.m_myPid;
367  m_numProc = src.m_numProc;
368 
369  return;
370 }
int m_worldRank
World rank.
Definition: MpiComm.h:403
int m_myPid
Process ID of this process.
Definition: MpiComm.h:406
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
void QUESO::MpiComm::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.

Parameters
sendbufstarting address of send buffer
sendcntnumber of elements in send buffer
sendtypedata type of send buffer elements
recvcountnumber of elements for any single receive
recvtypedata type of recv buffer elements
rootrank of receiving process
recvbuf(output) address of receive buffer

This method is deprecated. Use the templated Gather method instead.

Definition at line 192 of file MpiComm.C.

References m_rawComm, NumProc(), queso_deprecated, and queso_require_equal_to_msg.

Referenced by QUESO::GslVector::mpiAllQuantile().

197 {
199  if (NumProc() > 1) { // Necessarily true if QUESO_HAS_MPI
200 #ifdef QUESO_HAS_MPI
201  //int MPI_Gather (void *sendbuf, int sendcnt, MPI_Datatype sendtype,
202  // void *recvbuf, int recvcount, MPI_Datatype recvtype,
203  // int root, MPI_Comm comm )
204  int mpiRC = MPI_Gather(sendbuf, sendcnt, sendtype,
205  recvbuf, recvcount, recvtype,
206  root, m_rawComm);
207  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
208 #endif
209  }
210 }
#define queso_deprecated()
Definition: Defines.h:134
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
template<typename T >
void QUESO::MpiComm::Gather ( const T *  sendbuf,
int  sendcnt,
T *  recvbuf,
int  recvcount,
int  root,
const char *  whereMsg,
const char *  whatMsg 
) const

Gather values from each process to collect on all processes.

Parameters
sendbufstarting address of send buffer containing elements of type T
sendcntnumber of elements in send buffer
recvcountnumber of elements for any single receive
rootrank of receiving process
recvbuf(output) address of receive buffer containing elements of type T

Definition at line 214 of file MpiComm.C.

References m_rawComm, NumProc(), and queso_require_equal_to_msg.

216 {
217  if (NumProc() > 1) { // Necessarily true if QUESO_HAS_MPI
218 #ifdef QUESO_HAS_MPI
219  //int MPI_Gather (void *sendbuf, int sendcnt, MPI_Datatype sendtype,
220  // void *recvbuf, int recvcount, MPI_Datatype recvtype,
221  // int root, MPI_Comm comm )
222  T * sendbuf_noconst = const_cast<T *>(sendbuf);
223  int mpiRC = MPI_Gather(sendbuf_noconst, sendcnt, StandardType<T>(sendbuf),
224  recvbuf, recvcount, StandardType<T>(sendbuf),
225  root, m_rawComm);
226  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
227 #endif
228  }
229  else {
230  size_t dataTypeSize = sizeof(T);
231  size_t sendTotal = dataTypeSize*sendcnt;
232  size_t recvTotal = dataTypeSize*recvcount;
233  if (sendTotal != recvTotal) {
234  std::cerr << "MpiCommClass::Gather()"
235  << ": sendTotal != recvTotal"
236  << std::endl;
237  }
238  queso_require_equal_to_msg(sendTotal, recvTotal, whatMsg);
239  std::memcpy(recvbuf, sendbuf, sendTotal);
240  }
241 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
void QUESO::MpiComm::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.

Parameters
sendbufstarting address of send buffer
sendcountnumber of elements in send buffer
sendtypedata type of send buffer elements
recvcountsinteger array (of length group size) containing the number of elements that are received from each process
displsinteger array (of length group size). Entry i specifies the displacement relative to recvbuf at which to place the incoming data from process i
recvtypedata type of recv buffer elements
rootrank of receiving process

Definition at line 244 of file MpiComm.C.

References m_rawComm, NumProc(), queso_deprecated, and queso_require_equal_to_msg.

249 {
251  if (NumProc() > 1) { // Necessarily true if QUESO_HAS_MPI
252 #ifdef QUESO_HAS_MPI
253  //int MPI_Gatherv(void *sendbuf, int sendcnt, MPI_Datatype sendtype,
254  // void *recvbuf, int *recvcnts, int *displs, MPI_Datatype recvtype,
255  // int root, MPI_Comm comm )
256  int mpiRC = MPI_Gatherv(sendbuf, sendcnt, sendtype,
257  recvbuf, recvcnts, displs, recvtype,
258  root, m_rawComm);
259  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
260 #endif
261  }
262 }
#define queso_deprecated()
Definition: Defines.h:134
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
template<typename T >
void QUESO::MpiComm::Gatherv ( const T *  sendbuf,
int  sendcnt,
T *  recvbuf,
int *  recvcnts,
int *  displs,
int  root,
const char *  whereMsg,
const char *  whatMsg 
) const

Gathers into specified locations from all processes in a group.

Parameters
sendbufstarting address of send buffer containing elements of type T
sendcntnumber of elements in send buffer
recvcntsinteger array (of length group size) containing the number of elements that are received from each process
displsinteger array (of length group size). Entry i specifies the displacement relative to recvbuf at which to place the incoming data from process i
rootrank of receiving process

Definition at line 266 of file MpiComm.C.

References m_rawComm, NumProc(), and queso_require_equal_to_msg.

269 {
270  if (NumProc() > 1) { // Necessarily true if QUESO_HAS_MPI
271 #ifdef QUESO_HAS_MPI
272  //int MPI_Gatherv(void *sendbuf, int sendcnt, MPI_Datatype sendtype,
273  // void *recvbuf, int *recvcnts, int *displs, MPI_Datatype recvtype,
274  // int root, MPI_Comm comm )
275  T * sendbuf_noconst = const_cast<T *>(sendbuf);
276  int mpiRC = MPI_Gatherv(sendbuf_noconst, sendcnt, StandardType<T>(sendbuf),
277  recvbuf, recvcnts, displs,
278  StandardType<T>(recvbuf), root, m_rawComm);
279  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
280 #endif
281  }
282  else {
283  size_t dataTypeSize = sizeof(T);
284  size_t sendTotal = dataTypeSize*sendcnt;
285  size_t recvTotal = dataTypeSize*recvcnts[0];
286  if (sendTotal != recvTotal) {
287  std::cerr << "MpiCommClass::Gatherv()"
288  << ": sendTotal != recvTotal"
289  << std::endl;
290  }
291  queso_require_equal_to_msg(sendTotal, recvTotal, whatMsg);
292  std::memcpy(recvbuf, sendbuf, sendTotal);
293  }
294 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
int QUESO::MpiComm::MyPID ( ) const

Return my process ID.

Definition at line 114 of file MpiComm.C.

References m_myPid.

Referenced by QUESO::MiscCheckForSameValueInAllNodes(), QUESO::GslVector::mpiAllQuantile(), QUESO::GslVector::mpiAllReduce(), QUESO::GslVector::mpiBcast(), and syncPrintDebugMsg().

115 {
116 #ifdef QUESO_HAS_TRILINOS
117  return m_epetraMpiComm->MyPID();
118 #endif
119  return m_myPid;
120 }
int m_myPid
Process ID of this process.
Definition: MpiComm.h:406
int QUESO::MpiComm::NumProc ( ) const
MpiComm & QUESO::MpiComm::operator= ( const MpiComm rhs)

Assignment operator.

Definition at line 97 of file MpiComm.C.

References copy().

98 {
99  this->copy(rhs);
100  return *this;
101 }
void copy(const MpiComm &src)
Copies from an existing MpiComm instance.
Definition: MpiComm.C:358
void QUESO::MpiComm::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.

Parameters
buf(output) initial address of receive buffer
status(output) status object
countmaximum number of elements in receive buffer
datatypedatatype of each receive buffer element
sourcerank of source
tagmessage tag

Definition at line 297 of file MpiComm.C.

References m_rawComm, NumProc(), and queso_require_equal_to_msg.

300 {
301  if (NumProc() > 1) { // Necesarrily true if QUESO_HAS_MPI
302 #ifdef QUESO_HAS_MPI
303  int mpiRC = MPI_Recv(buf, count, datatype, source, tag, m_rawComm, status);
304  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
305 #endif
306  }
307 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
void QUESO::MpiComm::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.

Parameters
bufinitial address of send buffer
countnumber of elements in send buffer
datatypedatatype of each send buffer element
destrank of destination
tagmessage tag

Definition at line 310 of file MpiComm.C.

References m_rawComm, NumProc(), and queso_require_equal_to_msg.

313 {
314  if (NumProc() > 1) { // Necesarrily true if QUESO_HAS_MPI
315 #ifdef QUESO_HAS_MPI
316  int mpiRC = MPI_Send(buf, count, datatype, dest, tag, m_rawComm);
317  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, whatMsg);
318 #endif
319  }
320 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:400
void QUESO::MpiComm::syncPrintDebugMsg ( const char *  msg,
unsigned int  msgVerbosity,
unsigned int  numUSecs 
) const

Synchronizes all the processes and print debug message.

Definition at line 323 of file MpiComm.C.

References Barrier(), QUESO::BaseEnvironment::fullRank(), QUESO::BaseEnvironment::inter0Rank(), m_env, MyPID(), NumProc(), QUESO::BaseEnvironment::subId(), QUESO::BaseEnvironment::subRank(), and QUESO::BaseEnvironment::syncVerbosity().

324 {
325  if (m_env.syncVerbosity() >= msgVerbosity) {
326  this->Barrier();
327  for (int i = 0; i < this->NumProc(); ++i) {
328  if (i == this->MyPID()) {
329  std::cout << msg
330  << ": fullRank " << m_env.fullRank()
331  << ", subEnvironment " << m_env.subId()
332  << ", subRank " << m_env.subRank()
333  << ", inter0Rank " << m_env.inter0Rank()
334  << std::endl;
335  }
336  usleep(numUSecs);
337  this->Barrier();
338  }
339  //if (this->fullRank() == 0) std::cout << "Sleeping " << numUSecs << " microseconds..."
340  // << std::endl;
341  //usleep(numUSecs);
342  this->Barrier();
343  }
344 
345  return;
346 }
int subRank() const
Access function for sub-rank.
Definition: Environment.C:245
int fullRank() const
Returns the process full rank.
Definition: Environment.C:226
unsigned int syncVerbosity() const
Access function to private attribute m_syncVerbosity.
Definition: Environment.C:407
int inter0Rank() const
Returns the process inter0 rank.
Definition: Environment.C:265
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:164
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
Definition: Environment.C:299
int MyPID() const
Return my process ID.
Definition: MpiComm.C:114
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
const BaseEnvironment & m_env
Definition: MpiComm.h:393

Member Data Documentation

const BaseEnvironment& QUESO::MpiComm::m_env
private

Definition at line 393 of file MpiComm.h.

Referenced by syncPrintDebugMsg().

int QUESO::MpiComm::m_myPid
private

Process ID of this process.

Definition at line 406 of file MpiComm.h.

Referenced by copy(), MpiComm(), and MyPID().

int QUESO::MpiComm::m_numProc
private

Definition at line 409 of file MpiComm.h.

Referenced by copy(), MpiComm(), and NumProc().

RawType_MPI_Comm QUESO::MpiComm::m_rawComm
private

Embedded wrapped opaque MPI_Comm object.

Definition at line 400 of file MpiComm.h.

Referenced by Allreduce(), Barrier(), Bcast(), Comm(), copy(), Gather(), Gatherv(), Recv(), and Send().

int QUESO::MpiComm::m_worldRank
private

World rank.

Definition at line 403 of file MpiComm.h.

Referenced by copy(), and MpiComm().


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

Generated on Fri Jun 17 2016 14:17:44 for queso-0.55.0 by  doxygen 1.8.5