Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
channel.cpp
Go to the documentation of this file.
1 
14 #include "channel.h"
15 
16 //====================================================================
17 Channel *Communicator::send_init(int count, int idir, int ipm)
18 {
19  LOG;
20 
21  assert(ipm == 1 || ipm == -1);
22 
23  Channel *ch = new Channel(count);
24  if(!ch){
25  printf("%s: allocate channel failed.\n", __func__);
26  exit(EXIT_FAILURE);
27  }
28 
29  return ch;
30 
31 }
32 
33 //====================================================================
34 Channel *Communicator::recv_init(int count, int idir, int ipm)
35 {
36  LOG;
37 
38  assert(ipm == 1 || ipm == -1);
39 
40  Channel *ch = new Channel(count);
41  if(!ch){
42  printf("%s: allocate channel failed.\n", __func__);
43  exit(EXIT_FAILURE);
44  }
45 
46  return ch;
47 
48 }
49 
50 //====================================================================
51 Channel *Communicator::send_init(int count, int idir, int ipm, void* buf)
52 {
53  LOG;
54 
55  assert(ipm == 1 || ipm == -1);
56 
57  Channel *ch = new Channel(buf);
58  if(!ch){
59  printf("%s: allocate channel failed.\n", __func__);
60  exit(EXIT_FAILURE);
61  }
62 
63  return ch;
64 
65 }
66 
67 //====================================================================
68 Channel *Communicator::recv_init(int count, int idir, int ipm, void* buf)
69 {
70  LOG;
71 
72  assert(ipm == 1 || ipm == -1);
73 
74  Channel *ch = new Channel(buf);
75  if(!ch){
76  printf("%s: allocate channel failed.\n", __func__);
77  exit(EXIT_FAILURE);
78  }
79 
80  return ch;
81 
82 }
83 
84 //====================================================================
85 // class Channel
87  : m_buf(NULL),
88  m_my_buf(false)
89 {
90 }
91 
92 Channel::Channel(void* buf)
93  : m_buf(reinterpret_cast<element_type*>(buf)),
94  m_my_buf(false)
95 {
96 }
97 
98 Channel::Channel(const int count)
99 {
100  m_buf = new element_type[count];
101  m_my_buf = true;
102 }
103 
105 {
106  if (m_my_buf) delete [] m_buf;
107 
108  m_buf = NULL;
109  m_my_buf = false;
110 }
111 
112 //====================================================================
113 int Channel::start()
114 {
115  return 0;
116 }
117 
118 //====================================================================
119 int Channel::wait()
120 {
121  return 0;
122 }
123 
124 //====================================================================
125 // class ChannelSet
126 ChannelSet::ChannelSet(int count)
127 {
128  LOG;
129 }
130 
131 
132 //====================================================================
134 {
135  return 0;
136 }
137 
138 
139 //====================================================================
140 int ChannelSet::start()
141 {
142  return 0;
143 }
144 
145 //====================================================================
146 int ChannelSet::wait()
147 {
148  return 0;
149 }
150 
151 //====================================================================
152 //============================================================END=====
int wait()
Definition: channel.cpp:218
int start()
collective start
Definition: channel.cpp:153
#define LOG
Definition: defs.h:21
int start()
Definition: channel.cpp:194
static Channel * recv_init(int count, int idir, int ipm)
bool m_my_buf
whether buffer is owned by this instance.
Definition: channel.h:70
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:24
Channel()
Definition: channel.cpp:95
int wait()
collective wait
Definition: channel.cpp:161
static std::vector< container_type > m_buf
Definition: channel.h:37
char element_type
Definition: channel.h:26
virtual ~Channel()
Definition: channel.cpp:187
static Channel * send_init(int count, int idir, int ipm)
ChannelSet(int nchannel=8)
constructor. default number of channels is 8 for upward and downward in 4 dimensions.
Definition: channel.cpp:131