Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
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  // world
56  static MPI_Comm& world() { return m_comm; }
57 
58  // synchronize
59  static int sync(); //< synchronize within small world.
60 
61 #ifdef ENABLE_MULTI_INSTANCE
62  static int sync_global(); //< synchronize all processes.
63 #endif
64 
65  // info
66  static double get_time();
67 
68  // debug
69  static int status();
70 
71  // base case
72  class Base {
73  public:
74  static int reduce(int count, void *recv_buf, void *send_buf, MPI_Datatype type, MPI_Op op, int pattern);
75  static int broadcast(size_t size, void *data, int sender);
76  static int exchange(size_t size, void *recv_buf, void *send_buf, int idir, int ipm, int tag);
77 
78  static int send_1to1(size_t size, void *recv_buf, void *send_buf, int send_to, int recv_from, int tag);
79  };
80 
81  // for specific datatypes
82  static int broadcast_string(int count, string& data, int sender);
83 
84  // async communication
85  static Channel *send_init(int count, int idir, int ipm);
86  static Channel *recv_init(int count, int idir, int ipm);
87 
88  // logical and physical layout
89  class Layout;
90 
91  private:
95 
97 
98 #ifdef ENABLE_MULTI_INSTANCE
99  static int m_n_instance; // number of instances
100  static int m_instance_id; // id of present instance
101 
102  static int m_global_rank;
103  static int m_global_size;
104 #endif
105 
106  static int m_grid_rank;
107  static int m_grid_size;
108 
109  static MPI_Comm m_comm;
110 };
111 #endif /* COMMUNICATOR_MPI_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 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)