Graybat  1.1
Graph Approach for Highly Generic Communication Schemes Based on Adaptive Topologies
Context.hpp
1 #pragma once
2 
3 #include <boost/mpi/environment.hpp>
4 
5 namespace graybat {
6 
7  namespace communicationPolicy {
8 
9  namespace bmpi {
10 
16  class Context {
17  typedef unsigned ContextID;
18  typedef unsigned VAddr;
19 
20  public:
21  Context() :
22  id(0),
23  isValid(false){
24 
25  }
26 
27  Context(ContextID contextID, boost::mpi::communicator comm) :
28  comm(comm),
29  id(contextID),
30  isValid(true){
31 
32  }
33 
34  Context& operator=(const Context& otherContext){
35  id = otherContext.getID();
36  isValid = otherContext.valid();
37  comm = otherContext.comm;
38  return *this;
39 
40  }
41 
42  size_t size() const{
43  return comm.size();
44  }
45 
46  VAddr getVAddr() const {
47  return comm.rank();
48  }
49 
50  ContextID getID() const {
51  return id;
52  }
53 
54  bool valid() const{
55  return isValid;
56  }
57 
58  boost::mpi::communicator comm;
59 
60  private:
61  ContextID id;
62  bool isValid;
63  };
64 
65  } // namespace bmpi
66 
67  } // namespace communicationPolicy
68 
69 } // namespace graybat
Definition: BiStar.hpp:8