21#ifndef __MPIHELPER_H__
22#define __MPIHELPER_H__
33#define MPI_WORKER_STATUSUPDATE_TAG 0x11
35#define MPI_WORKER_FINISHED_TAG 0x12
37#define MPI_WORKER_FINISHED_ACK_TAG 0x13
40#define MPI_COWORKER_NEW_JOB_TAG 0x14
44#define MPI_OPT_NEW_JOB_TAG 0x21
46#define MPI_OPT_JOB_FINISHED_TAG 0x22
48#define MPI_OPT_CONVERGED_TAG 0x23
52#define MPI_WORK_JOBID_TAG 0x41
54#define MPI_WORK_SIZE_TAG 0x42
56#define MPI_WORK_SIZE_PARAMS 0x43
58#define MPI_EXCHANGE_SOL_STATE_TAG 0x51
59#define MPI_EXCHANGE_SOL_STATE_DATA_TAG 0x52
60#define MPI_EXCHANGE_SOL_STATE_RES_SIZE_TAG 0x53
61#define MPI_EXCHANGE_SOL_STATE_RES_TAG 0x54
64#define MPI_STOP_TAG 0x91
67#define MPI_EXCHANGE_SERIALIZED_DATA_TAG 0x99
100template<
class Data_t>
103 std::ostringstream os;
105 size_t buf_size = os.str().length();
107 MPI_Send(&buf_size, 1, MPI_LONG, pid,
110 char *buffer =
new char[buf_size];
111 memcpy(buffer, os.str().c_str(), buf_size);
113 MPI_Send(buffer, buf_size, MPI_CHAR, pid,
119template<
class Data_t>
124 MPI_Recv(&buf_size, 1, MPI_LONG, pid,
127 char *buffer =
new char[buf_size];
128 MPI_Recv(buffer, buf_size, MPI_CHAR, pid,
157 MPI_Comm comm, MPI_Request *req);
void MPI_Send_reqvars(reqVarContainer_t reqvars, size_t pid, MPI_Comm comm)
#define MPI_OPT_JOB_FINISHED_TAG
pilot tells optimizer that results are ready to collect
void MPI_Bcast_params(Param_t ¶ms, size_t root, MPI_Comm comm)
broadcast params to all entities in comm
#define MPI_EXCHANGE_SOL_STATE_RES_SIZE_TAG
void MPI_Send_params(Param_t params, size_t pid, MPI_Comm comm)
void MPI_Bcast_reqvars(reqVarContainer_t reqvars, size_t root, MPI_Comm comm)
broadcast requested variables to all entities in comm
#define MPI_WORKER_FINISHED_TAG
notify pilot that work has been finished and results are ready to collect
void MPI_Recv_serialized(Data_t &data, size_t pid, MPI_Comm comm)
void MPI_Recv_reqvars(reqVarContainer_t &reqvars, size_t pid, MPI_Comm comm)
#define MPI_EXCHANGE_SOL_STATE_TAG
void serialize(Param_t params, std::ostringstream &os)
serializes params using Boost archive
#define MPI_OPT_CONVERGED_TAG
optimizer notifies pilot that optimization has converged (EXIT)
void MPI_Send_serialized(Data_t data, size_t pid, MPI_Comm comm)
#define MPI_WORKER_STATUSUPDATE_TAG
notify pilot about worker status
#define MPI_OPT_NEW_JOB_TAG
optimizer sends new job to pilot
#define MPI_EXCHANGE_SERIALIZED_DATA_TAG
tag for exchanging serialized data
@ EXCHANGE_SOL_STATE_RES_SIZE_TAG
@ WORKER_STATUSUPDATE_TAG
std::pair< size_t *, char * > MPI_ISend_params(Param_t params, size_t pid, MPI_Comm comm, MPI_Request *req)
State_t
Worker state is either idle or running.
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)
std::map< std::string, reqVarInfo_t > reqVarContainer_t
namedVariableCollection_t Param_t