Pakman
MPIMaster Class Reference

#include <MPIMaster.h>

Inheritance diagram for MPIMaster:
Collaboration diagram for MPIMaster:

Public Member Functions

 MPIMaster (bool *p_program_terminated)
 
virtual ~MPIMaster () override
 
virtual bool isActive () const override
 
virtual bool needMorePendingTasks () const override
 
virtual void pushPendingTask (const std::string &input_string) override
 
virtual bool finishedTasksEmpty () const override
 
virtual TaskHandlerfrontFinishedTask () override
 
virtual void popFinishedTask () override
 
virtual void flush () override
 
virtual void terminate () override
 
- Public Member Functions inherited from AbstractMaster
 AbstractMaster (bool *p_program_terminated)
 
virtual ~AbstractMaster ()=default
 

Static Public Member Functions

static std::string help ()
 
static void addLongOptions (LongOptions &lopts)
 
static void run (controller_t controller, const Arguments &args)
 
static void cleanup ()
 
- Static Public Member Functions inherited from AbstractMaster
static master_t getMaster (const std::string &arg)
 
static std::string help (master_t master)
 
static void addLongOptions (master_t master, LongOptions &lopts)
 
static void run (master_t master, controller_t controller, const Arguments &args)
 
static void cleanup (master_t master)
 

Protected Member Functions

virtual void iterate () override
 
- Protected Member Functions inherited from AbstractMaster
void assignController (std::shared_ptr< AbstractController > p_controller)
 
bool programTerminated () const
 

Additional Inherited Members

- Protected Attributes inherited from AbstractMaster
std::weak_ptr< AbstractControllerm_p_controller
 

Detailed Description

A Master class for performing simulation tasks in parallel using MPI.

The MPIMaster class performs simulation tasks in parallel using MPI by delegating simulation tasks to a pool of Managers (as implemented by the Manager class). These Managers then perform simulation tasks by spawning child processes with fork()exec() to run simulation.

Warning
If your simulator uses MPI internally, this will likely clash with Pakman when using MPIMaster. In that case, you will need to build an MPI simulator. An example of an MPI simulator can be found on our wiki.

For instructions on how to use Pakman with the MPI master, execute the following command

$ pakman mpi --help

Definition at line 38 of file MPIMaster.h.

Constructor & Destructor Documentation

◆ MPIMaster()

MPIMaster::MPIMaster ( bool *  p_program_terminated)

Constructor saves program termination flag.

Parameters
p_program_terminatedpointer to boolean flag that is set when the execution of Pakman is terminated by the user.

Definition at line 19 of file MPIMaster.cc.

◆ ~MPIMaster()

MPIMaster::~MPIMaster ( )
overridevirtual

Default destructor does nothing.

Definition at line 36 of file MPIMaster.cc.

Member Function Documentation

◆ addLongOptions()

void MPIMaster::addLongOptions ( LongOptions lopts)
static

Add long command-line options.

Parameters
loptslong command-line options that the MPIMaster needs.

Definition at line 93 of file MPIMasterStatic.cc.

◆ cleanup()

void MPIMaster::cleanup ( )
static

Terminate all Managers, as well as the MPIWorker associated with rank 0, and terminate MPI.

This function is used when an exception occurs in run() and MPI processes need to be cleaned up appropriately so that the program does not hang after an exception.

Definition at line 226 of file MPIMasterStatic.cc.

◆ finishedTasksEmpty()

bool MPIMaster::finishedTasksEmpty ( ) const
overridevirtual
Returns
whether finished tasks queue is empty.

Implements AbstractMaster.

Definition at line 207 of file MPIMaster.cc.

◆ flush()

void MPIMaster::flush ( )
overridevirtual

Flush all finished, busy and pending tasks.

Implements AbstractMaster.

Definition at line 225 of file MPIMaster.cc.

◆ frontFinishedTask()

TaskHandler & MPIMaster::frontFinishedTask ( )
overridevirtual
Returns
reference to front finished task.

Implements AbstractMaster.

Definition at line 213 of file MPIMaster.cc.

◆ help()

std::string MPIMaster::help ( )
static
Returns
help message string.

Definition at line 29 of file MPIMasterStatic.cc.

◆ isActive()

bool MPIMaster::isActive ( ) const
overridevirtual
Returns
whether the MPIMaster is active.

Implements AbstractMaster.

Definition at line 56 of file MPIMaster.cc.

◆ iterate()

void MPIMaster::iterate ( )
overrideprotectedvirtual

Iterates the MPIMaster in an event loop.

Implements AbstractMaster.

Definition at line 62 of file MPIMaster.cc.

◆ needMorePendingTasks()

bool MPIMaster::needMorePendingTasks ( ) const
overridevirtual
Returns
whether more pending tasks are needed.

Implements AbstractMaster.

Definition at line 91 of file MPIMaster.cc.

◆ popFinishedTask()

void MPIMaster::popFinishedTask ( )
overridevirtual

Pop front finished task.

Implements AbstractMaster.

Definition at line 219 of file MPIMaster.cc.

◆ pushPendingTask()

void MPIMaster::pushPendingTask ( const std::string &  input_string)
overridevirtual

Push a new pending task.

Parameters
input_stringinput string to simulation job.

Implements AbstractMaster.

Definition at line 201 of file MPIMaster.cc.

◆ run()

void MPIMaster::run ( controller_t  controller,
const Arguments args 
)
static

Run MPIMaster in an event loop.

This function creates the MPIMaster and Controller objects, and runs them in an event loop.

Parameters
controllercontroller type.
argscommand-line arguments.

Definition at line 103 of file MPIMasterStatic.cc.

◆ terminate()

void MPIMaster::terminate ( )
overridevirtual

Terminate MPIMaster.

Implements AbstractMaster.

Definition at line 234 of file MPIMaster.cc.


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