3 #include <boost/static_assert.hpp>
4 #include <boost/serialization/map.hpp>
6 #include <boost/archive/text_oarchive.hpp>
7 #include <boost/archive/text_iarchive.hpp>
13 boost::archive::text_oarchive oa(os);
19 boost::archive::text_oarchive oa(os);
26 std::istringstream is(buffer);
27 boost::archive::text_iarchive ia(is);
34 std::istringstream is(buffer);
35 boost::archive::text_iarchive ia(is);
43 MPI_Comm_rank(comm, &pid);
44 my_pid =
static_cast<size_t>(pid);
47 std::ostringstream os;
51 buf_size = os.str().length() + 1;
54 MPI_Bcast(&buf_size, 1, MPI_UNSIGNED_LONG, root, comm);
56 char *buffer =
new char[buf_size];
57 if(my_pid == root) memcpy(buffer, os.str().c_str(), buf_size);
59 MPI_Bcast(buffer, buf_size, MPI_CHAR, root, comm);
68 std::ostringstream os;
70 size_t buf_size = os.str().length() + 1;
72 MPI_Send(&buf_size, 1, MPI_UNSIGNED_LONG, pid,
75 char *buffer =
new char[buf_size];
76 memcpy(buffer, os.str().c_str(), buf_size);
78 MPI_Send(buffer, buf_size, MPI_CHAR, pid,
85 MPI_Comm comm, MPI_Request *req) {
87 std::ostringstream os;
89 size_t* buf_size =
new size_t();
90 *buf_size = os.str().length() + 1;
92 MPI_Isend(buf_size, 1, MPI_UNSIGNED_LONG, pid,
95 char *buffer =
new char[*buf_size];
96 memcpy(buffer, os.str().c_str(), *buf_size);
98 MPI_Isend(buffer, *buf_size, MPI_CHAR, pid,
101 std::pair<size_t*, char*> p(buf_size, buffer);
111 MPI_Recv(&buf_size, 1, MPI_UNSIGNED_LONG, pid,
114 char *buffer =
new char[buf_size]();
116 MPI_Recv(buffer, buf_size, MPI_CHAR, pid,
127 std::ostringstream os;
129 size_t buf_size = os.str().length() + 1;
131 MPI_Send(&buf_size, 1, MPI_UNSIGNED_LONG, pid,
134 char *buffer =
new char[buf_size];
135 memcpy(buffer, os.str().c_str(), buf_size);
137 MPI_Send(buffer, buf_size, MPI_CHAR, pid,
148 MPI_Recv(&buf_size, 1, MPI_UNSIGNED_LONG, pid,
151 char *buffer =
new char[buf_size]();
153 MPI_Recv(buffer, buf_size, MPI_CHAR, pid,
std::map< std::string, reqVarInfo_t > reqVarContainer_t
std::pair< size_t *, char * > MPI_ISend_params(Param_t params, size_t pid, MPI_Comm comm, MPI_Request *req)
#define MPI_EXCHANGE_SERIALIZED_DATA_TAG
tag for exchanging serialized data
void serialize(Param_t params, std::ostringstream &os)
serializes params using Boost archive
void MPI_Send_reqvars(reqVarContainer_t reqvars, size_t pid, MPI_Comm comm)
namedVariableCollection_t Param_t
void deserialize(char *buffer, Param_t ¶ms)
deserializes params using Boost archive
void MPI_Recv_params(Param_t ¶ms, size_t pid, MPI_Comm comm)
void MPI_Send_params(Param_t params, size_t pid, MPI_Comm comm)
void MPI_Recv_reqvars(reqVarContainer_t &reqvars, size_t pid, MPI_Comm comm)
void MPI_Bcast_params(Param_t ¶ms, size_t root, MPI_Comm comm)
broadcast params to all entities in comm