SpinParser  1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
HMP::LoadManagerSlave Class Reference

LoadManager slave implementation, responsible for receiving and executing workload chunks form a LoadManagerMaster implementation. More...

#include <LoadManager.hpp>

Inheritance diagram for HMP::LoadManagerSlave:
Inheritance graph
[legend]
Collaboration diagram for HMP::LoadManagerSlave:
Collaboration graph
[legend]

Public Member Functions

virtual void calculate (const StackIdentifier *stackIds, const int size) override
 Calculate a list of stacks, where the stack identifiers are provided in list form. More...
 
- Public Member Functions inherited from HMP::LoadManager
virtual ~LoadManager ()
 Destroy the LoadManager object.
 
template<class StackT >
StackIdentifier addMasterStackExplicit (StackT *const data, const int size, const std::function< StackT(int)> &calculator, const int recommendedChunkSizeMultiple=1, const int recommendedChunksPerRank=10, const bool autoBroadcast=false)
 Create an explicit data stack and attach it to the LoadManager. More...
 
template<class StackT >
StackIdentifier addMasterStackImplicit (StackT *const data, const int size, const std::function< void(int)> &calculator, const int typeMultiplicity=1, const int recommendedChunkSizeMultiple=1, const int recommendedChunksPerRank=10, const bool autoBroadcast=false)
 Create an implicit data stack and attach it to the LoadManager. More...
 
template<class StackT >
StackIdentifier addSlaveStack (StackT *const data, const int size, const StackIdentifier master, const int typeMultiplicity=1)
 Create a slave data stack and attach it to the LoadManager. More...
 
template<class StackT >
StackIdentifier addPassiveStack (StackT *const data, const int size)
 Create a passive data stack and attach it to the LoadManager. More...
 
void calculate (const std::initializer_list< StackIdentifier > &stackIds)
 Calculate a list of stacks, where the stack identifiers are provided in initializer list form. More...
 
void calculate (const StackIdentifier stackId)
 Calculate a single stack. More...
 
void calculateAll ()
 Calculate all stacks.
 
void broadcast (const StackIdentifier *stackIds, const int size)
 Broadcast a list of stacks, where the stack identifiers are provided in list form. More...
 
void broadcast (const std::initializer_list< StackIdentifier > &stackIds)
 Broadcast a list of stacks, where the stack identifiers are provided in initializer list form. More...
 
void broadcast (const StackIdentifier stackId)
 Broadcast a single stack. More...
 
void broadcastAll ()
 Broadcast all stacks.
 
virtual void printRuntimeStatistics () const
 Virtual implementation to print runtime statistics, including information on the efficiency of LoadManager instances running on different MPI ranks.
 

Protected Member Functions

 LoadManagerSlave (const int serverRank, const MPI_Comm communicator)
 Construct a new LoadManagerSlave object. More...
 
virtual StackIdentifier _registerStack (DataStackBase *stack) override
 Register a DataStackBase with the LoadManager. By registering the stack, the LoadManager assumes responsibility to synchronize data between MPI ranks as necessary. More...
 
void _waitChunk (Chunk &chunk) const
 Wait until a workload chunk has been received from a LoadManagerMaster instance. More...
 
void _returnChunk (const Chunk &chunk) const
 Return the result of the workload defined by a specific chunk. More...
 
- Protected Member Functions inherited from HMP::LoadManager
 LoadManager (const int serverRank, const MPI_Comm communicator)
 Construct a new Load Manager object. More...
 
void _calculateChunk (const Chunk &chunk)
 Calculate the workload defined by a specific chunk. More...
 

Protected Attributes

std::vector< float > _currentCalculationComputeTimeBuffer
 _currentCalculationComputeTimeBuffer[stack] is a buffer for the time in milliseconds spent on computing stack in the current calculate() call.
 
- Protected Attributes inherited from HMP::LoadManager
std::vector< DataStackBase * > _stacks
 List of all registered stacks.
 
int _serverRank
 Designated MPI master rank.
 
int _rank
 MPI rank of the current LoadManager instance.
 
int _commSize
 MPI communicator size.
 
MPI_Comm _communicator
 MPI communicator to operate on.
 

Friends

LoadManagernewLoadManager (const int serverRank, const MPI_Comm communicator)
 Create a new LoadManager instance. If the current MPI rank is the designated master rank, returns a LoadManagerMaster instance, otherwise returns a LoadManagerSlave instance. More...
 

Detailed Description

LoadManager slave implementation, responsible for receiving and executing workload chunks form a LoadManagerMaster implementation.

See also
LoadManager

Constructor & Destructor Documentation

◆ LoadManagerSlave()

HMP::LoadManagerSlave::LoadManagerSlave ( const int  serverRank,
const MPI_Comm  communicator 
)
inlineprotected

Construct a new LoadManagerSlave object.

Parameters
serverRankThe MPI rank to take on the master role.
communicatorThe MPI communicator used for communication.

Member Function Documentation

◆ _registerStack()

virtual StackIdentifier HMP::LoadManagerSlave::_registerStack ( DataStackBase stack)
inlineoverrideprotectedvirtual

Register a DataStackBase with the LoadManager. By registering the stack, the LoadManager assumes responsibility to synchronize data between MPI ranks as necessary.

Parameters
stackThe stack to be registered.
Returns
StackIdentifier Unique identifier of the newly registered stack; Used e.g. for LoadManager::calculate calls.

Reimplemented from HMP::LoadManager.

◆ _returnChunk()

void HMP::LoadManagerSlave::_returnChunk ( const Chunk chunk) const
inlineprotected

Return the result of the workload defined by a specific chunk.

Parameters
chunkThe workload definition whose results are to be returned.

◆ _waitChunk()

void HMP::LoadManagerSlave::_waitChunk ( Chunk chunk) const
inlineprotected

Wait until a workload chunk has been received from a LoadManagerMaster instance.

Parameters
[out]chunkThe workload definition which has been received.

◆ calculate()

virtual void HMP::LoadManagerSlave::calculate ( const StackIdentifier stackIds,
const int  size 
)
inlineoverridevirtual

Calculate a list of stacks, where the stack identifiers are provided in list form.

Parameters
stackIdsPointer to the first StackIdentifier.
sizeNumber of stacks.

Implements HMP::LoadManager.

Friends And Related Function Documentation

◆ newLoadManager

LoadManager* newLoadManager ( const int  serverRank = 0,
const MPI_Comm  communicator = MPI_COMM_WORLD 
)
friend

Create a new LoadManager instance. If the current MPI rank is the designated master rank, returns a LoadManagerMaster instance, otherwise returns a LoadManagerSlave instance.

Parameters
serverRankMPI rank to assume the master role.
communicatorThe MPI communicator to operate on.
Returns
LoadManager* Newly generated LoadManager instance.

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