OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
CommTopology.h
Go to the documentation of this file.
1 #ifndef __COMM_TOPOLOGY__
2 #define __COMM_TOPOLOGY__
3 
4 #include <vector>
5 #include "mpi.h"
6 
7 
9 class CommTopology {
10 
11 public:
12 
13  CommTopology(MPI_Comm comm = MPI_COMM_WORLD) : comm_(comm) {
14  MPI_Comm_rank(comm_, &rank_);
15  MPI_Comm_size(comm_, &num_procs_);
16  }
17 
18  virtual ~CommTopology()
19  {}
20 
22  virtual void discover() = 0;
23 
24  int getRank() const { return rank_; }
25  int getNP() const { return num_procs_; }
26 
27  unsigned int getNumDimensions() const { return num_dims_; }
28  unsigned int getCoreID() const { return my_core_id_; }
29 
30  std::vector<unsigned int> getCoordinates() const { return coords_; }
31  std::vector<unsigned int> getDimensions() const { return dims_; }
32 
33 
34 private:
35 
36  MPI_Comm comm_;
37  int rank_;
39 
40 
41 protected:
42 
43  unsigned int hwID_;
44  unsigned int num_dims_;
45  unsigned int my_core_id_;
46 
47  std::vector<unsigned int> coords_;
48  std::vector<unsigned int> dims_;
49 
50 };
51 
52 #endif
int getRank() const
Definition: CommTopology.h:24
unsigned int getNumDimensions() const
Definition: CommTopology.h:27
CommTopology(MPI_Comm comm=MPI_COMM_WORLD)
Definition: CommTopology.h:13
virtual void discover()=0
every implementation must provide a discover method
std::vector< unsigned int > dims_
Definition: CommTopology.h:48
unsigned int my_core_id_
Definition: CommTopology.h:45
virtual ~CommTopology()
Definition: CommTopology.h:18
MPI_Comm comm_
Definition: CommTopology.h:36
int getNP() const
Definition: CommTopology.h:25
unsigned int hwID_
Definition: CommTopology.h:43
Specifies interface for topology policies.
Definition: CommTopology.h:9
unsigned int num_dims_
Definition: CommTopology.h:44
std::vector< unsigned int > getCoordinates() const
Definition: CommTopology.h:30
unsigned int getCoreID() const
Definition: CommTopology.h:28
std::vector< unsigned int > coords_
Definition: CommTopology.h:47
std::vector< unsigned int > getDimensions() const
Definition: CommTopology.h:31