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>
17using namespace std;
18
19#include "helper.h"
20#include "msg.h"
21
22namespace openm
23{
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
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
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
static IMsgRecvArray * create(int i_selfRank, int i_recvFrom, MsgTag i_msgTag, const type_info &i_type, size_t i_size, void *io_valueArr)
create new receiver for value array.
Definition: msgCommon.cpp:68
virtual ~IMsgRecvArray(void) noexcept=0
cleanup value array receiver resources.
Definition: msgCommon.cpp:23
public interface for message receiver
Definition: msgCommon.h:79
virtual bool tryReceive(void)=0
try to receive the data, return return true if received.
virtual ~IMsgRecv(void) noexcept=0
cleanup message receiver resources.
Definition: msgCommon.cpp:22
public interface to receive packed data
Definition: msgCommon.h:112
static IMsgRecvPacked * create(int i_selfRank, int i_recvFrom, IRowBaseVec &io_resultRowVec, const IPackedAdapter &i_adapter)
create new receiver for packed data.
Definition: msgCommon.cpp:77
virtual ~IMsgRecvPacked(void) noexcept=0
cleanup message receiver resources.
Definition: msgCommon.cpp:24
public interface to send value array
Definition: msgCommon.h:37
virtual ~IMsgSendArray(void) noexcept=0
cleanup message sender resources.
Definition: msgCommon.cpp:18
static IMsgSendArray * create(int i_selfRank, int i_sendTo, MsgTag i_msgTag, const type_info &i_type, size_t i_size, void *i_valueArr)
create new value array sender.
Definition: msgCommon.cpp:50
public interface for message sender
Definition: msgCommon.h:26
virtual ~IMsgSend(void) noexcept=0
cleanup message sender resources.
Definition: msgCommon.cpp:17
virtual bool isCompleted(void)=0
check is send completed.
public interface to send packed data.
Definition: msgCommon.h:59
virtual ~IMsgSendPacked(void) noexcept=0
cleanup message sender resources.
Definition: msgCommon.cpp:19
static IMsgSendPacked * create(int i_selfRank, int i_sendTo, const IRowBaseVec &i_rowVec, const IPackedAdapter &i_adapter)
create new sender for packed data.
Definition: msgCommon.cpp: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:239
public interface to pack and unpack rows of metadata db-table
Definition: msg.h:99