Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
channel.h
Go to the documentation of this file.
1 
14 #ifndef CHANNEL_INCLUDED
15 #define CHANNEL_INCLUDED
16 
17 #include <mpi.h>
18 #include <cassert>
19 #include <vector>
20 #include <valarray>
21 
23 
24 static const int max_dimension = 8;
25 
26 // forward declaration
27 class ChannelSet;
28 
30 
48 class Channel {
49  public:
50  typedef char element_type;
51  typedef std::valarray<element_type> container_type;
52 
53  Channel();
54  Channel(const int count);
55  virtual ~Channel();
56 
57  int start();
58  int wait();
59 
61  inline element_type& operator[](unsigned int idx) { return m_buf[idx]; }
63  inline element_type operator[](unsigned int idx) const { return m_buf[idx]; }
65  inline const element_type *ptr() { return &m_buf[0]; }
66 
67  private:
69 
70  MPI_Request m_request;
71  MPI_Status m_status;
72 
73  friend class Communicator_impl;
74  friend class ChannelSet;
75 };
76 
78 
83 class ChannelSet {
84  public:
85  ChannelSet(int nchannel = 8);
86 
87  int append(Channel *const p);
88 
89  int start();
90  int wait();
91 
92  private:
93  std::vector<MPI_Request> m_array;
94  std::vector<MPI_Status> m_status;
95  unsigned int m_nreq;
96 };
97 #endif /* _CHANNEL_H_ */
std::valarray< element_type > container_type
Definition: channel.h:51
int wait()
wait for completion
Definition: channel.cpp:122
MPI_Status m_status
handler to MPI status information
Definition: channel.h:71
element_type operator[](unsigned int idx) const
accessor to buffer
Definition: channel.h:63
int start()
collective start
Definition: channel.cpp:153
int start()
start asynchronous communication
Definition: channel.cpp:114
container_type m_buf
buffer
Definition: channel.h:68
int append(Channel *const p)
append channel to the set. there is no way to remove a channel.
Definition: channel.cpp:139
std::vector< MPI_Request > m_array
a collection of MPI request held in channels.
Definition: channel.h:93
Channel class for asynchronous communication.
Definition: channel.h:48
MPI_Request m_request
handler to MPI persistent communication
Definition: channel.h:70
ChannelSet class for a collection of channels.
Definition: channel.h:83
Channel()
constructor.
Definition: channel.cpp:95
unsigned int m_nreq
number of channels to hold.
Definition: channel.h:95
int wait()
collective wait
Definition: channel.cpp:161
element_type & operator[](unsigned int idx)
accessor to buffer
Definition: channel.h:61
static const int max_dimension
Definition: channel.h:24
const element_type * ptr()
accessor to buffer; returns pointer to the first element.
Definition: channel.h:65
std::vector< MPI_Status > m_status
a collection of MPI status.
Definition: channel.h:94
char element_type
data transfer is byte-wise.
Definition: channel.h:50
virtual ~Channel()
destructor
Definition: channel.cpp:107
MPI-realisation of communicator class implementation.
ChannelSet(int nchannel=8)
constructor. default number of channels is 8 for upward and downward in 4 dimensions.
Definition: channel.cpp:131