OpenM++ runtime library (libopenm)
msg.h
Go to the documentation of this file.
1 
5 // Copyright (c) 2013-2015 OpenM++
6 // This code is licensed under the MIT license (see LICENSE.txt for details)
7 
8 #ifndef OM_MSG_H
9 #define OM_MSG_H
10 
11 #include <string>
12 using namespace std;
13 
14 #include "libopenm/omLog.h"
17 #include "libopenm/db/dbCommon.h"
18 
19 namespace openm
20 {
22  extern const char msgUnknownErrorMessage[];
23 
26 
28  enum class MsgTag
29  {
31  unused = 0,
32 
35 
37  initial,
38 
40  langLst = 32,
41 
43  langWord,
44 
46  modelDic,
47 
49  typeDic,
50 
53 
56 
59 
61  tableDic,
62 
64  tableDims,
65 
67  tableAcc,
68 
70  tableExpr,
71 
73  groupLst,
74 
76  groupPc,
77 
79  runOption,
80 
82  codeValue,
83 
85  //inParam,
86 
88  outSubValueBase = 128
89  };
90 
93  {
94  public:
95  virtual ~IPackedAdapter(void) noexcept { }
96 
102  static IPackedAdapter * create(MsgTag i_msgTag);
103 
105  virtual MsgTag tag(void) const noexcept = 0;
106 
112  virtual const vector<char> pack(const IRowBaseVec & i_rowVec) const = 0;
113 
121  virtual void unpackTo(int i_packSize, void * i_packedData, IRowBaseVec & io_rowVec) const = 0;
122 
124  static size_t packedSize(const type_info & i_type, size_t i_size);
125 
127  static unique_ptr<char> packArray(const type_info & i_type, size_t i_size, void * i_valueArr);
128  };
129 
131  class IMsgExec
132  {
133  public:
135  virtual ~IMsgExec(void) noexcept = 0;
136 
144  static IMsgExec * create(int argc, char **argv, IFinalState * i_final);
145 
147  static const int rootRank = 0;
148 
150  bool isRoot(void) const { return rank() == rootRank; }
151 
153  virtual int worldSize(void) const = 0;
154 
156  virtual int rank(void) const = 0;
157 
159  virtual int groupRank(void) const = 0;
160 
162  virtual void setCleanExit(bool i_isClean = false) = 0;
163 
169  virtual void createGroups(int i_groupSize, int i_groupCount) = 0;
170 
178  virtual void bcastValue(int i_groupOne, const type_info & i_type, void * io_value) = 0;
179 
186  void bcastInt(int i_groupOne, void * io_value) { bcastValue(i_groupOne, typeid(int), io_value); }
187 
195  virtual void bcastSend(int i_groupOne, const type_info & i_type, size_t i_size, void * io_valueArr) = 0;
196 
205  virtual void bcastReceive(int i_groupOne, const type_info & i_type, size_t i_size, void * io_valueArr) = 0;
206 
207 
214  virtual void bcastSendPacked(int i_groupOne, IRowBaseVec & io_rowVec, const IPackedAdapter & i_adapter) = 0;
215 
222  virtual void bcastReceivePacked(int i_groupOne, IRowBaseVec & io_rowVec, const IPackedAdapter & i_adapter) = 0;
223 
233  virtual void startSend(int i_sendTo, MsgTag i_msgTag, const type_info & i_type, size_t i_size, void * i_valueArr) = 0;
234 
242  virtual void startSendPacked(int i_sendTo, const IRowBaseVec & i_rowVec, const IPackedAdapter & i_adapter) = 0;
243 
253  virtual bool tryReceive(int i_recvFrom, MsgTag i_msgTag, const type_info & i_type, size_t i_size, void * io_valueArr) const = 0;
254 
262  virtual bool tryReceive(int i_recvFrom, IRowBaseVec & io_resultRowVec, const IPackedAdapter & i_adapter) const = 0;
263 
265  virtual void waitSendAll(void) = 0;
266  };
267 }
268 
269 #endif // OM_MSG_H
type_dic db rows
public interface to pack and unpack rows of metadata db-table
Definition: msg.h:92
initial message at process start
final model run state public interface: thread safe
Definition: omHelper.h:196
parameter_dic db rows
OpenM++: public interface for log and trace support.
table_acc db rows
const char msgUnknownErrorMessage[]
messaging library default error message: "unknown messaging error"
Definition: msgCommon.cpp:11
model_dic db rows
group_lst db rows
OpenmException< 4000, msgUnknownErrorMessage > MsgException
messaging library exception
Definition: msg.h:25
table_expr db rows
table_dims db rows
type_enum_lst db rows
lang_word db rows
group_pc db rows
modeling job status
openM++ namespace
Definition: argReader.cpp:16
bool isRoot(void) const
if root process then true (root process rank == 0)
Definition: msg.h:150
table_dic db rows
parameter_dims db rows
MsgTag
tag to identify message content
Definition: msg.h:28
OpenM++ modeling library: model run state public interface.
vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:190
reserved and should not be used
lang_lst db rows
OpenM++ data library: public interface for db common structures.
generic (code,value) db rows
void bcastInt(int i_groupOne, void *io_value)
broadcast integer value from root to all other processes.
Definition: msg.h:186
openM++ exceptions
Definition: omError.h:19
OpenM++ common helper utilities.
run_option db rows
public interface for message passing
Definition: msg.h:131