queso-0.51.1
MpiComm.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008,2009,2010,2011,2012,2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef UQ_MPI_COMM_H
26 #define UQ_MPI_COMM_H
27 
28 #include <queso/Defines.h>
29 
30 #ifdef QUESO_HAS_TRILINOS
31 #include <Epetra_MpiComm.h>
32 #endif
33 
34 #include <mpi.h>
35 
36 namespace QUESO {
37 
38 typedef MPI_Comm RawType_MPI_Comm ;
39 typedef MPI_Group RawType_MPI_Group ;
40 typedef MPI_Datatype RawType_MPI_Datatype ;
41 typedef MPI_Op RawType_MPI_Op ;
42 typedef MPI_Status RawType_MPI_Status ;
43 #define RawValue_MPI_COMM_SELF MPI_COMM_SELF
44 #define RawValue_MPI_IN_PLACE MPI_IN_PLACE
45 #define RawValue_MPI_ANY_SOURCE MPI_ANY_SOURCE
46 #define RawValue_MPI_CHAR MPI_CHAR
47 #define RawValue_MPI_INT MPI_INT
48 #define RawValue_MPI_DOUBLE MPI_DOUBLE
49 #define RawValue_MPI_UNSIGNED MPI_UNSIGNED
50 #define RawValue_MPI_MIN MPI_MIN
51 #define RawValue_MPI_MAX MPI_MAX
52 #define RawValue_MPI_SUM MPI_SUM
53 
54 } // End namespace QUESO
55 
56 
57 namespace QUESO {
58 
73 class BaseEnvironment;
74 
75 class MpiComm
76 {
77 public:
79 
80 
82 
83  MpiComm();
84 
86 
88  MpiComm(const BaseEnvironment& env, RawType_MPI_Comm inputRawComm);
89 
91 
92  MpiComm(const MpiComm& src);
93 
95  ~MpiComm();
97 
99 
100  MpiComm& operator= (const MpiComm& rhs);
103 
104 
106 
107  RawType_MPI_Comm Comm () const;
109 
111  int MyPID () const;
112 
114  int NumProc () const;
116 
118 
119 
125  void Allreduce(void* sendbuf, void* recvbuf, int count, RawType_MPI_Datatype datatype,
126  RawType_MPI_Op op, const char* whereMsg, const char* whatMsg) const;
127 
129 
131  void Barrier () const; // const char* whereMsg, const char* whatMsg) const;
132 
134 
139  void Bcast (void* buffer, int count, RawType_MPI_Datatype datatype, int root,
140  const char* whereMsg, const char* whatMsg) const;
141 
143 
150  void Gather (void *sendbuf, int sendcnt, RawType_MPI_Datatype sendtype,
151  void *recvbuf, int recvcount, RawType_MPI_Datatype recvtype,
152  int root,
153  const char* whereMsg, const char* whatMsg) const;
154 
156 
165  void Gatherv (void *sendbuf, int sendcnt, RawType_MPI_Datatype sendtype,
166  void *recvbuf, int *recvcnts, int *displs, RawType_MPI_Datatype recvtype,
167  int root,
168  const char* whereMsg, const char* whatMsg) const;
169 
171 
177  void Recv (void *buf, int count, RawType_MPI_Datatype datatype, int source, int tag, RawType_MPI_Status *status,
178  const char* whereMsg, const char* whatMsg) const;
179 
181 
186  void Send (void *buf, int count, RawType_MPI_Datatype datatype, int dest, int tag,
187  const char* whereMsg, const char* whatMsg) const;
189 
191 
192  void syncPrintDebugMsg(const char* msg, unsigned int msgVerbosity, unsigned int numUSecs) const;
194 
195 #ifdef QUESO_HAS_TRILINOS
196  const Epetra_MpiComm& epetraMpiComm() const;
198 #endif
199 
201 private:
203  void copy (const MpiComm& src);
204 
205  // QUESO environment
207 #ifdef QUESO_HAS_TRILINOS
208 
209  // Epetra MPI communicator
210  Epetra_MpiComm* m_epetraMpiComm;
211 #endif
214 
217 
219  int m_myPid;
220 
221  // Total number of processes
223 };
224 
225 } // End namespace QUESO
226 
227 #endif // UQ_MPI_COMM_H
int m_worldRank
World rank.
Definition: MpiComm.h:216
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.
Definition: MpiComm.C:157
The QUESO MPI Communicator Class.
Definition: MpiComm.h:75
RawType_MPI_Comm m_rawComm
Embedded wrapped opaque MPI_Comm object.
Definition: MpiComm.h:213
MpiComm()
Default Constructor.
Definition: MpiComm.C:31
const BaseEnvironment & m_env
Definition: MpiComm.h:206
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:121
int m_myPid
Process ID of this process.
Definition: MpiComm.h:219
MPI_Datatype RawType_MPI_Datatype
Definition: MpiComm.h:40
MPI_Status RawType_MPI_Status
Definition: MpiComm.h:42
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.
Definition: MpiComm.C:131
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:187
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.
Definition: MpiComm.C:221
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.
Definition: MpiComm.C:168
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:143
MpiComm & operator=(const MpiComm &rhs)
Assignment operator.
Definition: MpiComm.C:95
MPI_Comm RawType_MPI_Comm
Definition: MpiComm.h:38
MPI_Group RawType_MPI_Group
Definition: MpiComm.h:39
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.
Definition: MpiComm.C:188
void syncPrintDebugMsg(const char *msg, unsigned int msgVerbosity, unsigned int numUSecs) const
Synchronizes all the processes and print debug message.
Definition: MpiComm.C:234
int MyPID() const
Return my process ID.
Definition: MpiComm.C:112
~MpiComm()
Destructor.
Definition: MpiComm.C:84
void copy(const MpiComm &src)
Copies from an existing MpiComm instance.
Definition: MpiComm.C:269
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.
Definition: MpiComm.C:208
MPI_Op RawType_MPI_Op
Definition: MpiComm.h:41
RawType_MPI_Comm Comm() const
Extract MPI Communicator from a MpiComm object.
Definition: MpiComm.C:103

Generated on Thu Apr 23 2015 19:26:15 for queso-0.51.1 by  doxygen 1.8.5