NEML2 2.0.0
Loading...
Searching...
No Matches
SimpleMPIScheduler Class Reference

A simple MPI scheduler. More...

Detailed Description

A simple MPI scheduler.

Each rank dispatches to a single device, selected based on its processor ID.

It dispataches a fixed batch size, up to (optionally) the provided capacity. The default capacity is the batch size.

The number of devices in the list must be greater than or equal to local communicator size.

The list must not include the cpu.

#include <SimpleMPIScheduler.h>

Inheritance diagram for SimpleMPIScheduler:

Public Member Functions

 SimpleMPIScheduler (const OptionSet &options)
 Construct a new WorkScheduler object.
 
void setup () override
 Check the device list and coordinate this rank's device.
 
std::vector< Devicedevices () const override
 Device options.
 
virtual TIMPI::Communicator & comm ()
 
virtual void set_comm (TIMPI::Communicator comm)
 
- Public Member Functions inherited from WorkScheduler
 WorkScheduler (const OptionSet &options)
 Construct a new WorkScheduler object.
 
void schedule_work (Device &, std::size_t &)
 Determine the device and batch size for the next dispatch.
 
void dispatched_work (Device, std::size_t)
 Update the scheduler with the dispatch of the last batch.
 
void completed_work (Device, std::size_t)
 Update the scheduler with the completion of the last batch.
 
void wait_for_completion ()
 Wait for all work to complete.
 
- Public Member Functions inherited from NEML2Object
 NEML2Object ()=delete
 
 NEML2Object (NEML2Object &&)=delete
 
 NEML2Object (const NEML2Object &)=delete
 
NEML2Objectoperator= (NEML2Object &&)=delete
 
NEML2Objectoperator= (const NEML2Object &)=delete
 
virtual ~NEML2Object ()=default
 
 NEML2Object (const OptionSet &options)
 Construct a new NEML2Object object.
 
const OptionSetinput_options () const
 
const std::string & name () const
 A readonly reference to the object's name.
 
const std::string & type () const
 A readonly reference to the object's type.
 
const std::string & path () const
 A readonly reference to the object's path.
 
const std::string & doc () const
 A readonly reference to the object's docstring.
 
Factoryfactory () const
 Get the factory that created this object.
 
const Settingssettings () const
 Settings.
 
template<typename T = NEML2Object>
const T * host () const
 Get a readonly pointer to the host.
 
template<typename T = NEML2Object>
T * host ()
 Get a writable pointer to the host.
 
template<typename T >
const T & resolve_tensor (const std::string &name)
 Resolve a TensorName to a Tensor.
 
template<class T >
std::shared_ptr< T > get_object (const std::string &section, const std::string &name)
 
template<class T = Solver>
std::shared_ptr< T > get_solver (const std::string &name)
 Get a solver from the factory.
 
template<class T = Data>
std::shared_ptr< T > get_data (const std::string &name)
 Get a data from the factory.
 
template<class T = Model>
std::shared_ptr< T > get_model (const std::string &name)
 Get a model from the factory.
 
template<class T = Driver>
std::shared_ptr< T > get_driver (const std::string &name)
 Get a driver from the factory.
 
template<class T = WorkScheduler>
std::shared_ptr< T > get_scheduler (const std::string &name)
 Get a scheduler from the factory.
 
- Public Member Functions inherited from TracingInterface
 TracingInterface (std::string)
 
 TracingInterface (const OptionSet &)
 
virtual ~TracingInterface ()=default
 
 TracingInterface (const TracingInterface &)=default
 
 TracingInterface (TracingInterface &&)=default
 
TracingInterfaceoperator= (const TracingInterface &)=delete
 
TracingInterfaceoperator= (TracingInterface &&)=delete
 
bool event_tracing_enabled () const
 
TraceWriterevent_trace_writer () const
 Get the event trace writer.
 

Static Public Member Functions

static OptionSet expected_options ()
 Options for the scheduler.
 
- Static Public Member Functions inherited from WorkScheduler
static OptionSet expected_options ()
 Options for the scheduler.
 
- Static Public Member Functions inherited from NEML2Object
static OptionSet expected_options ()
 
- Static Public Member Functions inherited from TracingInterface
static OptionSet expected_options ()
 

Protected Member Functions

bool schedule_work_impl (Device &, std::size_t &) const override
 Implementation of the work scheduling.
 
void dispatched_work_impl (Device, std::size_t) override
 Update the scheduler with the dispatch of the last batch.
 
void completed_work_impl (Device, std::size_t) override
 Update the scheduler with the completion of the last batch.
 
bool all_work_completed () const override
 Check if all work has been completed.
 
- Protected Member Functions inherited from WorkScheduler

Additional Inherited Members

- Protected Attributes inherited from WorkScheduler
std::condition_variable _condition
 Condition variable for the scheduling thread.
 

Constructor & Destructor Documentation

◆ SimpleMPIScheduler()

SimpleMPIScheduler ( const OptionSet & options)

Construct a new WorkScheduler object.

Parameters
optionsOptions for the scheduler

Member Function Documentation

◆ all_work_completed()

bool all_work_completed ( ) const
overrideprotectedvirtual

Check if all work has been completed.

Implements WorkScheduler.

◆ comm()

virtual TIMPI::Communicator & comm ( )
inlinevirtual

◆ completed_work_impl()

void completed_work_impl ( Device ,
std::size_t  )
overrideprotectedvirtual

Update the scheduler with the completion of the last batch.

Implements WorkScheduler.

◆ devices()

std::vector< Device > devices ( ) const
inlineoverridevirtual

Device options.

Reimplemented from WorkScheduler.

◆ dispatched_work_impl()

void dispatched_work_impl ( Device ,
std::size_t  )
overrideprotectedvirtual

Update the scheduler with the dispatch of the last batch.

Implements WorkScheduler.

◆ expected_options()

OptionSet expected_options ( )
static

Options for the scheduler.

◆ schedule_work_impl()

bool schedule_work_impl ( Device & ,
std::size_t &  ) const
overrideprotectedvirtual

Implementation of the work scheduling.

Implements WorkScheduler.

◆ set_comm()

virtual void set_comm ( TIMPI::Communicator comm)
inlinevirtual

◆ setup()

void setup ( )
overridevirtual

Check the device list and coordinate this rank's device.

Reimplemented from NEML2Object.