OpenM++ runtime library (libopenm)
msgExecBase.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 MSG_EXEC_BASE_H
9#define MSG_EXEC_BASE_H
10
11#include <string>
12#include <vector>
13#include <mutex>
14using namespace std;
15
16#include "msg.h"
17
18namespace openm
19{
22 {
23 public:
25 virtual ~MsgExecBase(void) noexcept { };
26
28 int worldSize(void) const;
29
31 int rank(void) const;
32
34 int groupRank(void) const;
35
37 void startSend(int i_sendTo, MsgTag i_msgTag, const type_info & i_type, size_t i_size, void * i_valueArr);
38
40 void startSendPacked(int i_sendTo, const IRowBaseVec & i_rowVec, const IPackedAdapter & i_adapter);
41
43 bool tryReceive(int i_recvFrom, MsgTag i_msgTag, const type_info & i_type, size_t i_size, void * io_valueArr) const;
44
46 bool tryReceive(int i_recvFrom, IRowBaseVec & io_resultRowVec, const IPackedAdapter & i_adapter) const;
47
49 void waitSendAll(void);
50
51 protected:
52 MsgExecBase(IFinalState * i_final) : worldCommSize(1), worldRank(0), group_rank(0), theFinal(i_final) { }
53
54 protected:
55 int worldCommSize; // total number of processes in world communicator
56 int worldRank; // rank of process in world communicator
57 int group_rank; // rank of process in group communicator
58 IFinalState * theFinal = nullptr; // final model run state interface
59
60 list<unique_ptr<IMsgSend> > sendLst; // list of active send requests
61
62 private:
63 MsgExecBase(const MsgExecBase & i_msgExec) = delete;
64 MsgExecBase & operator=(const MsgExecBase & i_msgExec) = delete;
65 };
66
68 extern recursive_mutex msgMutex;
69}
70
71#endif // MSG_EXEC_BASE_H
message passing base class
Definition: msgExecBase.h:22
void startSendPacked(int i_sendTo, const IRowBaseVec &i_rowVec, const IPackedAdapter &i_adapter)
pack and start non-blocking send of vector of db rows to i_sendTo process.
Definition: msgExecBase.cpp:74
void startSend(int i_sendTo, MsgTag i_msgTag, const type_info &i_type, size_t i_size, void *i_valueArr)
start non-blocking send of value array to i_sendTo process.
Definition: msgExecBase.cpp:46
int rank(void) const
return current process rank.
Definition: msgExecBase.cpp:24
int groupRank(void) const
return rank in modeling group.
Definition: msgExecBase.cpp:31
virtual ~MsgExecBase(void) noexcept
cleanup message passing resources.
Definition: msgExecBase.h:25
void waitSendAll(void)
wait for non-blocking send to be completed.
Definition: msgExecBase.cpp:148
bool tryReceive(int i_recvFrom, MsgTag i_msgTag, const type_info &i_type, size_t i_size, void *io_valueArr) const
try to non-blocking receive value array, return return true if completed.
Definition: msgExecBase.cpp:102
int worldSize(void) const
return total number of processes in MPI world communicator.
Definition: msgExecBase.cpp:17
OpenM++: message passing library public interface.
openM++ namespace
Definition: log.h:32
MsgTag
tag to identify message content
Definition: msg.h:29
recursive_mutex msgMutex
mutex to lock messaging operations
Definition: msgExecBase.cpp:14
std::vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:239
final model run state public interface: thread safe
Definition: omHelper.h:246
public interface to pack and unpack rows of metadata db-table
Definition: msg.h:99