ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Communication::MpiCallbacks Class Reference

The interface of the MPI callback mechanism. More...

#include <MpiCallbacks.hpp>

Classes

class  CallbackHandle
 RAII handle for a callback. More...
 

Public Member Functions

 MpiCallbacks (MpiCallbacks const &)=delete
 
MpiCallbacksoperator= (MpiCallbacks const &)=delete
 
 MpiCallbacks (boost::mpi::communicator comm, std::shared_ptr< boost::mpi::environment > mpi_env)
 
 ~MpiCallbacks ()
 
template<class... Args>
void add (void(*fp)(Args...))
 Add a new callback.
 
template<class... Args, class... ArgRef>
auto call (void(*fp)(Args...), ArgRef &&...args) const -> std::enable_if_t< std::is_void_v< decltype(fp(args...))> >
 Call a callback on worker nodes.
 
template<class... Args, class... ArgRef>
auto call_all (void(*fp)(Args...), ArgRef &&...args) const -> std::enable_if_t< std::is_void_v< decltype(fp(args...))> >
 Call a callback on all nodes.
 
void loop () const
 Start the MPI loop.
 
void abort_loop ()
 Abort the MPI loop.
 
boost::mpi::communicator const & comm () const
 The boost mpi communicator used by this instance.
 
std::shared_ptr< boost::mpi::environment > share_mpi_env () const
 

Static Public Member Functions

template<class... Args>
static void add_static (void(*fp)(Args...))
 Add a new callback.
 

Detailed Description

The interface of the MPI callback mechanism.

Definition at line 187 of file MpiCallbacks.hpp.

Constructor & Destructor Documentation

◆ MpiCallbacks() [1/2]

Communication::MpiCallbacks::MpiCallbacks ( MpiCallbacks const &  )
delete

◆ MpiCallbacks() [2/2]

Communication::MpiCallbacks::MpiCallbacks ( boost::mpi::communicator  comm,
std::shared_ptr< boost::mpi::environment >  mpi_env 
)
inline

Definition at line 258 of file MpiCallbacks.hpp.

◆ ~MpiCallbacks()

Communication::MpiCallbacks::~MpiCallbacks ( )
inline

Definition at line 269 of file MpiCallbacks.hpp.

References abort_loop().

Member Function Documentation

◆ abort_loop()

void Communication::MpiCallbacks::abort_loop ( )
inline

Abort the MPI loop.

Make the worker nodes exit the MPI loop.

Definition at line 443 of file MpiCallbacks.hpp.

Referenced by ~MpiCallbacks().

◆ add()

template<class... Args>
void Communication::MpiCallbacks::add ( void(*)(Args...)  fp)
inline

Add a new callback.

Add a new callback to the system. This is a collective function that must be run on all nodes.

Parameters
fpPointer to the static callback function to add.

Definition at line 305 of file MpiCallbacks.hpp.

◆ add_static()

template<class... Args>
static void Communication::MpiCallbacks::add_static ( void(*)(Args...)  fp)
inlinestatic

Add a new callback.

Add a new callback to the system. This is a collective function that must be run on all nodes.

Parameters
fpPointer to the static callback function to add.

Definition at line 319 of file MpiCallbacks.hpp.

Referenced by Communication::RegisterCallback::RegisterCallback().

◆ call()

template<class... Args, class... ArgRef>
auto Communication::MpiCallbacks::call ( void(*)(Args...)  fp,
ArgRef &&...  args 
) const -> std::enable_if_t<std::is_void_v<decltype(fp(args...))>>
inline

Call a callback on worker nodes.

The callback is not called on the head node.

This method can only be called on the head node.

Parameters
fpPointer to the function to call.
argsArguments for the callback.

Definition at line 386 of file MpiCallbacks.hpp.

◆ call_all()

template<class... Args, class... ArgRef>
auto Communication::MpiCallbacks::call_all ( void(*)(Args...)  fp,
ArgRef &&...  args 
) const -> std::enable_if_t<std::is_void_v<decltype(fp(args...))>>
inline

Call a callback on all nodes.

This calls a callback on all nodes, including the head node.

This method can only be called on the head node.

Parameters
fpPointer to the function to call.
argsArguments for the callback.

Definition at line 405 of file MpiCallbacks.hpp.

Referenced by get_particle_data(), and mpi_call_all().

◆ comm()

boost::mpi::communicator const & Communication::MpiCallbacks::comm ( ) const
inline

The boost mpi communicator used by this instance.

Definition at line 448 of file MpiCallbacks.hpp.

◆ loop()

void Communication::MpiCallbacks::loop ( ) const
inline

Start the MPI loop.

This is the callback loop for the worker nodes. They block on the MPI call and wait for a new callback request coming from the head node. This should be run on the worker nodes and must be running so that the head node can issue call().

Definition at line 421 of file MpiCallbacks.hpp.

Referenced by mpi_loop().

◆ operator=()

MpiCallbacks & Communication::MpiCallbacks::operator= ( MpiCallbacks const &  )
delete

◆ share_mpi_env()

std::shared_ptr< boost::mpi::environment > Communication::MpiCallbacks::share_mpi_env ( ) const
inline

Definition at line 450 of file MpiCallbacks.hpp.


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