SpinParser
1.0
|
Common load manager interface for both, the MPI server rank and slave ranks. More...
#include <LoadManager.hpp>
Classes | |
struct | Chunk |
Definition of a small chunk of work. Used to communicate workload between different LoadManager instances. More... | |
struct | DataStack |
Concrete derivation of DataStackBase, managing an array of fundamental data types (or tuples thereof, if DataStackBase::typeMultiplicity is greater than one). More... | |
struct | DataStackBase |
Abstract base class for DataStack types. More... | |
Public Member Functions | |
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... | |
virtual void | calculate (const StackIdentifier *stackIds, const int size)=0 |
Calculate a list of stacks, where the stack identifiers are provided in list form. 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 | |
LoadManager (const int serverRank, const MPI_Comm communicator) | |
Construct a new Load Manager object. More... | |
virtual StackIdentifier | _registerStack (DataStackBase *stack) |
Register a DataStackBase with the LoadManager. By registering the stack, the LoadManager assumes responsibility to synchronize data between MPI ranks as necessary. More... | |
void | _calculateChunk (const Chunk &chunk) |
Calculate the workload defined by a specific chunk. More... | |
Protected Attributes | |
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. | |
Common load manager interface for both, the MPI server rank and slave ranks.
This class provides an implementation of an automatic load balancing scheme for hybrid shared/distributed memory parallelization. Intra-node parallelization is implemented via OpenMP. Inter-node parallelization is implemented via MPI. A LoadManager instance is created on every MPI rank by calling the LoadManager::newLoadManager routine; This will create a LoadManagerMaster instance on the designated MPI master rank, and LoadManagerSlave instances on all remaining ranks. The work load is registered with the LoadManager in the form of DataStacks. Each data stack is associated with an array of numbers and with a functional description (referred to as calculators) on how to perform computations on the individual array entries. Different types of data stack exist with different calculator properties, see DataStackBase::StackType for more information. The LoadManager interface provides functions to create and register the different stack types with the LoadManager.
The role of the LoadManagerMaster is to break down the collective computation of all array entries into smaller chunks of work, to distribute them either locally or across multiple MPI ranks, and to retrieve the result on the master rank. In order to execute the calculators on a specific stack, the LoadManager provides the LoadManager::calculate interface. In order to make the results available also on other MPI ranks, the LoadManager::broadcast interface is provided. Various different types of data stacks exist, see the appropriate member functions for adding new stacks.
|
inlineprotected |
Construct a new Load Manager object.
serverRank | The MPI rank to take on the master role. |
communicator | The MPI communicator to operate on. |
|
inlineprotected |
Calculate the workload defined by a specific chunk.
chunk | Provides the workload definition. |
|
inlineprotectedvirtual |
Register a DataStackBase with the LoadManager. By registering the stack, the LoadManager assumes responsibility to synchronize data between MPI ranks as necessary.
stack | The stack to be registered. |
Reimplemented in HMP::LoadManagerSlave, and HMP::LoadManagerMaster.
|
inline |
Create an explicit data stack and attach it to the LoadManager.
StackT | The fundamental data type of the DataStack to be created. |
data | Data array on which the stack operates. The allocated size should be at least size * typeof(StackT). |
size | Number of elements in the stack. |
calculator | Calculator object associated with the stack. |
recommendedChunkSizeMultiple | Suggested quantization of elements per work chunk. |
recommendedChunksPerRank | Suggested number of work chunks per MPI rank. |
autoBroadcast | Enable or disable auto broadcast. |
|
inline |
Create an implicit data stack and attach it to the LoadManager.
StackT | The fundamental data type of the DataStack to be created. |
data | Data array on which the stack operates. The allocated size should be at least size * typeMultiplicity * typeof(StackT). |
size | Number of elements (or element tuples) in the stack. |
calculator | Calculator object associated with the stack. |
typeMultiplicity | Element tuple size. |
recommendedChunkSizeMultiple | Suggested quantization of elements per work chunk. |
recommendedChunksPerRank | Suggested number of work chunks per MPI rank. |
autoBroadcast | Enable or disable auto broadcast. |
|
inline |
Create a passive data stack and attach it to the LoadManager.
StackT | The fundamental data type of the DataStack to be created. |
data | Data array on which the stack operates. The allocated size should be at least size * typeMultiplicity * typeof(StackT). |
size | Number of elements (or element tuples) in the stack. |
|
inline |
Create a slave data stack and attach it to the LoadManager.
StackT | The fundamental data type of the DataStack to be created. |
data | Data array on which the stack operates. The allocated size should be at least size * typeMultiplicity * typeof(StackT). |
size | Number of elements (or element tuples) in the stack. |
master | Stack id of the associated implicit master stack. |
typeMultiplicity | Element tuple size. |
|
inline |
Broadcast a list of stacks, where the stack identifiers are provided in list form.
stackIds | Pointer to the first StackIdentifier. |
size | Number of stacks. |
|
inline |
Broadcast a single stack.
stackId | StackIdentifier of the stack to be broadcasted. |
|
inline |
Broadcast a list of stacks, where the stack identifiers are provided in initializer list form.
stackIds | Initializer list of StackIdentifiers. |
|
pure virtual |
Calculate a list of stacks, where the stack identifiers are provided in list form.
stackIds | Pointer to the first StackIdentifier. |
size | Number of stacks. |
Implemented in HMP::LoadManagerSlave, and HMP::LoadManagerMaster.
|
inline |
Calculate a single stack.
stackId | StackIdentifier of the stack to be calculated. |
|
inline |
Calculate a list of stacks, where the stack identifiers are provided in initializer list form.
stackIds | Initializer list of StackIdentifiers. |