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

#include <Worker.h>

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

Public Member Functions

 Worker (Expressions::Named_t constraints, std::string simName, Comm::Bundle_t comms, CmdArguments_t args)
 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)
 ~Worker ()

Protected Types

typedef const std::unique_ptr< Sim_t > SimPtr_t

Protected Member Functions

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 bool onMessage (MPI_Status status, size_t recv_value)
virtual void run ()

Protected Attributes

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

Detailed Description

template<class Sim_t>
class Worker< Sim_t >

Definition at line 43 of file Worker.h.

Member Typedef Documentation

◆ SimPtr_t

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

Definition at line 101 of file Worker.h.

Constructor & Destructor Documentation

◆ Worker() [1/2]

template<class Sim_t>
Worker< Sim_t >::Worker ( Expressions::Named_t constraints,
std::string simName,
Comm::Bundle_t comms,
CmdArguments_t args )
inline

Definition at line 47 of file Worker.h.

References cmd_args_, constraints_, coworker_comm_, Comm::Bundle_t::coworkers, is_idle_, leader_pid_, Comm::Bundle_t::master_local_pid, num_coworkers_, pilot_rank_, Poller::Poller(), and simulation_name_.

Referenced by SampleWorker< Sim_t >::SampleWorker().

Here is the call graph for this function:

◆ Worker() [2/2]

template<class Sim_t>
Worker< Sim_t >::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 )
inline

Definition at line 64 of file Worker.h.

References cmd_args_, constraints_, coworker_comm_, Comm::Bundle_t::coworkers, is_idle_, leader_pid_, Comm::Bundle_t::master_local_pid, num_coworkers_, objectives_, pilot_rank_, Poller::Poller(), Poller::run(), runCoWorker(), simulation_name_, and userVariables_.

Here is the call graph for this function:

◆ ~Worker()

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

Definition at line 96 of file Worker.h.

Member Function Documentation

◆ notifyCoWorkers()

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

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>
virtual bool Worker< Sim_t >::onMessage ( MPI_Status status,
size_t recv_value )
inlineprotectedvirtual

User specific behavior on receiving a message.

Returns
boolean indicating if Irecv has to be re-posted

Implements Poller.

Reimplemented in SampleWorker< Sim_t >.

Definition at line 201 of file Worker.h.

References cmd_args_, Poller::comm_m, constraints_, coworker_comm_, is_idle_, leader_pid_, MPI_Bcast_params(), MPI_COWORKER_NEW_JOB_TAG, MPI_Recv_params(), MPI_Send_reqvars(), MPI_WORK_JOBID_TAG, MPI_WORKER_FINISHED_ACK_TAG, MPI_WORKER_FINISHED_TAG, notifyCoWorkers(), num_coworkers_, objectives_, pilot_rank_, simulation_name_, userVariables_, and OptPilotException::what().

Here is the call graph for this function:

◆ onStop()

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

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 ( )
inlineprotectedvirtual

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 ( )
inlineprotectedvirtual

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 ( )
inlineprotected

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:

◆ setupPoll()

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

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_
protected

◆ comm_m

MPI_Comm Poller::comm_m
protectedinherited

◆ constraints_

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

◆ coworker_comm_

◆ is_idle_

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

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_
protected

◆ objectives_

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

◆ pilot_rank_

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

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_
protected

◆ userVariables_

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

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