Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
communicator.cpp
Go to the documentation of this file.
1 
14 #include "layout.h"
15 
16 //====================================================================
17 
22 int Communicator::init(int *pargc, char ***pargv)
23 {
24  return Communicator_impl::init(pargc, pargv);
25 }
26 
27 
28 //====================================================================
30 {
32 }
33 
34 
35 //====================================================================
37 {
38  return Communicator_impl::abort();
39 }
40 
41 
42 //====================================================================
43 int Communicator::setup(int ninstance)
44 {
45  return Communicator_impl::setup(ninstance);
46 }
47 
48 
49 //====================================================================
51 {
53 }
54 
55 
56 //====================================================================
58 {
59  return Communicator_impl::is_primary_master();
60 }
61 
62 
63 //====================================================================
65 {
66  return Communicator_impl::self();
67 }
68 
69 
70 //====================================================================
72 {
73  return Communicator_impl::size();
74 }
75 
76 
77 //====================================================================
78 #ifdef ENABLE_MULTI_INSTANCE
79 int Communicator::self_global()
80 {
81  return Communicator_impl::self_global();
82 }
83 
84 
85 //====================================================================
86 int Communicator::world_id()
87 {
88  return Communicator_impl::world_id();
89 }
90 #endif
91 
92 //====================================================================
93 int Communicator::ipe(const int idir)
94 {
95  return Communicator_impl::Layout::ipe(idir);
96 }
97 
98 
99 //====================================================================
100 int Communicator::npe(const int idir)
101 {
102  return Communicator_impl::Layout::npe(idir);
103 }
104 
105 
106 //====================================================================
107 int Communicator::grid_rank(int *rank, const int *grid_coord)
108 {
109  return Communicator_impl::Layout::grid_rank(rank, grid_coord);
110 }
111 
112 
113 //====================================================================
114 int Communicator::grid_coord(int *grid_coord, const int rank)
115 {
116  return Communicator_impl::Layout::grid_coord(grid_coord, rank);
117 }
118 
119 
120 //====================================================================
121 int Communicator::grid_dims(int *grid_dims)
122 {
123  return Communicator_impl::Layout::grid_dims(grid_dims);
124 }
125 
126 
127 //====================================================================
128 int Communicator::sync()
129 {
130  return Communicator_impl::sync();
131 }
132 
133 
134 //====================================================================
135 #ifdef ENABLE_MULTI_INSTANCE
136 int Communicator::sync_global()
137 {
138  return Communicator_impl::sync_global();
139 }
140 #endif
141 
142 //====================================================================
143 int Communicator::Base::broadcast(size_t size, void *data, int sender)
144 {
145  return Communicator_impl::Base::broadcast(size, data, sender);
146 }
147 
148 
149 int Communicator::broadcast(int count, double *data, int sender)
150 {
151  return Communicator_impl::Base::broadcast(sizeof(double) * count, (void *)data, sender);
152 }
153 
154 
155 int Communicator::broadcast(int count, int *data, int sender)
156 {
157  return Communicator_impl::Base::broadcast(sizeof(int) * count, (void *)data, sender);
158 }
159 
160 
161 int Communicator::broadcast(int count, string& data, int sender)
162 {
163  return Communicator_impl::broadcast_string(count, data, sender);
164 }
165 
166 
167 //====================================================================
168 int Communicator::Base::exchange(size_t size, void *recv_buf, void *send_buf, int idir, int ipm, int itag)
169 {
170  return Communicator_impl::Base::exchange(size, recv_buf, send_buf, idir, ipm, itag);
171 }
172 
173 
174 int Communicator::exchange(int count, double *recv_buf, double *send_buf, int idir, int ipm, int itag)
175 {
176  return Communicator_impl::Base::exchange(sizeof(double) * count, (void *)recv_buf, (void *)send_buf, idir, ipm, itag);
177 }
178 
179 
180 int Communicator::exchange(int count, int *recv_buf, int *send_buf, int idir, int ipm, int itag)
181 {
182  return Communicator_impl::Base::exchange(sizeof(int) * count, (void *)recv_buf, (void *)send_buf, idir, ipm, itag);
183 }
184 
185 
186 //====================================================================
187 int Communicator::Base::send_1to1(size_t size, void *recv_buf, void *send_buf, int send_to, int recv_from, int tag)
188 {
189  return Communicator_impl::Base::send_1to1(size, recv_buf, send_buf, send_to, recv_from, tag);
190 }
191 
192 
193 int Communicator::send_1to1(int count, double *recv_buf, double *send_buf, int send_to, int recv_from, int tag)
194 {
195  return Communicator_impl::Base::send_1to1(sizeof(double) * count, (void *)recv_buf, (void *)send_buf, send_to, recv_from, tag);
196 }
197 
198 
199 int Communicator::send_1to1(int count, int *recv_buf, int *send_buf, int send_to, int recv_from, int tag)
200 {
201  return Communicator_impl::Base::send_1to1(sizeof(int) * count, (void *)recv_buf, (void *)send_buf, send_to, recv_from, tag);
202 }
203 
204 
205 //====================================================================
206 int Communicator::reduce_sum(int count, double *recv_buf, double *send_buf, int pattern)
207 {
208  return Communicator_impl::Base::reduce(count, (void *)recv_buf, (void *)send_buf, MPI_DOUBLE, MPI_SUM, pattern);
209 }
210 
211 
212 int Communicator::reduce_sum(int count, int *recv_buf, int *send_buf, int pattern)
213 {
214  return Communicator_impl::Base::reduce(count, (void *)recv_buf, (void *)send_buf, MPI_INT, MPI_SUM, pattern);
215 }
216 
217 
218 //====================================================================
219 int Communicator::reduce_max(int count, double *recv_buf, double *send_buf, int pattern)
220 {
221  return Communicator_impl::Base::reduce(count, (void *)recv_buf, (void *)send_buf, MPI_DOUBLE, MPI_MAX, pattern);
222 }
223 
224 
225 int Communicator::reduce_max(int count, int *recv_buf, int *send_buf, int pattern)
226 {
227  return Communicator_impl::Base::reduce(count, (void *)recv_buf, (void *)send_buf, MPI_INT, MPI_MAX, pattern);
228 }
229 
230 
231 //====================================================================
232 int Communicator::reduce_min(int count, double *recv_buf, double *send_buf, int pattern)
233 {
234  return Communicator_impl::Base::reduce(count, (void *)recv_buf, (void *)send_buf, MPI_DOUBLE, MPI_MIN, pattern);
235 }
236 
237 
238 int Communicator::reduce_min(int count, int *recv_buf, int *send_buf, int pattern)
239 {
240  return Communicator_impl::Base::reduce(count, (void *)recv_buf, (void *)send_buf, MPI_INT, MPI_MIN, pattern);
241 }
242 
243 
244 //====================================================================
245 double Communicator::reduce_sum(double a)
246 {
247  double ar = double();
248 
249  reduce_sum(1, &ar, &a, 0);
250  return ar;
251 }
252 
253 
254 //====================================================================
255 double Communicator::reduce_max(double a)
256 {
257  double ar = double();
258 
259  reduce_max(1, &ar, &a, 0);
260  return ar;
261 }
262 
263 
264 //====================================================================
265 double Communicator::reduce_min(double a)
266 {
267  double ar = double();
268 
269  reduce_min(1, &ar, &a, 0);
270  return ar;
271 }
272 
273 
274 //====================================================================
275 double Communicator::get_time()
276 {
278 }
279 
280 
281 //====================================================================
283 {
284  return Communicator_impl::status();
285 }
286 
287 
288 //====================================================================
289 Channel* Communicator::send_init(int count, int idir, int ipm)
290 {
291  return Communicator_impl::send_init(count, idir, ipm);
292 }
293 
294 //====================================================================
295 Channel* Communicator::recv_init(int count, int idir, int ipm)
296 {
297  return Communicator_impl::recv_init(count, idir, ipm);
298 }
299 
300 
301 //====================================================================
302 //============================================================END=====
static int send_1to1(size_t size, void *recv_buf, void *send_buf, int send_to, int recv_from, int tag)
static int broadcast(size_t size, void *data, int sender)
static int npe(const int dir)
logical grid extent
static int reduce_max(int count, double *recv_buf, double *send_buf, int pattern=0)
find a global maximum of an array of double over the communicator. pattern specifies the dimensions t...
static void abort()
terminate communicator
static int self()
rank within small world.
static bool is_primary_master()
check if the present node is primary in global communicator.
static int init(int *pargc, char ***pargv)
initialize communicator
static int grid_coord(int *gcoord, const int rank)
static int grid_coord(int *grid_coord, const int rank)
find grid coordinate from rank number.
static int sync()
synchronize within small world.
static int reduce_min(int count, double *recv_buf, double *send_buf, int pattern=0)
find a global minimum of an array of double over the communicator. pattern specifies the dimensions t...
static int setup(int ninstance=1)
static Channel * recv_init(int count, int idir, int ipm)
static int status()
for debug
static int broadcast(size_t size, void *data, int sender)
static int ipe(const int dir)
logical coordinate of current proc.
static int grid_rank(int *rank, const int *gcoord)
static bool is_primary()
info about rank
static int npe(const int idir)
Definition: layout.cpp:57
Channel class for asynchronous communication.
Definition: channel.h:24
static int reduce(int count, void *recv_buf, void *send_buf, int type, int op, int pattern)
static int finalize()
finalize communicator
static int init(int *pargc, char ***pargv)
static int send_1to1(int count, double *recv_buf, double *send_buf, int p_to, int p_from, int tag)
send array of double from rank p_from to rank p_to. communication distinguished by tag...
static int grid_dims(int *gdims)
Definition: layout.cpp:64
static int exchange(size_t size, void *recv_buf, void *send_buf, int idir, int ipm, int tag)
static int grid_dims(int *grid_dims)
find grid dimensions.
static int broadcast_string(int count, string &data, int sender)
for specific datatypes
static double get_time()
for getting time interval using clock count.
static int exchange(int count, double *recv_buf, double *send_buf, int idir, int ipm, int tag)
receive array of double from upstream specified by idir and ipm, and send array to downstream...
static int status()
static int grid_rank(int *rank, const int *grid_coord)
find rank number from grid coordinate.
static int setup(int ninstance=1)
setup communicator
static int ipe(const int idir)
Definition: layout.cpp:50
static Channel * recv_init(int count, int idir, int ipm)
Definition: channel.cpp:98
static int send_1to1(size_t size, void *recv_buf, void *send_buf, int send_to, int recv_from, int tag)
static Channel * send_init(int count, int idir, int ipm)
async communication
Definition: channel.cpp:61
static int size()
size of small world.
static double get_time()
obtain a wall-clock time.
static Channel * send_init(int count, int idir, int ipm)
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
static int sync()
synchronize within small world.
static int broadcast(int count, double *data, int sender)
broadcast array of double from sender.
static bool is_primary()
check if the present node is primary in small communicator.
static int exchange(size_t size, void *recv_buf, void *send_buf, int idir, int ipm, int tag)