1 #ifndef __SAMPLE_WORKER_H__
2 #define __SAMPLE_WORKER_H__
19 template <
class Sim_t>
29 const std::vector<std::string> &storeobjstr,
30 const std::vector<std::string> &filesToKeep)
31 :
Worker<Sim_t>(objectives, constraints, simName, comms, args, false)
60 MPI_Send(&job_id, 1, MPI_UNSIGNED_LONG, i, tag, this->
coworker_comm_);
74 MPI_Irecv(&job_id, 1, MPI_UNSIGNED_LONG, this->
leader_pid_,
85 if(stop_req != MPI_REQUEST_NULL) {
88 MPI_Test(&stop_req, &flag, &status);
101 sim->setFilename(job_id);
105 std::cout <<
"Exception while running simulation: "
108 MPI_Irecv(&job_id, 1, MPI_UNSIGNED_LONG, this->
leader_pid_,
121 bool onMessage(MPI_Status status,
size_t recv_value)
override {
126 size_t job_id = recv_value;
147 sim->setFilename(job_id);
158 sim->collectResults();
159 requested_results = sim->getResults();
170 std::cout <<
"Exception while running simulation: "
174 MPI_Send(&job_id, 1, MPI_UNSIGNED_LONG, this->pilot_rank_,
178 MPI_Recv(&dummy, 1, MPI_UNSIGNED_LONG, this->pilot_rank_,
187 std::stringstream os;
188 os <<
"Unexpected MPI_TAG: " << status.MPI_TAG;
189 std::cout <<
"(Worker) Error: " << os.str() <<
std::endl;
std::map< std::string, reqVarInfo_t > reqVarContainer_t
virtual const char * what() const
#define MPI_WORKER_FINISHED_TAG
notify pilot that work has been finished and results are ready to collect
boost::shared_ptr< CmdArguments > CmdArguments_t
#define MPI_WORKER_FINISHED_ACK_TAG
pilot notifies worker that he is ready to collect the results
const std::vector< std::string > statVariablesToStore_m
A worker MPI entity consists of a processor group that runs a simulation of type Sim_t. The main loop in run() accepts new jobs from the master process runs the simulation and reports back the results.
void MPI_Send_reqvars(reqVarContainer_t reqvars, size_t pid, MPI_Comm comm)
namedVariableCollection_t Param_t
SampleWorker(Expressions::Named_t objectives, Expressions::Named_t constraints, std::string simName, Comm::Bundle_t comms, CmdArguments_t args, const std::vector< std::string > &storeobjstr, const std::vector< std::string > &filesToKeep)
boost::scoped_ptr< Sim_t > SimPtr_t
A worker MPI entity consists of a processor group that runs a simulation of type Sim_t. The main loop in run() accepts new jobs from the master process runs the simulation and reports back the results.
#define MPI_WORK_JOBID_TAG
unique id of the job
void MPI_Recv_params(Param_t ¶ms, size_t pid, MPI_Comm comm)
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
const std::vector< std::string > filesToKeep_m
#define MPI_COWORKER_NEW_JOB_TAG
notifies coworkers about new jobs
std::string simulation_name_
void MPI_Bcast_params(Param_t ¶ms, size_t root, MPI_Comm comm)
broadcast params to all entities in comm
Expressions::Named_t objectives_
bundles all communicators for a specific role/pid
bool onMessage(MPI_Status status, size_t recv_value) override
void notifyCoWorkers(size_t job_id, int tag)
notify coworkers of incoming broadcast
MPI_Comm comm_m
communicator the poller listens to requests
Inform & endl(Inform &inf)
#define MPI_STOP_TAG
global stop tag to exit poll loop (
Expressions::Named_t constraints_