Bridge++  Version 1.4.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 <vector>
18 #include <cassert>
19 
21 
22 static const int max_dimension = 4;
23 
24 class Channel {
25  public:
26  typedef char element_type;
27  typedef std::vector<element_type> container_type;
28  enum channel_mode { SEND, RECV };
29  private:
30 
31  /*
32  element_type* m_buf;
33  // container_type m_buf;
34  static std::vector<container_type> m_buf_send;
35  static std::vector<container_type> m_buf_recv;
36  */
37  static std::vector<container_type> m_buf;
38  int m_count;
39  int m_ibuf;
40 
41  struct bgnet_IDs
42  {
43  int fifoID;
44  int sendBufID;
46  int size;
47  int destRank;
48  int groupID;
49  int recvBufID;
51  int counterID;
52  };
53 
55  std::vector<bgnet_IDs> m_bgnet_ids_thread;
56 
57  static int m_set_id;
58 
59  public:
60 
61  Channel();
62  Channel(const int count);
63  Channel(const int count, const int tag, const channel_mode mode);
64  virtual ~Channel();
65 
66  int start();
67  int wait();
68 
70  static void increment_channel_set_id();
71 
72  void set_thread(int, const std::vector<int>&,
73  const std::vector<int>&, const std::vector<int>&);
74  int start_thread(int);
75  int wait_thread(int);
76 
77  inline element_type& operator[](unsigned int idx)
78  {
79  return m_buf[m_ibuf][idx];
80  }
81 
82  // inline element_type operator[] (unsigned int idx) const { return m_buf[idx]; }
83 
84  inline const element_type *ptr()
85  {
86  return &m_buf[m_ibuf][0];
87  }
88 
89  inline const element_type *ptr(int offset)
90  {
91  return &m_buf[m_ibuf][offset];
92  }
93 
94  friend class Communicator_impl;
95 };
96 #endif /* CHANNEL_INCLUDED */
int wait()
Definition: channel.cpp:218
bgnet_IDs m_bgnet_ids
Definition: channel.h:54
static const int max_dimension
Definition: channel.h:22
const element_type * ptr(int offset)
Definition: channel.h:89
void set_thread(int, const std::vector< int > &, const std::vector< int > &, const std::vector< int > &)
Definition: channel.cpp:38
int m_count
Definition: channel.h:38
int start()
Definition: channel.cpp:194
int start_thread(int)
Definition: channel.cpp:236
std::vector< element_type > container_type
Definition: channel.h:27
static void increment_channel_set_id()
To be called before defining new set of channels for a operator.
Channel class for asynchronous communication.
Definition: channel.h:24
int wait_thread(int)
Definition: channel.cpp:261
Channel()
Definition: channel.cpp:95
element_type & operator[](unsigned int idx)
Definition: channel.h:77
static std::vector< container_type > m_buf
Definition: channel.h:37
const element_type * ptr()
Definition: channel.h:84
char element_type
Definition: channel.h:26
virtual ~Channel()
Definition: channel.cpp:187
static int m_set_id
identifies set of channels.
Definition: channel.h:57
Implementation of Communicator with BGNET library.
channel_mode
Definition: channel.h:28
std::vector< bgnet_IDs > m_bgnet_ids_thread
Definition: channel.h:55
int m_ibuf
Definition: channel.h:39