8#ifndef MSG_MPI_PACKED_H
9#define MSG_MPI_PACKED_H
30 template<
typename TVal>
31 static void pack(TVal i_value,
int i_packedSize,
void * io_packedData,
int & io_packPos)
33 int mpiRet = MPI_Pack(&i_value, 1,
toMpiType(
typeid(TVal)), io_packedData, i_packedSize, &io_packPos, MPI_COMM_WORLD);
45 template<
typename TVal>
46 static TVal
unpack(
int i_packedSize,
void * i_packedData,
int & io_packPos)
49 int mpiRet = MPI_Unpack(i_packedData, i_packedSize, &io_packPos, &val, 1,
toMpiType(
typeid(TVal)), MPI_COMM_WORLD);
56 static void pack(
const string & i_value,
int i_packedSize,
void * io_packedData,
int & io_packPos);
59 static string unpackStr(
int i_packedSize,
void * i_packedData,
int & io_packPos);
62 static unique_ptr<uint8_t[]>
packArray(
const type_info & i_type,
size_t i_size,
void * i_valueArr);
65 static unique_ptr<uint8_t[]>
packArray(
size_t i_size,
const string * i_valueArr);
68 static void unpackArray(
int i_packedSize,
void * i_packedData,
size_t i_size,
string * io_valueArr);
71 static int packedSize(
const type_info & i_type,
size_t i_size);
74 static int packedSize(
size_t i_size,
const string * i_valueArr);
77 static int packedSize(
const type_info & i_type);
83 static MPI_Datatype
toMpiType(
const type_info & i_type);
101 static void pack(
const IRowBaseUptr & i_row,
int i_packedSize,
void * io_packedData,
int & io_packPos);
131 MsgTag tag(
void)
const noexcept override {
return rowMsgTag; }
140 lock_guard<recursive_mutex> lck(
msgMutex);
142 int packSize = packedSize(i_rowVec);
143 vector<uint8_t> packedData(packSize);
146 int rowCount = (int)i_rowVec.size();
147 MpiPacked::pack<int>(rowCount, packSize, packedData.data(), packPos);
149 for (IRowBaseVec::const_iterator rowIt = i_rowVec.begin(); rowIt != i_rowVec.end(); rowIt++) {
164 lock_guard<recursive_mutex> lck(
msgMutex);
167 int rowCount = MpiPacked::unpack<int>(i_packSize, i_packedData, packPos);
169 for (
int nRow = 0; nRow < rowCount; nRow++) {
172 io_rowVec.push_back(std::move(row));
186 for (IRowBaseVec::const_iterator rowIt = i_rowVec.begin(); rowIt != i_rowVec.end(); rowIt++) {
messaging library MPI exception
Definition: msgMpi.h:19
wrapper class around of MPI_Pack and MPI_Unpack
Definition: msgMpiPacked.h:19
static void pack(TVal i_value, int i_packedSize, void *io_packedData, int &io_packPos)
MPI_Pack value of primitive type into data buffer at i_packPos position.
Definition: msgMpiPacked.h:31
static void unpackArray(int i_packedSize, void *i_packedData, size_t i_size, string *io_valueArr)
unpack MPI_Pack'ed string array from i_packedData into supplied io_valueArr.
Definition: msgMpiPacked.cpp:128
static int packedSize(const type_info &i_type, size_t i_size)
return MPI pack size for array of specified primitive type values.
Definition: msgMpiPacked.cpp:151
static unique_ptr< uint8_t[]> packArray(const type_info &i_type, size_t i_size, void *i_valueArr)
return an MPI_Pack'ed copy of source array.
Definition: msgMpiPacked.cpp:75
static MPI_Datatype toMpiType(const type_info &i_type)
return MPI type corresponding to source primitive type.
Definition: msgMpiPacked.cpp:218
static string unpackStr(int i_packedSize, void *i_packedData, int &io_packPos)
MPI_Unpack string from data buffer at i_packPos position and return the string.
Definition: msgMpiPacked.cpp:48
static TVal unpack(int i_packedSize, void *i_packedData, int &io_packPos)
MPI_Unpack value of primitive type from data buffer at i_packPos position and return the value.
Definition: msgMpiPacked.h:46
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::unique_ptr< IRowBase > IRowBaseUptr
unique pointer to db row
Definition: omHelper.h:236
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
public interface to pack and unpack rows of metadata db-table
Definition: msg.h:99
MPI-based adapter to pack and unpack metadata db row.
Definition: msgMpiPacked.h:91
static void pack(const IRowBaseUptr &i_row, int i_packedSize, void *io_packedData, int &io_packPos)
pack db row into MPI message.
static void unpackTo(const IRowBaseUptr &io_row, int i_packedSize, void *i_packedData, int &io_packPos)
unpack MPI message into db row.
static int packedSize(const IRowBaseUptr &i_row)
return byte size to pack db row into MPI message.