Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
communicator_single.cpp
Go to the documentation of this file.
1 
10 #include "configure.h"
11 #include "defs.h"
12 
13 #include <cstdio>
14 #include <cstdarg>
15 #include <cstring>
16 #include "commonParameters.h"
17 #include "communicator.h"
18 //#include "field.h"
19 #include <sys/time.h>
20 #include <time.h>
21 #include <cassert>
22 
23 static const char rcsid[] = "$Id";
24 
25 //namespace Communicator {
27 //}
28 
29 int Communicator::init(int *pargc, char ***pargv)
30 {
31  return BRIDGE_SUCCESS;
32 }
33 
34 
36 {
37  return BRIDGE_SUCCESS;
38 }
39 
40 
42 {
43  ::abort(); // call system function.
44 }
45 
46 
47 int Communicator::setup(int ninstance)
48 {
50  return BRIDGE_SUCCESS;
51 }
52 
53 
55 {
56  return true;
57 }
58 
59 
61 {
62  return true;
63 }
64 
65 
67 {
68  return 0;
69 }
70 
71 
73 {
74  return 1;
75 }
76 
77 
78 int Communicator::self_global()
79 {
80  return 0;
81 }
82 
83 
84 int Communicator::ipe(const int dir)
85 {
86  return 0;
87 }
88 
89 
90 int Communicator::npe(const int dir)
91 {
92  return 1;
93 }
94 
95 
96 int Communicator::grid_rank(int *rank, const int *gcoord)
97 {
98  *rank = 0;
99  return BRIDGE_SUCCESS;
100 }
101 
102 
103 int Communicator::grid_coord(int *gcoord, const int rank)
104 {
105  for (int i = 0; i < m_ndim; ++i) {
106  gcoord[i] = 0;
107  }
108  return BRIDGE_SUCCESS;
109 }
110 
111 
112 int Communicator::grid_dims(int *gdims)
113 {
114  for (int i = 0; i < m_ndim; ++i) {
115  gdims[i] = 1;
116  }
117  return BRIDGE_SUCCESS;
118 }
119 
120 
121 int Communicator::sync()
122 {
123  return BRIDGE_SUCCESS;
124 }
125 
126 
127 int Communicator::sync_global()
128 {
129  return BRIDGE_SUCCESS;
130 }
131 
132 
133 int Communicator::Base::broadcast(size_t size, void *data, int sender)
134 {
135  // stay intact
136  return BRIDGE_SUCCESS;
137 }
138 
139 
140 int Communicator::broadcast(int count, double *data, int sender)
141 {
142  // stay intact
143  return BRIDGE_SUCCESS;
144 }
145 
146 
147 int Communicator::broadcast(int count, int *data, int sender)
148 {
149  // stay intact
150  return BRIDGE_SUCCESS;
151 }
152 
153 
154 int Communicator::broadcast(int count, string& data, int sender)
155 {
156  // stay intact
157  return BRIDGE_SUCCESS;
158 }
159 
160 
161 int Communicator::Base::exchange(size_t size, void *recv_buf, void *send_buf, int idir, int ipm, int tag)
162 {
163  memcpy(recv_buf, send_buf, size);
164  return BRIDGE_SUCCESS;
165 }
166 
167 
168 int Communicator::exchange(int count, double *recv_buf, double *send_buf, int idir, int ipm, int tag)
169 {
170  memcpy(recv_buf, send_buf, sizeof(double) * count);
171  return BRIDGE_SUCCESS;
172 }
173 
174 
175 int Communicator::exchange(int count, int *recv_buf, int *send_buf, int idir, int ipm, int tag)
176 {
177  memcpy(recv_buf, send_buf, sizeof(int) * count);
178  return BRIDGE_SUCCESS;
179 }
180 
181 
182 int Communicator::Base::send_1to1(size_t size, void *recv_buf, void *send_buf, int send_to, int recv_from, int tag)
183 {
184  memcpy(recv_buf, send_buf, size);
185  return BRIDGE_SUCCESS;
186 }
187 
188 
189 int Communicator::send_1to1(int count, double *recv_buf, double *send_buf, int send_to, int recv_from, int tag)
190 {
191  memcpy(recv_buf, send_buf, sizeof(double) * count);
192  return BRIDGE_SUCCESS;
193 }
194 
195 
196 int Communicator::send_1to1(int count, int *recv_buf, int *send_buf, int send_to, int recv_from, int tag)
197 {
198  memcpy(recv_buf, send_buf, sizeof(int) * count);
199  return BRIDGE_SUCCESS;
200 }
201 
202 
203 int Communicator::reduce_sum(int count, double *recv_buf, double *send_buf, int pattern)
204 {
205  memcpy(recv_buf, send_buf, sizeof(double) * count);
206  return BRIDGE_SUCCESS;
207 }
208 
209 
210 int Communicator::reduce_sum(int count, int *recv_buf, int *send_buf, int pattern)
211 {
212  memcpy(recv_buf, send_buf, sizeof(int) * count);
213  return BRIDGE_SUCCESS;
214 }
215 
216 
217 double Communicator::reduce_sum(double v)
218 {
219  return v;
220 }
221 
222 
223 double Communicator::reduce_max(double v)
224 {
225  return v;
226 }
227 
228 
229 double Communicator::reduce_min(double v)
230 {
231  return v;
232 }
233 
234 
236 {
237 #ifdef DEBUG
238  printf("Communicator Single\n");
239 #endif
240  return BRIDGE_SUCCESS;
241 }
242 
243 
244 double Communicator::get_time()
245 {
246  struct timeval now;
247 
248  if (gettimeofday(&now, (struct timezone *)0) != 0) {
249  return double();
250  }
251 
252  double sec = (double)now.tv_sec + ((double)now.tv_usec) * 1.0e-6;
253 
254  return sec;
255 }
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 *grid_coord, const int rank)
find grid coordinate from rank number.
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 m_ndim
static int broadcast(size_t size, void *data, int sender)
static int ipe(const int dir)
logical coordinate of current proc.
static int finalize()
finalize communicator
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 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 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 send_1to1(size_t size, void *recv_buf, void *send_buf, int send_to, int recv_from, int tag)
static int size()
size of small world.
static double get_time()
obtain a wall-clock time.
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 const char rcsid[]
static bool is_primary()
check if the present node is primary in small communicator.