Bridge++  Ver. 2.0.2
Communicator Class Reference

Communication library which wraps MPI. More...

#include <communicator.h>

Classes

class  Base
 base case More...
 

Static Public Member Functions

static int init (int *pargc, char ***pargv)
 initialize communicator More...
 
static int finalize ()
 finalize communicator More...
 
static void abort ()
 terminate communicator More...
 
static int setup (int ninstance=1)
 setup communicator More...
 
static int setup (const std::vector< int > &lattice_size, std::vector< int > &grid_size, int ninstance=1)
 
static bool is_primary ()
 check if the present node is primary in small communicator. More...
 
static bool is_primary_master ()
 check if the present node is primary in global communicator. More...
 
static int self ()
 rank within small world. More...
 
static int size ()
 size of small world. More...
 
static int ipe (const int dir)
 logical coordinate of current proc. More...
 
static int npe (const int dir)
 logical grid extent More...
 
static int grid_rank (int *rank, const int *grid_coord)
 find rank number from grid coordinate. More...
 
static int grid_coord (int *grid_coord, const int rank)
 find grid coordinate from rank number. More...
 
static int grid_dims (int *grid_dims)
 find grid dimensions. More...
 
static int sync ()
 synchronize within small world. More...
 
static int sync_usleep ()
 synchronize within small world. (slow but no busy wait) More...
 
static int broadcast (int count, dcomplex *data, int sender)
 broadcast array of dcomplex from sender. More...
 
static int broadcast (int count, double *data, int sender)
 broadcast array of double from sender. More...
 
static int broadcast (int count, float *data, int sender)
 broadcast array of float from sender. More...
 
static int broadcast (int count, int *data, int sender)
 broadcast array of integer from sender. More...
 
static int broadcast (int count, string &data, int sender)
 broadcast a string from sender. count is insignificant. More...
 
static int exchange (int count, dcomplex *recv_buf, dcomplex *send_buf, int idir, int ipm, int tag)
 receive array of dcomplex from upstream specified by idir and ipm, and send array to downstream. More...
 
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. More...
 
static int exchange (int count, float *recv_buf, float *send_buf, int idir, int ipm, int tag)
 receive array of float from upstream specified by idir and ipm, and send array to downstream. More...
 
static int exchange (int count, int *recv_buf, int *send_buf, int idir, int ipm, int tag)
 receive array of int from upstream specified by idir and ipm, and send array to downstream. More...
 
static int send_1to1 (int count, dcomplex *recv_buf, dcomplex *send_buf, int p_to, int p_from, int tag)
 send array of dcomplex from rank p_from to rank p_to. communication distinguished by tag. More...
 
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. More...
 
static int send_1to1 (int count, float *recv_buf, float *send_buf, int p_to, int p_from, int tag)
 send array of float from rank p_from to rank p_to. communication distinguished by tag. More...
 
static int send_1to1 (int count, int *recv_buf, int *send_buf, int p_to, int p_from, int tag)
 send array of int from rank p_from to rank p_to. communication distinguished by tag. More...
 
static int reduce_sum (int count, dcomplex *recv_buf, dcomplex *send_buf, int pattern=0)
 make a global sum of an array of dcomplex over the communicator. pattern specifies the dimensions to be reduced. More...
 
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 reduced. More...
 
static int reduce_sum (int count, float *recv_buf, float *send_buf, int pattern=0)
 make a global sum of an array of float over the communicator. pattern specifies the dimensions to be reduced. More...
 
static int reduce_sum (int count, int *recv_buf, int *send_buf, int pattern=0)
 make a global sum of an array of int over the communicator. pattern specifies the dimensions to be reduced. More...
 
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 to be reduced. More...
 
static int reduce_max (int count, float *recv_buf, float *send_buf, int pattern=0)
 find a global maximum of an array of float over the communicator. pattern specifies the dimensions to be reduced. More...
 
static int reduce_max (int count, int *recv_buf, int *send_buf, int pattern=0)
 find a global maximum of an array of int over the communicator. pattern specifies the dimensions to be reduced. More...
 
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 to be reduced. More...
 
static int reduce_min (int count, float *recv_buf, float *send_buf, int pattern=0)
 find a global minimum of an array of float over the communicator. pattern specifies the dimensions to be reduced. More...
 
static int reduce_min (int count, int *recv_buf, int *send_buf, int pattern=0)
 find a global minimum of an array of int over the communicator. pattern specifies the dimensions to be reduced. More...
 
static dcomplex reduce_sum (dcomplex)
 alternative interface to reduce_sum(). returns the global sum of a dcomplex over the whole communicator. More...
 
static double reduce_sum (double)
 alternative interface to reduce_sum(). returns the global sum of a double over the whole communicator. More...
 
static double reduce_max (double)
 alternative interface to reduce_max(). returns the global sum of a double over the whole communicator. More...
 
static double reduce_min (double)
 alternative interface to reduce_min(). returns the global sum of a double over the whole communicator. More...
 
static float reduce_sum (float)
 alternative interface to reduce_sum(). returns the global sum of a float over the whole communicator. More...
 
static float reduce_max (float)
 alternative interface to reduce_max(). returns the global sum of a float over the whole communicator. More...
 
static float reduce_min (float)
 alternative interface to reduce_min(). returns the global sum of a float over the whole communicator. More...
 
static double get_time ()
 obtain a wall-clock time. More...
 
static Channel * send_init (int count, int idir, int ipm)
 
static Channel * recv_init (int count, int idir, int ipm)
 
static Channel * send_init (int count, int idir, int ipm, void *buf)
 
static Channel * recv_init (int count, int idir, int ipm, void *buf)
 
static int status ()
 

Private Member Functions

 Communicator ()
 no instance at all More...
 
 Communicator (const Communicator &)
 
Communicatoroperator= (const Communicator &)
 
 ~Communicator ()
 

Detailed Description

Communication library which wraps MPI.

This class provides a communication library which wraps MPI (Message Passing Interface) if the implementation file communicator_mpi.cpp is bound. In the single processor environment with no MPI library, communicator_single.cpp should be bound instead. [28 Dec 2011 H.Matsufuru]

This class defines interface of inter-node communication routines. All methods are static, i.e. class-methods (like global). The explicit definitions are hidden in the implementation classes.

Add complex args [08 Aug 2020 Y.Namekawa]

Definition at line 50 of file communicator.h.

Constructor & Destructor Documentation

◆ Communicator() [1/2]

Communicator::Communicator ( )
inlineprivate

no instance at all

communicator class is not indented to be instantiated. constructor, copy constroctor, assignment operator, and destructor are defined as private.

Definition at line 213 of file communicator.h.

◆ Communicator() [2/2]

Communicator::Communicator ( const Communicator )
inlineprivate

Definition at line 214 of file communicator.h.

◆ ~Communicator()

Communicator::~Communicator ( )
inlineprivate

Definition at line 217 of file communicator.h.

Member Function Documentation

◆ abort()

void Communicator::abort ( )
static

terminate communicator

terminate communicator immediately at some erroneous situations.

Definition at line 36 of file communicator.cpp.

◆ broadcast() [1/5]

int Communicator::broadcast ( int  count,
dcomplex *  data,
int  sender 
)
static

broadcast array of dcomplex from sender.

Definition at line 170 of file communicator.cpp.

◆ broadcast() [2/5]

int Communicator::broadcast ( int  count,
double *  data,
int  sender 
)
static

broadcast array of double from sender.

Definition at line 176 of file communicator.cpp.

◆ broadcast() [3/5]

int Communicator::broadcast ( int  count,
float *  data,
int  sender 
)
static

broadcast array of float from sender.

Definition at line 182 of file communicator.cpp.

◆ broadcast() [4/5]

int Communicator::broadcast ( int  count,
int *  data,
int  sender 
)
static

broadcast array of integer from sender.

Definition at line 188 of file communicator.cpp.

◆ broadcast() [5/5]

int Communicator::broadcast ( int  count,
string &  data,
int  sender 
)
static

broadcast a string from sender. count is insignificant.

Definition at line 194 of file communicator.cpp.

◆ exchange() [1/4]

int Communicator::exchange ( int  count,
dcomplex *  recv_buf,
dcomplex *  send_buf,
int  idir,
int  ipm,
int  tag 
)
static

receive array of dcomplex from upstream specified by idir and ipm, and send array to downstream.

Definition at line 207 of file communicator.cpp.

◆ exchange() [2/4]

int Communicator::exchange ( int  count,
double *  recv_buf,
double *  send_buf,
int  idir,
int  ipm,
int  tag 
)
static

receive array of double from upstream specified by idir and ipm, and send array to downstream.

Definition at line 213 of file communicator.cpp.

◆ exchange() [3/4]

int Communicator::exchange ( int  count,
float *  recv_buf,
float *  send_buf,
int  idir,
int  ipm,
int  tag 
)
static

receive array of float from upstream specified by idir and ipm, and send array to downstream.

Definition at line 219 of file communicator.cpp.

◆ exchange() [4/4]

int Communicator::exchange ( int  count,
int *  recv_buf,
int *  send_buf,
int  idir,
int  ipm,
int  tag 
)
static

receive array of int from upstream specified by idir and ipm, and send array to downstream.

Definition at line 225 of file communicator.cpp.

◆ finalize()

int Communicator::finalize ( )
static

finalize communicator

finalize communicator. terminates communication environment.

Definition at line 29 of file communicator.cpp.

◆ get_time()

double Communicator::get_time ( )
static

obtain a wall-clock time.

Definition at line 401 of file communicator.cpp.

◆ grid_coord()

int Communicator::grid_coord ( int *  grid_coord,
const int  rank 
)
static

find grid coordinate from rank number.

Definition at line 126 of file communicator.cpp.

◆ grid_dims()

int Communicator::grid_dims ( int *  grid_dims)
static

find grid dimensions.

Definition at line 133 of file communicator.cpp.

◆ grid_rank()

int Communicator::grid_rank ( int *  rank,
const int *  grid_coord 
)
static

find rank number from grid coordinate.

Definition at line 119 of file communicator.cpp.

◆ init()

int Communicator::init ( int *  pargc,
char ***  pargv 
)
static

initialize communicator

initialize communicator.

Parameters
pargcpointer to argc passed from main function.
pargvpointer to argv passed from main function.

they would further be passed to communication library for hints to machine-dependent configurations.

MPI implementation of Communicator class which delegates to Communicator_impl class.

MPI implementation of Communicator class which delegates to Communicator_impl class.

removed send_init(...) and recv_init(...) [5 May 2022 I.Kanamori]

Definition at line 22 of file communicator.cpp.

◆ ipe()

int Communicator::ipe ( const int  dir)
static

logical coordinate of current proc.

Definition at line 105 of file communicator.cpp.

◆ is_primary()

bool Communicator::is_primary ( )
static

check if the present node is primary in small communicator.

Definition at line 60 of file communicator.cpp.

◆ is_primary_master()

bool Communicator::is_primary_master ( )
static

check if the present node is primary in global communicator.

Definition at line 67 of file communicator.cpp.

◆ npe()

int Communicator::npe ( const int  dir)
static

logical grid extent

Definition at line 112 of file communicator.cpp.

◆ operator=()

Communicator& Communicator::operator= ( const Communicator )
private

◆ recv_init() [1/2]

static Channel* Communicator::recv_init ( int  count,
int  idir,
int  ipm 
)
static

◆ recv_init() [2/2]

static Channel* Communicator::recv_init ( int  count,
int  idir,
int  ipm,
void *  buf 
)
static

◆ reduce_max() [1/5]

double Communicator::reduce_max ( double  a)
static

alternative interface to reduce_max(). returns the global sum of a double over the whole communicator.

Definition at line 354 of file communicator.cpp.

◆ reduce_max() [2/5]

float Communicator::reduce_max ( float  a)
static

alternative interface to reduce_max(). returns the global sum of a float over the whole communicator.

Definition at line 382 of file communicator.cpp.

◆ reduce_max() [3/5]

int Communicator::reduce_max ( int  count,
double *  recv_buf,
double *  send_buf,
int  pattern = 0 
)
static

find a global maximum of an array of double over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 290 of file communicator.cpp.

◆ reduce_max() [4/5]

int Communicator::reduce_max ( int  count,
float *  recv_buf,
float *  send_buf,
int  pattern = 0 
)
static

find a global maximum of an array of float over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 296 of file communicator.cpp.

◆ reduce_max() [5/5]

int Communicator::reduce_max ( int  count,
int *  recv_buf,
int *  send_buf,
int  pattern = 0 
)
static

find a global maximum of an array of int over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 302 of file communicator.cpp.

◆ reduce_min() [1/5]

double Communicator::reduce_min ( double  a)
static

alternative interface to reduce_min(). returns the global sum of a double over the whole communicator.

Definition at line 363 of file communicator.cpp.

◆ reduce_min() [2/5]

float Communicator::reduce_min ( float  a)
static

alternative interface to reduce_min(). returns the global sum of a float over the whole communicator.

Definition at line 391 of file communicator.cpp.

◆ reduce_min() [3/5]

int Communicator::reduce_min ( int  count,
double *  recv_buf,
double *  send_buf,
int  pattern = 0 
)
static

find a global minimum of an array of double over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 311 of file communicator.cpp.

◆ reduce_min() [4/5]

int Communicator::reduce_min ( int  count,
float *  recv_buf,
float *  send_buf,
int  pattern = 0 
)
static

find a global minimum of an array of float over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 317 of file communicator.cpp.

◆ reduce_min() [5/5]

int Communicator::reduce_min ( int  count,
int *  recv_buf,
int *  send_buf,
int  pattern = 0 
)
static

find a global minimum of an array of int over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 323 of file communicator.cpp.

◆ reduce_sum() [1/7]

dcomplex Communicator::reduce_sum ( dcomplex  a)
static

alternative interface to reduce_sum(). returns the global sum of a dcomplex over the whole communicator.

Definition at line 330 of file communicator.cpp.

◆ reduce_sum() [2/7]

double Communicator::reduce_sum ( double  a)
static

alternative interface to reduce_sum(). returns the global sum of a double over the whole communicator.

Definition at line 345 of file communicator.cpp.

◆ reduce_sum() [3/7]

float Communicator::reduce_sum ( float  a)
static

alternative interface to reduce_sum(). returns the global sum of a float over the whole communicator.

Definition at line 373 of file communicator.cpp.

◆ reduce_sum() [4/7]

int Communicator::reduce_sum ( int  count,
dcomplex *  recv_buf,
dcomplex *  send_buf,
int  pattern = 0 
)
static

make a global sum of an array of dcomplex over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 263 of file communicator.cpp.

◆ reduce_sum() [5/7]

int Communicator::reduce_sum ( int  count,
double *  recv_buf,
double *  send_buf,
int  pattern = 0 
)
static

make a global sum of an array of double over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 269 of file communicator.cpp.

◆ reduce_sum() [6/7]

int Communicator::reduce_sum ( int  count,
float *  recv_buf,
float *  send_buf,
int  pattern = 0 
)
static

make a global sum of an array of float over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 275 of file communicator.cpp.

◆ reduce_sum() [7/7]

int Communicator::reduce_sum ( int  count,
int *  recv_buf,
int *  send_buf,
int  pattern = 0 
)
static

make a global sum of an array of int over the communicator. pattern specifies the dimensions to be reduced.

Definition at line 281 of file communicator.cpp.

◆ self()

int Communicator::self ( )
static

rank within small world.

Definition at line 74 of file communicator.cpp.

◆ send_1to1() [1/4]

int Communicator::send_1to1 ( int  count,
dcomplex *  recv_buf,
dcomplex *  send_buf,
int  p_to,
int  p_from,
int  tag 
)
static

send array of dcomplex from rank p_from to rank p_to. communication distinguished by tag.

Definition at line 238 of file communicator.cpp.

◆ send_1to1() [2/4]

int Communicator::send_1to1 ( int  count,
double *  recv_buf,
double *  send_buf,
int  p_to,
int  p_from,
int  tag 
)
static

send array of double from rank p_from to rank p_to. communication distinguished by tag.

Definition at line 244 of file communicator.cpp.

◆ send_1to1() [3/4]

int Communicator::send_1to1 ( int  count,
float *  recv_buf,
float *  send_buf,
int  p_to,
int  p_from,
int  tag 
)
static

send array of float from rank p_from to rank p_to. communication distinguished by tag.

Definition at line 250 of file communicator.cpp.

◆ send_1to1() [4/4]

int Communicator::send_1to1 ( int  count,
int *  recv_buf,
int *  send_buf,
int  p_to,
int  p_from,
int  tag 
)
static

send array of int from rank p_from to rank p_to. communication distinguished by tag.

Definition at line 256 of file communicator.cpp.

◆ send_init() [1/2]

static Channel* Communicator::send_init ( int  count,
int  idir,
int  ipm 
)
static

◆ send_init() [2/2]

static Channel* Communicator::send_init ( int  count,
int  idir,
int  ipm,
void *  buf 
)
static

◆ setup() [1/2]

int Communicator::setup ( const std::vector< int > &  lattice_size,
std::vector< int > &  grid_size,
int  ninstance = 1 
)
static

setup communicator environment with lattice size and (hint of) grid size provided.

Parameters
grid_sizemay be incomplete, in that case it is determined from the total number of processes and the lattice size and overwritten.

Definition at line 50 of file communicator.cpp.

◆ setup() [2/2]

int Communicator::setup ( int  ninstance = 1)
static

setup communicator

setup communicator environment such as logical layout. called after the parameters are obtained.

Parameters
ninstancespecifies multiplicity of trivial parallelism. (expects 1 at present).

Definition at line 43 of file communicator.cpp.

◆ size()

int Communicator::size ( )
static

size of small world.

Definition at line 81 of file communicator.cpp.

◆ status()

int Communicator::status ( )
static

Definition at line 408 of file communicator.cpp.

◆ sync()

int Communicator::sync ( )
static

synchronize within small world.

Definition at line 140 of file communicator.cpp.

◆ sync_usleep()

int Communicator::sync_usleep ( )
static

synchronize within small world. (slow but no busy wait)

Definition at line 147 of file communicator.cpp.


The documentation for this class was generated from the following files: