69 const std::map<std::string, std::string> &userVariables,
70 bool isOptimizer =
true)
85 if (!isOptimizer)
return;
114 MPI_Request stop_req;
115 size_t stop_value = 0;
117 MPI_Irecv(&stop_value, 1, MPI_UNSIGNED_LONG,
leader_pid_,
128 if(stop_req != MPI_REQUEST_NULL) {
131 MPI_Test(&stop_req, &flag, &status);
146 std::cout <<
"Exception while running simulation: "
147 << ex.
what() << std::endl;
149 MPI_Irecv(&stop_value, 1, MPI_UNSIGNED_LONG,
leader_pid_,
186 MPI_Send(&dummy, 1, MPI_UNSIGNED_LONG,
pilot_rank_,
201 virtual bool onMessage(MPI_Status status,
size_t recv_value) {
206 size_t job_id = recv_value;
230 sim->collectResults();
232 requested_results = sim->getResults();
234 std::cout <<
"Exception while running simulation: "
235 << ex.
what() << std::endl;
238 MPI_Send(&job_id, 1, MPI_UNSIGNED_LONG,
pilot_rank_,
242 MPI_Recv(&dummy, 1, MPI_UNSIGNED_LONG,
pilot_rank_,
251 std::stringstream os;
252 os <<
"Unexpected MPI_TAG: " << status.MPI_TAG;
253 std::cout <<
"(Worker) Error: " << os.str() << std::endl;
#define MPI_WORK_JOBID_TAG
unique id of the job
#define MPI_WORKER_FINISHED_TAG
notify pilot that work has been finished and results are ready to collect
#define MPI_COWORKER_NEW_JOB_TAG
notifies coworkers about new jobs
#define MPI_WORKER_STATUSUPDATE_TAG
notify pilot about worker status
#define MPI_WORKER_FINISHED_ACK_TAG
pilot notifies worker that he is ready to collect the results
#define MPI_STOP_TAG
global stop tag to exit poll loop (
void MPI_Send_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
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
std::shared_ptr< CmdArguments > CmdArguments_t
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
bundles all communicators for a specific role/pid
Poller(MPI_Comm comm, double delay=0.1)
MPI_Comm comm_m
communicator the poller listens to requests
Expressions::Named_t objectives_
Worker(Expressions::Named_t objectives, Expressions::Named_t constraints, std::string simName, Comm::Bundle_t comms, CmdArguments_t args, const std::map< std::string, std::string > &userVariables, bool isOptimizer=true)
const std::unique_ptr< Sim_t > SimPtr_t
std::string simulation_name_
void postPoll()
executed after handling (if any) new request
void onStop()
enable implementation to react to STOP tag
void notifyCoWorkers(int tag)
notify coworkers of incoming broadcast
void prePoll()
executed before checking for new request
const std::map< std::string, std::string > userVariables_
void setupPoll()
executed before starting polling loop
Worker(Expressions::Named_t constraints, std::string simName, Comm::Bundle_t comms, CmdArguments_t args)
virtual bool onMessage(MPI_Status status, size_t recv_value)
Expressions::Named_t constraints_
virtual const char * what() const