Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "configure.h"
23 #include "defs.h"
24 #include "communicator.h"
25 #include "channel.h"
26 
28 
42  public:
43  static int init(int *pargc, char ***pargv);
44  static int finalize();
45  static void abort();
46 
47  static int setup(int ninstance = 1);
48 
50  static bool is_primary();
51 
52 #ifdef ENABLE_MULTI_INSTANCE
53  static bool is_primary_master();
54 
55 #endif
56 
57  static int self(); //< rank within small world.
58  static int size(); //< size of small world.
59 
60 #ifdef ENABLE_MULTI_INSTANCE
61  static int self_global();
62  static int world_id();
63 
64 #endif
65 
66 
67  // static MPI_Comm& world() { return m_comm; }
68  static int world() { return m_comm; }
69 
70 #if 0
71  static int ipe(const int dir);
73  static int npe(const int dir);
74 
75  static int grid_rank(int *rank, const int *grid_coord);
76  static int grid_coord(int *grid_coord, const int rank);
77  static int grid_dims(int *grid_dims);
78 
79 #endif
80 
81 // synchronize
82  static int sync();
83 
84 #ifdef ENABLE_MULTI_INSTANCE
85  static int sync_global();
86 
87 #endif
88 
90  static double get_time();
91 
93  static int status();
94 
96  class Base {
97  public:
98  static int reduce(int count, void *recv_buf, void *send_buf,
99  int type, int op, int pattern);
100 
101  static int broadcast(size_t size, void *data, int sender);
102 
103  static int exchange(size_t size, void *recv_buf, void *send_buf,
104  int idir, int ipm, int tag);
105 
106  static int send_1to1(size_t size, void *recv_buf, void *send_buf,
107  int send_to, int recv_from, int tag);
108  };
109 
111  static int broadcast_string(int count, string& data, int sender);
112  static int broadcast_double(int count, double *data, int sender);
113  static int broadcast_int(int count, int *data, int sender);
114 
116  static Channel *send_init(int count, int idir, int ipm);
117  static Channel *recv_init(int count, int idir, int ipm);
118 
120  class Layout;
121 
122  private:
123 
127 
129 
130 #ifdef ENABLE_MULTI_INSTANCE
131  static int m_n_instance;
132  static int m_instance_id;
133 
134  static int m_global_rank;
135  static int m_global_size;
136 #endif
137 
138  static int m_grid_rank;
139  static int m_grid_size;
140 
141  static int m_comm;
142 };
143 
144 #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:16
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:20
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:100
static Channel * send_init(int count, int idir, int ipm)
async communication
Definition: channel.cpp:63
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)