QMCPACK
MPIObjectBase.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 /** @file MPIObjectBase.h
15  * @brief declaration of MPIObjectBase
16  */
17 
18 #ifndef QMCPLUSPLUS_MPIOBJECTBASE_H
19 #define QMCPLUSPLUS_MPIOBJECTBASE_H
20 #include "Message/Communicate.h"
21 
22 namespace qmcplusplus
23 {
24 /** Base class for any object which needs to know about a MPI communicator.
25  */
27 {
28 public:
30 
31  ///constructor with communicator
33 
34  ///return the rank of the communicator
35  inline int rank() const { return myComm->rank(); }
36 
37  ///return the group id of the communicator
38  inline int getGroupID() const { return myComm->getGroupID(); }
39 
40  ///return myComm
41  inline Communicate* getCommunicator() const { return myComm; }
42 
43  ///return a TEMPORARY reference to Communicate
44  inline Communicate& getCommRef() const { return *myComm; }
45 
46  ///return MPI communicator if one wants to use MPI directly
47  inline mpi_comm_type getMPI() const { return myComm->getMPI(); }
48 
49  /** return true if the rank == 0
50  */
51  inline bool is_manager() const { return !myComm->rank(); }
52 
53  ///return the name
54  inline const std::string& getName() const { return myName; }
55 
56  inline void setName(const std::string& aname) { myName = aname; }
57 
58 protected:
59  /** pointer to Communicate
60  * @todo use smart pointer
61  */
63  /** class Name
64  */
65  std::string ClassName;
66  /** name of the object */
67  std::string myName;
68 };
69 
70 } // namespace qmcplusplus
71 #endif // QMCPLUSPLUS_MPIOBJECTBASE_H
Base class for any object which needs to know about a MPI communicator.
Definition: MPIObjectBase.h:26
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
int rank() const
return the rank
Definition: Communicate.h:116
std::string myName
name of the object
Definition: MPIObjectBase.h:67
mpi_comm_type getMPI() const
return MPI communicator if one wants to use MPI directly
Definition: MPIObjectBase.h:47
int getGroupID() const
return the group id of the communicator
Definition: MPIObjectBase.h:38
Wrapping information on parallelism.
Definition: Communicate.h:68
Communicate * getCommunicator() const
return myComm
Definition: MPIObjectBase.h:41
int getGroupID() const
return the group id
Definition: Communicate.h:121
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
std::string ClassName
class Name
Definition: MPIObjectBase.h:65
Communicate::mpi_comm_type mpi_comm_type
Definition: MPIObjectBase.h:29
Communicate & getCommRef() const
return a TEMPORARY reference to Communicate
Definition: MPIObjectBase.h:44
mpi_comm_type getMPI() const
return the Communicator ID (typically MPI_WORLD_COMM)
Definition: Communicate.h:113
bool is_manager() const
return true if the rank == 0
Definition: MPIObjectBase.h:51
const std::string & getName() const
return the name
Definition: MPIObjectBase.h:54
MPIObjectBase(Communicate *c)
constructor with communicator
int rank() const
return the rank of the communicator
Definition: MPIObjectBase.h:35
void setName(const std::string &aname)
Definition: MPIObjectBase.h:56