OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Macros | Enumerations | Functions
MPIHelper.h File Reference
#include <vector>
#include <map>
#include <sstream>
#include <mpi.h>
#include "Util/Types.h"
Include dependency graph for MPIHelper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MPI_WORKER_STATUSUPDATE_TAG   0x11
 notify pilot about worker status More...
 
#define MPI_WORKER_FINISHED_TAG   0x12
 notify pilot that work has been finished and results are ready to collect More...
 
#define MPI_WORKER_FINISHED_ACK_TAG   0x13
 pilot notifies worker that he is ready to collect the results More...
 
#define MPI_COWORKER_NEW_JOB_TAG   0x14
 notifies coworkers about new jobs More...
 
#define MPI_OPT_NEW_JOB_TAG   0x21
 optimizer sends new job to pilot More...
 
#define MPI_OPT_JOB_FINISHED_TAG   0x22
 pilot tells optimizer that results are ready to collect More...
 
#define MPI_OPT_CONVERGED_TAG   0x23
 optimizer notifies pilot that optimization has converged (EXIT) More...
 
#define MPI_WORK_JOBID_TAG   0x41
 unique id of the job More...
 
#define MPI_WORK_SIZE_TAG   0x42
 tags messages containing the size of results (requested vars) More...
 
#define MPI_WORK_SIZE_PARAMS   0x43
 tags messages containing the size of the parameter list (for simulation) More...
 
#define MPI_EXCHANGE_SOL_STATE_TAG   0x51
 
#define MPI_EXCHANGE_SOL_STATE_DATA_TAG   0x52
 
#define MPI_EXCHANGE_SOL_STATE_RES_SIZE_TAG   0x53
 
#define MPI_EXCHANGE_SOL_STATE_RES_TAG   0x54
 
#define MPI_STOP_TAG   0x91
 global stop tag to exit poll loop ( More...
 
#define MPI_EXCHANGE_SERIALIZED_DATA_TAG   0x99
 tag for exchanging serialized data More...
 

Enumerations

enum  MPITag_t {
  WORKER_FINISHED_TAG = 0x12 , OPT_NEW_JOB_TAG = 0x21 , OPT_CONVERGED_TAG = 0x23 , WORKER_STATUSUPDATE_TAG = 0x11 ,
  REQUEST_FINISHED = 0x22 , EXCHANGE_SOL_STATE_TAG = 0x51 , EXCHANGE_SOL_STATE_RES_SIZE_TAG = 0x53
}
 
enum  State_t { IDLE = 0 , RUNNING = 1 }
 Worker state is either idle or running. More...
 

Functions

void serialize (Param_t params, std::ostringstream &os)
 serializes params using Boost archive More...
 
void serialize (reqVarContainer_t params, std::ostringstream &os)
 
void deserialize (char *buffer, Param_t &params)
 deserializes params using Boost archive More...
 
void deserialize (char *buffer, reqVarContainer_t &params)
 
void MPI_Bcast_params (Param_t &params, size_t root, MPI_Comm comm)
 broadcast params to all entities in comm More...
 
void MPI_Bcast_reqvars (reqVarContainer_t reqvars, size_t root, MPI_Comm comm)
 broadcast requested variables to all entities in comm More...
 
template<class Data_t >
void MPI_Send_serialized (Data_t data, size_t pid, MPI_Comm comm)
 
template<class Data_t >
void MPI_Recv_serialized (Data_t &data, size_t pid, MPI_Comm comm)
 
void MPI_Send_params (Param_t params, size_t pid, MPI_Comm comm)
 
std::pair< size_t *, char * > MPI_ISend_params (Param_t params, size_t pid, MPI_Comm comm, MPI_Request *req)
 
void MPI_Recv_params (Param_t &params, size_t pid, MPI_Comm comm)
 
void MPI_Send_reqvars (reqVarContainer_t reqvars, size_t pid, MPI_Comm comm)
 
void MPI_Recv_reqvars (reqVarContainer_t &reqvars, size_t pid, MPI_Comm comm)
 

Macro Definition Documentation

◆ MPI_COWORKER_NEW_JOB_TAG

#define MPI_COWORKER_NEW_JOB_TAG   0x14

notifies coworkers about new jobs

Definition at line 40 of file MPIHelper.h.

◆ MPI_EXCHANGE_SERIALIZED_DATA_TAG

#define MPI_EXCHANGE_SERIALIZED_DATA_TAG   0x99

tag for exchanging serialized data

Definition at line 67 of file MPIHelper.h.

◆ MPI_EXCHANGE_SOL_STATE_DATA_TAG

#define MPI_EXCHANGE_SOL_STATE_DATA_TAG   0x52

Definition at line 59 of file MPIHelper.h.

◆ MPI_EXCHANGE_SOL_STATE_RES_SIZE_TAG

#define MPI_EXCHANGE_SOL_STATE_RES_SIZE_TAG   0x53

Definition at line 60 of file MPIHelper.h.

◆ MPI_EXCHANGE_SOL_STATE_RES_TAG

#define MPI_EXCHANGE_SOL_STATE_RES_TAG   0x54

Definition at line 61 of file MPIHelper.h.

◆ MPI_EXCHANGE_SOL_STATE_TAG

#define MPI_EXCHANGE_SOL_STATE_TAG   0x51

Definition at line 58 of file MPIHelper.h.

◆ MPI_OPT_CONVERGED_TAG

#define MPI_OPT_CONVERGED_TAG   0x23

optimizer notifies pilot that optimization has converged (EXIT)

Definition at line 48 of file MPIHelper.h.

◆ MPI_OPT_JOB_FINISHED_TAG

#define MPI_OPT_JOB_FINISHED_TAG   0x22

pilot tells optimizer that results are ready to collect

Definition at line 46 of file MPIHelper.h.

◆ MPI_OPT_NEW_JOB_TAG

#define MPI_OPT_NEW_JOB_TAG   0x21

optimizer sends new job to pilot

Definition at line 44 of file MPIHelper.h.

◆ MPI_STOP_TAG

#define MPI_STOP_TAG   0x91

global stop tag to exit poll loop (

See also
Poller)

Definition at line 64 of file MPIHelper.h.

◆ MPI_WORK_JOBID_TAG

#define MPI_WORK_JOBID_TAG   0x41

unique id of the job

Definition at line 52 of file MPIHelper.h.

◆ MPI_WORK_SIZE_PARAMS

#define MPI_WORK_SIZE_PARAMS   0x43

tags messages containing the size of the parameter list (for simulation)

Definition at line 56 of file MPIHelper.h.

◆ MPI_WORK_SIZE_TAG

#define MPI_WORK_SIZE_TAG   0x42

tags messages containing the size of results (requested vars)

Definition at line 54 of file MPIHelper.h.

◆ MPI_WORKER_FINISHED_ACK_TAG

#define MPI_WORKER_FINISHED_ACK_TAG   0x13

pilot notifies worker that he is ready to collect the results

Definition at line 37 of file MPIHelper.h.

◆ MPI_WORKER_FINISHED_TAG

#define MPI_WORKER_FINISHED_TAG   0x12

notify pilot that work has been finished and results are ready to collect

Definition at line 35 of file MPIHelper.h.

◆ MPI_WORKER_STATUSUPDATE_TAG

#define MPI_WORKER_STATUSUPDATE_TAG   0x11

notify pilot about worker status

Definition at line 33 of file MPIHelper.h.

Enumeration Type Documentation

◆ MPITag_t

enum MPITag_t
Enumerator
WORKER_FINISHED_TAG 
OPT_NEW_JOB_TAG 
OPT_CONVERGED_TAG 
WORKER_STATUSUPDATE_TAG 
REQUEST_FINISHED 
EXCHANGE_SOL_STATE_TAG 
EXCHANGE_SOL_STATE_RES_SIZE_TAG 

Definition at line 71 of file MPIHelper.h.

◆ State_t

enum State_t

Worker state is either idle or running.

Enumerator
IDLE 
RUNNING 

Definition at line 82 of file MPIHelper.h.

Function Documentation

◆ deserialize() [1/2]

void deserialize ( char *  buffer,
Param_t params 
)

deserializes params using Boost archive

Definition at line 44 of file MPIHelper.cpp.

Referenced by MPI_Bcast_params(), MPI_Recv_params(), MPI_Recv_reqvars(), and MPI_Recv_serialized().

◆ deserialize() [2/2]

void deserialize ( char *  buffer,
reqVarContainer_t params 
)

Definition at line 52 of file MPIHelper.cpp.

◆ MPI_Bcast_params()

void MPI_Bcast_params ( Param_t params,
size_t  root,
MPI_Comm  comm 
)

broadcast params to all entities in comm

Definition at line 60 of file MPIHelper.cpp.

References deserialize(), and serialize().

Referenced by Worker< Sim_t >::onMessage(), SampleWorker< Sim_t >::onMessage(), Worker< Sim_t >::runCoWorker(), and SampleWorker< Sim_t >::runSlave().

Here is the call graph for this function:

◆ MPI_Bcast_reqvars()

void MPI_Bcast_reqvars ( reqVarContainer_t  reqvars,
size_t  root,
MPI_Comm  comm 
)

broadcast requested variables to all entities in comm

◆ MPI_ISend_params()

std::pair<size_t*, char*> MPI_ISend_params ( Param_t  params,
size_t  pid,
MPI_Comm  comm,
MPI_Request *  req 
)

Serializes a parameter list and asynchronously sends (MPI) to another processor. The memory associated with returned buffers must be freed by the consumer.

Parameters
paramsparameter list to serialize
pidprocessor ID to send data to
commMPI communicator group used for sending the data
reqMPI request assigned with the ISend

Definition at line 105 of file MPIHelper.cpp.

References MPI_EXCHANGE_SERIALIZED_DATA_TAG, and serialize().

Here is the call graph for this function:

◆ MPI_Recv_params()

void MPI_Recv_params ( Param_t params,
size_t  pid,
MPI_Comm  comm 
)

Receives and unpacks a parameter list from another (MPI) processor.

Parameters
paramsparameter list to store data
pidprocessor ID to receive data from
commMPI communicator group used for receiving the data

Definition at line 128 of file MPIHelper.cpp.

References deserialize(), and MPI_EXCHANGE_SERIALIZED_DATA_TAG.

Referenced by Pilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::onMessage(), Worker< Sim_t >::onMessage(), SamplePilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::onMessage(), and SampleWorker< Sim_t >::onMessage().

Here is the call graph for this function:

◆ MPI_Recv_reqvars()

void MPI_Recv_reqvars ( reqVarContainer_t reqvars,
size_t  pid,
MPI_Comm  comm 
)

Receives and unpacks a required variable list from another (MPI) processor.

Parameters
reqvarsvariable list to store data
pidprocessor ID to receive data from
commMPI communicator group used for receiving the data

Definition at line 165 of file MPIHelper.cpp.

References deserialize(), and MPI_EXCHANGE_SERIALIZED_DATA_TAG.

Referenced by Sampler::onMessage(), Pilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::onMessage(), and SamplePilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::onMessage().

Here is the call graph for this function:

◆ MPI_Recv_serialized()

template<class Data_t >
void MPI_Recv_serialized ( Data_t &  data,
size_t  pid,
MPI_Comm  comm 
)

Definition at line 120 of file MPIHelper.h.

References deserialize(), and MPI_EXCHANGE_SERIALIZED_DATA_TAG.

Here is the call graph for this function:

◆ MPI_Send_params()

void MPI_Send_params ( Param_t  params,
size_t  pid,
MPI_Comm  comm 
)

Serializes a parameter list and sends (MPI) to another processor.

Parameters
paramsparameter list to serialize
pidprocessor ID to send data to
commMPI communicator group used for sending the data

Definition at line 87 of file MPIHelper.cpp.

References MPI_EXCHANGE_SERIALIZED_DATA_TAG, and serialize().

Referenced by Sampler::dispatch_forward_solves(), Pilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::sendNewJobToWorker(), and SamplePilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::sendNewJobToWorker().

Here is the call graph for this function:

◆ MPI_Send_reqvars()

void MPI_Send_reqvars ( reqVarContainer_t  reqvars,
size_t  pid,
MPI_Comm  comm 
)

Serializes requested variable list and sends (MPI) to another processor.

Parameters
reqvarsvariable list list to serialize
pidprocessor ID to send data to
commMPI communicator group used for sending the data

Definition at line 146 of file MPIHelper.cpp.

References MPI_EXCHANGE_SERIALIZED_DATA_TAG, and serialize().

Referenced by Pilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::onMessage(), Worker< Sim_t >::onMessage(), SamplePilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >::onMessage(), and SampleWorker< Sim_t >::onMessage().

Here is the call graph for this function:

◆ MPI_Send_serialized()

template<class Data_t >
void MPI_Send_serialized ( Data_t  data,
size_t  pid,
MPI_Comm  comm 
)

Definition at line 101 of file MPIHelper.h.

References MPI_EXCHANGE_SERIALIZED_DATA_TAG, and serialize().

Here is the call graph for this function:

◆ serialize() [1/2]

void serialize ( Param_t  params,
std::ostringstream &  os 
)

◆ serialize() [2/2]

void serialize ( reqVarContainer_t  params,
std::ostringstream &  os 
)

Definition at line 38 of file MPIHelper.cpp.