54 assert(ninstance == 1);
63 fprintf(stderr,
"Communicator::setup(): inappropriate grid_size.\n");
76 const std::vector<int>& lattice_size,
77 std::vector<int>& grid_size,
81 int ndim = lattice_size.size();
83 if (grid_size.size() != ndim) {
84 grid_size.resize(ndim, 1);
88 for (
int i = 0; i < ndim; ++i) {
89 if (grid_size[i] != 1) {
95 printf(
"ERROR: %s: unexpected grid_size.\n", __func__);
132 int Communicator::self_global()
165 for (
int i = 0; i < Ndim; ++i) {
177 for (
int i = 0; i < Ndim; ++i) {
199 int Communicator::sync_global()
244 memcpy(recv_buf, send_buf, size);
251 memcpy(recv_buf, send_buf,
sizeof(
double) * count);
258 memcpy(recv_buf, send_buf,
sizeof(
float) * count);
265 memcpy(recv_buf, send_buf,
sizeof(
int) * count);
273 memcpy(recv_buf, send_buf, size);
278 int Communicator::send_1to1(
int count,
double *recv_buf,
double *send_buf,
int send_to,
int recv_from,
int tag)
280 memcpy(recv_buf, send_buf,
sizeof(
double) * count);
287 memcpy(recv_buf, send_buf,
sizeof(
float) * count);
294 memcpy(recv_buf, send_buf,
sizeof(
int) * count);
302 memcpy(recv_buf, send_buf,
sizeof(
double) * count);
309 memcpy(recv_buf, send_buf,
sizeof(
float) * count);
316 memcpy(recv_buf, send_buf,
sizeof(
int) * count);
367 printf(
"Communicator Single\n");
378 if (gettimeofday(&now, (
struct timezone *)0) != 0) {
382 double sec = (double)now.tv_sec + ((
double)now.tv_usec) * 1.0e-6;
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 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 grid_rank(int *rank, const int *grid_coord)
find rank number from grid coordinate.
static int setup(int ninstance=1)
setup communicator
static int sync_usleep()
synchronize within small world. (slow but no busy wait)
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 bool is_primary()
check if the present node is primary in small communicator.