NanoStructures  1.0
DMFT solver for layered, strongly correlated nanostructures
openmpi.h
Go to the documentation of this file.
1 #ifndef MPI_H
2 #define MPI_H
3 
12 /*
13  * Copyright (c) 2014 Christoph Schuette.
14  *
15  * The license and distribution terms for this file may be
16  * found in the file LICENSE in this distribution
17  */
18 
19 #include <memory>
20 
21 namespace math {
22  class CFunction;
23 }
24 
25 namespace mpi {
35  class OpenMPI {
36  public:
47  static OpenMPI& getInstance();
48  friend class std::auto_ptr<OpenMPI>;
49 
54  int getRank() const {
55  return m_rank;
56  }
61  int getSize() const {
62  return m_size;
63  }
64 
65  //network operations
81  void send(int target, int source, math::CFunction& f);
82 
98  void send(int target, int source, double &v);
99 
116  void combine(math::CFunction& f);
117 
127  void sync(math::CFunction& f, int master);
128 
138  void sync(double& v, int master);
139 
143  void sync();
144 
145 
146  protected:
147  OpenMPI();
148  virtual ~OpenMPI();
149  static std::auto_ptr< OpenMPI > m_ptr;
150  int m_rank;
151  int m_size;
152  };
153 #define HEAD if(!mpi::OpenMPI::getInstance().getRank())
154 }
155 #endif // MPI_H
int getSize() const
returns the total number of nodes.
Definition: openmpi.h:61
int getRank() const
returns the rank of the node.
Definition: openmpi.h:54
void send(int target, int source, math::CFunction &f)
sends a copy of the math::CFunction from node source to node target.
Definition: openmpi.cpp:24
static OpenMPI & getInstance()
returns the only instance of the OpenMPI class.
Definition: openmpi.cpp:17
void combine(math::CFunction &f)
assembles the partial information of the individual compute nodes to a full copy on each one...
Definition: openmpi.cpp:61
The MPI singleton is responsible for data exchange between compute nodes via OpenMPI.
Definition: openmpi.h:35
void sync()
blocks until all nodes have reached this function call.
Definition: openmpi.cpp:45
Discretized complex-valued function for real arguments.
Definition: cfunction.h:34