Bridge++  Ver. 1.3.x
communicator_mpi.h
Go to the documentation of this file.
1 
14 #ifndef COMMUNICATOR_MPI_INCLUDED
15 #define COMMUNICATOR_MPI_INCLUDED
16 
17 #include <cstdarg>
18 #include <cstring>
19 #include <exception>
20 
21 #include "communicator.h"
22 #include "channel.h"
23 
25 
32 class Communicator_impl {
33  public:
34  static int init(int *pargc, char ***pargv);
35  static int finalize();
36  static void abort();
37 
38  static int setup(int ninstance = 1);
39 
40 // info about rank
41  static bool is_primary();
42 
43 #ifdef ENABLE_MULTI_INSTANCE
44  static bool is_primary_master();
45 #endif
46 
47  static int self(); //< rank within small world.
48  static int size(); //< size of small world.
49 
50 #ifdef ENABLE_MULTI_INSTANCE
51  static int self_global();
52  static int world_id();
53 #endif
54 
55 //XXX
56  static MPI_Comm& world() { return m_comm; }
57 
58 #if 0
59 // layout
60  static int ipe(const int dir); //< logical coordinate of current proc.
61  static int npe(const int dir); //< logical grid extent
62 
63  static int grid_rank(int *rank, const int *grid_coord);
64  static int grid_coord(int *grid_coord, const int rank);
65  static int grid_dims(int *grid_dims);
66 #endif
67 
68 // synchronize
69  static int sync(); //< synchronize within small world.
70 
71 #ifdef ENABLE_MULTI_INSTANCE
72  static int sync_global(); //< synchronize all processes.
73 #endif
74 
75 // info
76  static double get_time();
77 
78 // debug
79  static int status();
80 
81 // base case
82  class Base {
83  public:
84  static int reduce(int count, void *recv_buf, void *send_buf, MPI_Datatype type, MPI_Op op, int pattern);
85  static int broadcast(size_t size, void *data, int sender);
86  static int exchange(size_t size, void *recv_buf, void *send_buf, int idir, int ipm, int tag);
87 
88  static int send_1to1(size_t size, void *recv_buf, void *send_buf, int send_to, int recv_from, int tag);
89  };
90 
91 // for specific datatypes
92  static int broadcast_string(int count, string& data, int sender);
93 
94 // async communication
95  static Channel *send_init(int count, int idir, int ipm);
96  static Channel *recv_init(int count, int idir, int ipm);
97 
98  // logical and physical layout
99  class Layout;
100 
101  private:
102 
106 
108 
109 #ifdef ENABLE_MULTI_INSTANCE
110  static int m_n_instance; // number of instances
111  static int m_instance_id; // id of present instance
112 
113  static int m_global_rank;
114  static int m_global_size;
115 #endif
116 
117  static int m_grid_rank;
118  static int m_grid_size;
119 
120  static MPI_Comm m_comm;
121 };
122 #endif /* m__COMMUNICATOR_MPI_H */
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 sync()
synchronize within small world.
static int setup(int ninstance=1)
static int status()
for debug
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)
static int m_comm
instead of MPI_Comm m_comm;
static MPI_Comm & world()
retrieves current communicator.
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)