OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
SampleWorker< Sim_t > Class Template Reference

#include <SampleWorker.h>

Inheritance diagram for SampleWorker< Sim_t >:
Collaboration diagram for SampleWorker< Sim_t >:

Public Member Functions

 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, const std::map< std::string, std::string > &userVariables)
 ~SampleWorker ()

Protected Types

typedef const std::unique_ptr< Sim_t > SimPtr_t

Protected Member Functions

void notifyCoWorkers (size_t job_id, int tag)
 notify coworkers of incoming broadcast
void runSlave ()
bool onMessage (MPI_Status status, size_t recv_value) override
void runCoWorker ()
void notifyCoWorkers (int tag)
 notify coworkers of incoming broadcast
void setupPoll ()
 executed before starting polling loop
void prePoll ()
 executed before checking for new request
void postPoll ()
 executed after handling (if any) new request
void onStop ()
 enable implementation to react to STOP tag
virtual void run ()

Protected Attributes

const std::vector< std::string > statVariablesToStore_m
bool is_idle_
MPI_Comm coworker_comm_
Expressions::Named_t objectives_
Expressions::Named_t constraints_
int leader_pid_
int num_coworkers_
int pilot_rank_
std::string simulation_name_
CmdArguments_t cmd_args_
const std::map< std::string, std::string > userVariables_
MPI_Comm comm_m
 communicator the poller listens to requests
bool is_running_
double last_polled_
 time of last MPI_Test
double poll_delay_
 delay in seconds between polls

Private Attributes

const std::vector< std::string > filesToKeep_m

Detailed Description

template<class Sim_t>
class SampleWorker< Sim_t >

Definition at line 36 of file SampleWorker.h.

Member Typedef Documentation

◆ SimPtr_t

template<class Sim_t>
typedef const std::unique_ptr<Sim_t> Worker< Sim_t >::SimPtr_t
protectedinherited

Definition at line 101 of file Worker.h.

Constructor & Destructor Documentation

◆ SampleWorker()

template<class Sim_t>
SampleWorker< Sim_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,
const std::map< std::string, std::string > & userVariables )
inline

Definition at line 40 of file SampleWorker.h.

References Worker< Sim_t >::coworker_comm_, filesToKeep_m, Worker< Sim_t >::leader_pid_, Poller::run(), runSlave(), statVariablesToStore_m, and Worker< Sim_t >::Worker().

Here is the call graph for this function:

◆ ~SampleWorker()

template<class Sim_t>
SampleWorker< Sim_t >::~SampleWorker ( )
inline

Definition at line 63 of file SampleWorker.h.

Member Function Documentation

◆ notifyCoWorkers() [1/2]

template<class Sim_t>
void SampleWorker< Sim_t >::notifyCoWorkers ( size_t job_id,
int tag )
inlineprotected

notify coworkers of incoming broadcast

Definition at line 71 of file SampleWorker.h.

References Worker< Sim_t >::coworker_comm_, Worker< Sim_t >::leader_pid_, and Worker< Sim_t >::num_coworkers_.

Referenced by onMessage().

◆ notifyCoWorkers() [2/2]

template<class Sim_t>
void Worker< Sim_t >::notifyCoWorkers ( int tag)
inlineprotectedinherited

notify coworkers of incoming broadcast

Definition at line 174 of file Worker.h.

References coworker_comm_, leader_pid_, and num_coworkers_.

Referenced by onMessage(), and onStop().

◆ onMessage()

template<class Sim_t>
bool SampleWorker< Sim_t >::onMessage ( MPI_Status status,
size_t recv_value )
inlineoverrideprotectedvirtual

◆ onStop()

template<class Sim_t>
void Worker< Sim_t >::onStop ( )
inlineprotectedvirtualinherited

enable implementation to react to STOP tag

Implements Poller.

Definition at line 196 of file Worker.h.

References MPI_STOP_TAG, notifyCoWorkers(), and num_coworkers_.

Here is the call graph for this function:

◆ postPoll()

template<class Sim_t>
void Worker< Sim_t >::postPoll ( )
inlineprotectedvirtualinherited

executed after handling (if any) new request

Implements Poller.

Definition at line 193 of file Worker.h.

◆ prePoll()

template<class Sim_t>
void Worker< Sim_t >::prePoll ( )
inlineprotectedvirtualinherited

executed before checking for new request

Implements Poller.

Definition at line 190 of file Worker.h.

◆ run()

virtual void Poller::run ( )
inlineprotectedvirtualinherited

The poll loop stops when receiving a 'MPI_STOP_TAG' otherwise passes message to user.

Reimplemented in Pilot< Opt_t, Sim_t, SolPropagationGraph_t, Comm_t >.

Definition at line 79 of file Poller.h.

References comm_m, is_running_, last_polled_, MPI_STOP_TAG, onMessage(), onStop(), poll_delay_, postPoll(), prePoll(), and setupPoll().

Referenced by Sampler::initialize(), SampleWorker< Sim_t >::SampleWorker(), and Worker< Sim_t >::Worker().

Here is the call graph for this function:

◆ runCoWorker()

template<class Sim_t>
void Worker< Sim_t >::runCoWorker ( )
inlineprotectedinherited

coworkers simply wait on a job broadcast from the leader and then start a simulation..

Definition at line 112 of file Worker.h.

References cmd_args_, constraints_, coworker_comm_, Poller::is_running_, leader_pid_, MPI_Bcast_params(), MPI_COWORKER_NEW_JOB_TAG, MPI_STOP_TAG, objectives_, simulation_name_, userVariables_, and OptPilotException::what().

Referenced by Worker().

Here is the call graph for this function:

◆ runSlave()

template<class Sim_t>
void SampleWorker< Sim_t >::runSlave ( )
inlineprotected

coworkers simply wait on a job broadcast from the leader and then start a simulation..

Definition at line 83 of file SampleWorker.h.

References Worker< Sim_t >::cmd_args_, Worker< Sim_t >::constraints_, Worker< Sim_t >::coworker_comm_, Poller::is_running_, Worker< Sim_t >::leader_pid_, MPI_Bcast_params(), MPI_COWORKER_NEW_JOB_TAG, MPI_STOP_TAG, Worker< Sim_t >::objectives_, Worker< Sim_t >::simulation_name_, Worker< Sim_t >::userVariables_, and OptPilotException::what().

Referenced by SampleWorker().

Here is the call graph for this function:

◆ setupPoll()

template<class Sim_t>
void Worker< Sim_t >::setupPoll ( )
inlineprotectedvirtualinherited

executed before starting polling loop

Implements Poller.

Definition at line 184 of file Worker.h.

References Poller::comm_m, MPI_WORKER_STATUSUPDATE_TAG, and pilot_rank_.

Member Data Documentation

◆ cmd_args_

template<class Sim_t>
CmdArguments_t Worker< Sim_t >::cmd_args_
protectedinherited

◆ comm_m

MPI_Comm Poller::comm_m
protectedinherited

◆ constraints_

template<class Sim_t>
Expressions::Named_t Worker< Sim_t >::constraints_
protectedinherited

◆ coworker_comm_

◆ filesToKeep_m

template<class Sim_t>
const std::vector<std::string> SampleWorker< Sim_t >::filesToKeep_m
private

Definition at line 214 of file SampleWorker.h.

Referenced by onMessage(), and SampleWorker().

◆ is_idle_

template<class Sim_t>
bool Worker< Sim_t >::is_idle_
protectedinherited

Definition at line 103 of file Worker.h.

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

◆ is_running_

bool Poller::is_running_
protectedinherited

◆ last_polled_

double Poller::last_polled_
protectedinherited

time of last MPI_Test

Definition at line 57 of file Poller.h.

Referenced by Poller(), and run().

◆ leader_pid_

◆ num_coworkers_

template<class Sim_t>
int Worker< Sim_t >::num_coworkers_
protectedinherited

◆ objectives_

template<class Sim_t>
Expressions::Named_t Worker< Sim_t >::objectives_
protectedinherited

◆ pilot_rank_

template<class Sim_t>
int Worker< Sim_t >::pilot_rank_
protectedinherited

Definition at line 167 of file Worker.h.

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

◆ poll_delay_

double Poller::poll_delay_
protectedinherited

delay in seconds between polls

Definition at line 59 of file Poller.h.

Referenced by Poller(), and run().

◆ simulation_name_

template<class Sim_t>
std::string Worker< Sim_t >::simulation_name_
protectedinherited

◆ statVariablesToStore_m

template<class Sim_t>
const std::vector<std::string> SampleWorker< Sim_t >::statVariablesToStore_m
protected

Definition at line 68 of file SampleWorker.h.

Referenced by SampleWorker().

◆ userVariables_

template<class Sim_t>
const std::map<std::string, std::string> Worker< Sim_t >::userVariables_
protectedinherited

The documentation for this class was generated from the following file: