OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Worker< Sim_t > Class Template Reference

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. More...

#include <Worker.h>

Inheritance diagram for Worker< Sim_t >:
Inheritance graph
[legend]
Collaboration diagram for Worker< Sim_t >:
Collaboration graph
[legend]

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, bool isOptimizer=true)
 
 ~Worker ()
 

Protected Types

typedef boost::scoped_ptr< Sim_t > SimPtr_t
 

Protected Member Functions

void runCoWorker ()
 
void notifyCoWorkers (int tag)
 notify coworkers of incoming broadcast More...
 
void setupPoll ()
 executed before starting polling loop More...
 
void prePoll ()
 executed before checking for new request More...
 
void postPoll ()
 executed after handling (if any) new request More...
 
void onStop ()
 enable implementation to react to STOP tag More...
 
virtual bool onMessage (MPI_Status status, size_t recv_value)
 
- Protected Member Functions inherited from Poller
virtual void run ()
 
 Poller (MPI_Comm comm, double delay=0.1)
 
virtual ~Poller ()
 

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_
 
- Protected Attributes inherited from Poller
MPI_Comm comm_m
 communicator the poller listens to requests More...
 
bool is_running_
 
double last_polled_
 time of last MPI_Test More...
 
double poll_delay_
 delay in seconds between polls More...
 

Detailed Description

template<class Sim_t>
class Worker< Sim_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.

See Also
Pilot
Poller
MPIHelper.h
Template Parameters
Sim_Ttype of simulation to run

Definition at line 28 of file Worker.h.

Member Typedef Documentation

template<class Sim_t>
typedef boost::scoped_ptr<Sim_t> Worker< Sim_t >::SimPtr_t
protected

Definition at line 84 of file Worker.h.

Constructor & Destructor Documentation

template<class Sim_t>
Worker< Sim_t >::Worker ( Expressions::Named_t  constraints,
std::string  simName,
Comm::Bundle_t  comms,
CmdArguments_t  args 
)
inline
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,
bool  isOptimizer = true 
)
inline
template<class Sim_t>
Worker< Sim_t >::~Worker ( )
inline

Definition at line 79 of file Worker.h.

Member Function Documentation

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

notify coworkers of incoming broadcast

Definition at line 155 of file Worker.h.

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

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

template<class Sim_t>
virtual bool Worker< Sim_t >::onMessage ( MPI_Status  status,
size_t  recv_value 
)
inlineprotectedvirtual
template<class Sim_t>
void Worker< Sim_t >::onStop ( )
inlineprotectedvirtual

enable implementation to react to STOP tag

Implements Poller.

Definition at line 177 of file Worker.h.

References MPI_STOP_TAG, Worker< Sim_t >::notifyCoWorkers(), and Worker< Sim_t >::num_coworkers_.

Here is the call graph for this function:

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

executed after handling (if any) new request

Implements Poller.

Definition at line 174 of file Worker.h.

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

executed before checking for new request

Implements Poller.

Definition at line 171 of file Worker.h.

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 95 of file Worker.h.

References Worker< Sim_t >::cmd_args_, Worker< Sim_t >::constraints_, Worker< Sim_t >::coworker_comm_, endl(), 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_, and OptPilotException::what().

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

Here is the call graph for this function:

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

executed before starting polling loop

Implements Poller.

Definition at line 165 of file Worker.h.

References Poller::comm_m, MPI_WORKER_STATUSUPDATE_TAG, and Worker< Sim_t >::pilot_rank_.

Member Data Documentation

template<class Sim_t>
CmdArguments_t Worker< Sim_t >::cmd_args_
protected
template<class Sim_t>
Expressions::Named_t Worker< Sim_t >::constraints_
protected
template<class Sim_t>
MPI_Comm Worker< Sim_t >::coworker_comm_
protected
template<class Sim_t>
bool Worker< Sim_t >::is_idle_
protected
template<class Sim_t>
int Worker< Sim_t >::leader_pid_
protected
template<class Sim_t>
int Worker< Sim_t >::num_coworkers_
protected
template<class Sim_t>
Expressions::Named_t Worker< Sim_t >::objectives_
protected
template<class Sim_t>
int Worker< Sim_t >::pilot_rank_
protected
template<class Sim_t>
std::string Worker< Sim_t >::simulation_name_
protected

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