OpenM++ runtime library (libopenm)
msgCommon.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_COMMON_H
9 #define MSG_COMMON_H
10 
11 #include <climits>
12 #include <cstdint>
13 #include <memory>
14 #include <mutex>
15 #include <string>
16 #include <vector>
17 using namespace std;
18 
19 #include "helper.h"
20 #include "msg.h"
21 
22 namespace openm
23 {
25  class IMsgSend
26  {
27  public:
29  virtual ~IMsgSend(void) noexcept = 0;
30 
32  virtual bool isCompleted(void) = 0;
33  };
34 
36  class IMsgSendArray : public IMsgSend
37  {
38  public:
40  virtual ~IMsgSendArray(void) noexcept = 0;
41 
52  static IMsgSendArray * create(
53  int i_selfRank, int i_sendTo, MsgTag i_msgTag, const type_info & i_type, size_t i_size, void * i_valueArr
54  );
55  };
56 
58  class IMsgSendPacked : public IMsgSend
59  {
60  public:
62  virtual ~IMsgSendPacked(void) noexcept = 0;
63 
72  static IMsgSendPacked * create(
73  int i_selfRank, int i_sendTo, const IRowBaseVec & i_rowVec, const IPackedAdapter & i_adapter
74  );
75  };
76 
78  class IMsgRecv
79  {
80  public:
82  virtual ~IMsgRecv(void) noexcept = 0;
83 
85  virtual bool tryReceive(void) = 0;
86  };
87 
89  class IMsgRecvArray : public IMsgRecv
90  {
91  public:
93  virtual ~IMsgRecvArray(void) noexcept = 0;
94 
105  static IMsgRecvArray * create(
106  int i_selfRank, int i_recvFrom, MsgTag i_msgTag, const type_info & i_type, size_t i_size, void * io_valueArr
107  );
108  };
109 
111  class IMsgRecvPacked : public IMsgRecv
112  {
113  public:
115  virtual ~IMsgRecvPacked(void) noexcept = 0;
116 
125  static IMsgRecvPacked * create(
126  int i_selfRank, int i_recvFrom, IRowBaseVec & io_resultRowVec, const IPackedAdapter & i_adapter
127  );
128  };
129 }
130 
131 // define OM_MSG_MPI to use message passing library based on MPI
132 // define OM_MSG_EMPTY to use empty version message passing library
133 // empty version does nothing but don't require MPI installed
134 
135 #ifdef OM_MSG_EMPTY
136  #include "msgEmpty.h"
137 #elif OM_MSG_MPI
138  #include <mpi.h>
139  #include "msgMpi.h"
140 #else // not defined any of OM_MSG_*
141  #error No message passing providers defined
142 #endif // OM_MSG_MPI
143 
144 #endif // MSG_COMMON_H
public interface to receive value array
Definition: msgCommon.h:90
public interface for message receiver
Definition: msgCommon.h:79
virtual bool tryReceive(void)=0
try to receive the data, return return true if received.
public interface to receive packed data
Definition: msgCommon.h:112
public interface to send value array
Definition: msgCommon.h:37
public interface for message sender
Definition: msgCommon.h:26
virtual bool isCompleted(void)=0
check is send completed.
public interface to send packed data.
Definition: msgCommon.h:59
OpenM++ common helper utilities.
OpenM++: message passing library public interface.
OpenM++: empty implementation of message passing library.
OpenM++: message passing library common classes and interfaces.
openM++ namespace
Definition: log.h:32
MsgTag
tag to identify message content
Definition: msg.h:29
std::vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:241
public interface to pack and unpack rows of metadata db-table
Definition: msg.h:99