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 <cassert>
18 
20 
21 static const int max_dimension = 8;
22 
23 // forward declaration
24 class ChannelSet;
25 
27 
49 class Channel {
50  public:
51  typedef char element_type;
52 
53  Channel();
54  Channel(const int count);
55  Channel(void *buf);
56  virtual ~Channel();
57 
58  int start();
59  int wait();
60 
62  inline element_type& operator[](unsigned int idx) { return m_buf[idx]; }
64  inline element_type operator[](unsigned int idx) const { return m_buf[idx]; }
66  inline const element_type *ptr() { return &m_buf[0]; }
67 
68  private:
70  bool m_my_buf;
71 
72  friend class Communicator;
73  friend class ChannelSet;
74 };
75 
77 
82 class ChannelSet {
83  public:
84  ChannelSet(int nchannel = 8);
85 
86  int append(Channel *const p);
87 
88  int start();
89  int wait();
90 };
91 #endif /* _CHANNEL_H_ */
static const int max_dimension
Definition: channel.h:21
int wait()
wait for completion
Definition: channel.cpp:122
Communication library which wraps MPI.
Definition: communicator.h:47
element_type operator[](unsigned int idx) const
accessor to buffer
Definition: channel.h:64
int start()
collective start
Definition: channel.cpp:153
int start()
start asynchronous communication
Definition: channel.cpp:114
bool m_my_buf
whether buffer is owned by this instance.
Definition: channel.h:70
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
Channel class for asynchronous communication.
Definition: channel.h:48
ChannelSet class for a collection of channels.
Definition: channel.h:83
Channel()
constructor.
Definition: channel.cpp:95
int wait()
collective wait
Definition: channel.cpp:161
element_type & operator[](unsigned int idx)
accessor to buffer
Definition: channel.h:62
element_type * m_buf
buffer
Definition: channel.h:69
const element_type * ptr()
accessor to buffer; returns pointer to the first element.
Definition: channel.h:66
char element_type
data transfer is byte-wise.
Definition: channel.h:51
virtual ~Channel()
destructor
Definition: channel.cpp:107
ChannelSet(int nchannel=8)
constructor. default number of channels is 8 for upward and downward in 4 dimensions.
Definition: channel.cpp:131