Bridge++  Ver. 1.3.x
communicator_bgnet.h
Go to the documentation of this file.
1 
14 #ifndef COMMUNICATOR_BGNET_INCLUDED
15 #define COMMUNICATOR_BGNET_INCLUDED
16 
17 #include <exception>
18 #include <cassert>
19 
20 #include <bgnet.h>
21 
22 #include "channel.h"
23 
25 
39  public:
40  static int init(int *pargc, char ***pargv);
41  static int finalize();
42  static void abort();
43 
44  static int setup(int ninstance = 1);
45 
47  static bool is_primary();
48 
49 #ifdef ENABLE_MULTI_INSTANCE
50  static bool is_primary_master();
51 #endif
52 
53  static int self(); //< rank within small world.
54  static int size(); //< size of small world.
55 
56 #ifdef ENABLE_MULTI_INSTANCE
57  static int self_global();
58  static int world_id();
59 #endif
60 
61 
62  // static MPI_Comm& world() { return m_comm; }
63  static int world() { return m_comm; }
64 
65 #if 0
66  static int ipe(const int dir);
68  static int npe(const int dir);
69 
70  static int grid_rank(int *rank, const int *grid_coord);
71  static int grid_coord(int *grid_coord, const int rank);
72  static int grid_dims(int *grid_dims);
73 #endif
74 
75 // synchronize
76  static int sync();
77 
78 #ifdef ENABLE_MULTI_INSTANCE
79  static int sync_global();
80 #endif
81 
83  static double get_time();
84 
86  static int status();
87 
89  class Base {
90  public:
91  static int reduce(int count, void *recv_buf, void *send_buf,
92  int type, int op, int pattern);
93 
94  static int broadcast(size_t size, void *data, int sender);
95 
96  static int exchange(size_t size, void *recv_buf, void *send_buf,
97  int idir, int ipm, int tag);
98 
99  static int send_1to1(size_t size, void *recv_buf, void *send_buf,
100  int send_to, int recv_from, int tag);
101  };
102 
104  static int broadcast_string(int count, string& data, int sender);
105  static int broadcast_double(int count, double *data, int sender);
106  static int broadcast_int(int count, int *data, int sender);
107 
109  static Channel *send_init(int count, int idir, int ipm);
110  static Channel *recv_init(int count, int idir, int ipm);
111 
113  class Layout;
114 
115  private:
116 
120 
122 
123 #ifdef ENABLE_MULTI_INSTANCE
124  static int m_n_instance;
125  static int m_instance_id;
126 
127  static int m_global_rank;
128  static int m_global_size;
129 #endif
130 
131  static int m_grid_rank;
132  static int m_grid_size;
133 
134  static int m_comm;
135 };
136 #endif /* #ifndef COMMUNICATOR_BGNET_INCLUDED */
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 broadcast_double(int count, double *data, int sender)
static int sync()
synchronize within small world.
static int setup(int ninstance=1)
static int status()
for debug
static int broadcast_int(int count, int *data, int sender)
static bool is_primary()
info about rank
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 init(int *pargc, char ***pargv)
Layout class for logical organisation of parallel nodes.
Definition: layout.h:19
static int m_comm
instead of MPI_Comm m_comm;
static int broadcast_string(int count, string &data, int sender)
for specific datatypes
Communicator_impl & operator=(const Communicator_impl &)
static double get_time()
for getting time interval using clock count.
static Channel * recv_init(int count, int idir, int ipm)
Definition: channel.cpp:98
static Channel * send_init(int count, int idir, int ipm)
async communication
Definition: channel.cpp:61
Communicator_impl(const Communicator_impl &)
Implementation of Communicator with BGNET library.
static int exchange(size_t size, void *recv_buf, void *send_buf, int idir, int ipm, int tag)