Bridge++  Ver. 1.1.x
 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_H_
15 #define _CHANNEL_H_
16 
17 #include "configure.h"
18 #include "defs.h"
19 
20 #include <cstdio>
21 #include <valarray>
22 #include <mpi.h>
23 #include <cassert>
24 
25 #include "communicator.h"
26 
27 static const int max_dimension = 8;
28 
29 // forward declaration
30 class ChannelSet;
31 
33 
51 class Channel {
52  public:
53  typedef char element_type;
54  typedef std::valarray<element_type> container_type;
55 
56  Channel();
57  Channel(const int count);
58  virtual ~Channel();
59 
60  int start();
61  int wait();
62 
64  inline element_type& operator[](unsigned int idx) { return m_buf[idx]; }
66  inline element_type operator[](unsigned int idx) const { return m_buf[idx]; }
68  inline const element_type *ptr() { return &m_buf[0]; }
69 
70  private:
72 
73  MPI_Request m_request;
74  MPI_Status m_status;
75 
76  friend class Communicator_impl;
77  friend class ChannelSet;
78 };
79 
81 
86 class ChannelSet {
87  public:
88  ChannelSet(int nchannel = 8);
89 
90  int append(Channel *const p);
91 
92  int start();
93  int wait();
94 
95  private:
96  std::valarray<MPI_Request> m_array;
97  unsigned int m_nreq;
98 };
99 #endif /* _CHANNEL_H_ */