OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::BlockLoadBalancer< T > Class Template Reference

#include <blockLoadBalancer.h>

+ Inheritance diagram for olb::BlockLoadBalancer< T >:
+ Collaboration diagram for olb::BlockLoadBalancer< T >:

Public Member Functions

 BlockLoadBalancer ()
 
 BlockLoadBalancer (int rank, int size, int globChunkSize, int offset)
 
 BlockLoadBalancer (CuboidGeometry2D< T > &cGeometry)
 
 BlockLoadBalancer (CuboidGeometry3D< T > &cGeometry)
 
void init_chunkD (int rank, int size, int globChunkSize, int offset)
 
int locChunkSize () const
 
int firstGlobNum () const
 
int lastGlobNum () const
 
- Public Member Functions inherited from olb::LoadBalancer< T >
 LoadBalancer (int size=1)
 Default empty constructor.
 
 LoadBalancer (int size, std::map< int, int > &loc, std::vector< int > &glob, std::map< int, int > &rank)
 Constructor accepting existing balancing.
 
 LoadBalancer (int size, std::map< int, int > &loc, std::vector< int > &glob, std::map< int, int > &rank, std::map< int, Platform > &platform)
 Constructor accepting existing heterogeneous balancing.
 
virtual ~LoadBalancer ()
 Default empty destructor.
 
void swap (LoadBalancer< T > &loadBalancer)
 Swap method.
 
bool isLocal (const int &glob)
 returns whether glob is on this process
 
int loc (const int &glob)
 
int loc (int glob) const
 
int glob (int loc) const
 
int rank (const int &glob)
 
int rank (int glob) const
 
int size () const
 
int getRankSize () const
 
virtual Platform platform (int loc) const
 
virtual void setPlatform (int loc, Platform platform)
 
bool operator== (const LoadBalancer< T > &rhs) const
 equal operator
 
std::size_t getNblock () const override
 Number of data blocks for the serializable interface.
 
std::size_t getSerializableSize () const override
 Binary size for the serializer.
 
bool * getBlock (std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
 Return a pointer to the memory of the current block and its size for the serializable interface.
 
void print (bool multiOutput=false) const
 
- Public Member Functions inherited from olb::Serializable
virtual ~Serializable ()=default
 
template<bool includeLogOutputDir = true>
bool save (std::string fileName="", const bool enforceUint=false)
 Save Serializable into file fileName
 
template<bool includeLogOutputDir = true>
bool load (std::string fileName="", const bool enforceUint=false)
 Load Serializable from file fileName
 
bool save (std::uint8_t *buffer)
 Save Serializable into buffer of length getSerializableSize
 
bool load (const std::uint8_t *buffer)
 Load Serializable from buffer of length getSerializableSize
 
virtual void postLoad ()
 

Additional Inherited Members

- Protected Member Functions inherited from olb::BufferSerializable
template<typename DataType >
void registerSerializable (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, size_t &sizeBufferIndex, bool *&dataPtr, DataType &data, const bool loadingMode=false)
 Register Serializable object of dynamic size.
 
template<typename DataType >
void registerStdVectorOfVars (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, size_t &sizeBufferIndex, bool *&dataPtr, std::vector< DataType > &data, const bool loadingMode=false)
 Method for registering a std::vector<DataType> of primitive DataType (int, double, ...)
 
template<typename DataType >
void registerStdVectorOfSerializablesOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, size_t &sizeBufferIndex, bool *&dataPtr, std::vector< DataType > &data, const bool loadingMode=false)
 Method for registering a std::vector<DataType> of constant-sized Serializable
 
template<typename DataType >
void registerStdVectorOfSerializables (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, size_t &sizeBufferIndex, bool *&dataPtr, std::vector< DataType > &data, const bool loadingMode=false)
 Method for registering a std::vector<DataType> of dynamic-sized DataType
 
template<typename DataTypeKey , typename DataTypeValue >
void registerMap (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, size_t &sizeBufferIndex, bool *&dataPtr, std::map< DataTypeKey, DataTypeValue > &data, const bool loadingMode=false)
 Method for registering a std::map<DataTypeKey, DataTypeValue> of fixed-sized types (i.e. int, double)
 
size_t addSizeToBuffer (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, size_t &sizeBufferIndex, bool *&dataPtr, const size_t data) const
 Add a size_t to the sizeBuffer in the n-th util::round and return that size_t in all successive rounds.
 
- Protected Member Functions inherited from olb::Serializable
template<typename DataType >
void registerVar (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, const DataType &data, const size_t arrayLength=1) const
 Register primitive data types (int, double, ...) or arrays of those.
 
template<typename DataType >
void registerSerializableOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType &data, const bool loadingMode=false)
 Register Serializable object of constant size.
 
template<typename DataType >
void registerSerializablesOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType *data, const size_t arrayLength, const bool loadingMode=false)
 Register an array of Serializable objects of constant size.
 
- Protected Attributes inherited from olb::LoadBalancer< T >
int _size
 number of cuboids after shrink -1 in appropriate thread
 
std::map< int, int > _loc
 maps global cuboid to (local) thread cuboid
 
std::vector< int > _glob
 content is 0,1,2,...,_size
 
std::map< int, int > _rank
 maps global cuboid number to the processing thread
 
std::map< int, Platform_platform
 maps global cuboid number to local platform
 
- Protected Attributes inherited from olb::BufferSerializable
std::vector< bool * > _dataBuffer
 Data buffer for data that has to be buffered between two getBlock() iterations.
 
std::vector< size_t > _sizeBuffer
 std::vector of integer buffers (e.g. for std::vector size) to be buffered for the whole iteration process
 

Detailed Description

template<typename T>
class olb::BlockLoadBalancer< T >

Definition at line 40 of file blockLoadBalancer.h.

Constructor & Destructor Documentation

◆ BlockLoadBalancer() [1/4]

template<typename T >
olb::BlockLoadBalancer< T >::BlockLoadBalancer ( )
inline

Definition at line 46 of file blockLoadBalancer.h.

46{}

◆ BlockLoadBalancer() [2/4]

template<typename T >
olb::BlockLoadBalancer< T >::BlockLoadBalancer ( int rank,
int size,
int globChunkSize,
int offset )

Definition at line 38 of file blockLoadBalancer.hh.

39{
40 init_chunkD(rank, size, globChunkSize, offset);
41}
void init_chunkD(int rank, int size, int globChunkSize, int offset)
int rank(const int &glob)

◆ BlockLoadBalancer() [3/4]

template<typename T >
olb::BlockLoadBalancer< T >::BlockLoadBalancer ( CuboidGeometry2D< T > & cGeometry)

Definition at line 50 of file blockLoadBalancer.hh.

51{
52 init_chunkD(singleton::mpi().getRank(), singleton::mpi().getSize(), cGeometry.getNc(), 0);
53}
MpiManager & mpi()

References olb::CuboidGeometry2D< T >::getNc(), and olb::singleton::mpi().

+ Here is the call graph for this function:

◆ BlockLoadBalancer() [4/4]

template<typename T >
olb::BlockLoadBalancer< T >::BlockLoadBalancer ( CuboidGeometry3D< T > & cGeometry)

Definition at line 44 of file blockLoadBalancer.hh.

45{
46 init_chunkD(singleton::mpi().getRank(), singleton::mpi().getSize(), cGeometry.getNc(), 0);
47}

References olb::CuboidGeometry3D< T >::getNc(), and olb::singleton::mpi().

+ Here is the call graph for this function:

Member Function Documentation

◆ firstGlobNum()

template<typename T >
int olb::BlockLoadBalancer< T >::firstGlobNum ( ) const

Definition at line 94 of file blockLoadBalancer.hh.

95{
96 return _firstGlobNum;
97}

◆ init_chunkD()

template<typename T >
void olb::BlockLoadBalancer< T >::init_chunkD ( int rank,
int size,
int globChunkSize,
int offset )

Definition at line 56 of file blockLoadBalancer.hh.

57{
58
59 OLB_PRECONDITION(rank>=0 && size>=1 && offset>=0)
60 OLB_PRECONDITION(size<=globChunkSize && rank<size);
61
62 // nice way to calculate # of chunks per processor
63 this->_locChunkSize = (globChunkSize+size-rank-1)/size;
64 this->_size = _locChunkSize;
65 if (rank+1 <= globChunkSize-(globChunkSize/size)*size) {
66 this->_firstGlobNum = globChunkSize/size * rank + rank + offset;
67 this->_lastGlobNum = this->_firstGlobNum + this->_locChunkSize - 1;
68 }
69 else {
70 this->_firstGlobNum = globChunkSize/size * rank + globChunkSize - (globChunkSize/size)*size + offset;
71 this->_lastGlobNum = this->_firstGlobNum + this->_locChunkSize - 1;
72 }
73 for (int i=0; i<this->_locChunkSize; i++) {
74 this->_loc[this->_firstGlobNum + i] = i;
75 this->_glob.push_back(this->_firstGlobNum + i);
76 }
77 int temp = offset;
78 for (int iRank=0; iRank<size; iRank++) {
79 int iLocChunkSize = (globChunkSize+size-iRank-1)/size;
80 for (int i=0; i<iLocChunkSize; i++) {
81 this->_rank[temp] = iRank;
82 temp++;
83 }
84 }
85}
std::vector< int > _glob
content is 0,1,2,...,_size
int _size
number of cuboids after shrink -1 in appropriate thread
std::map< int, int > _rank
maps global cuboid number to the processing thread
std::map< int, int > _loc
maps global cuboid to (local) thread cuboid
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46

References OLB_PRECONDITION.

◆ lastGlobNum()

template<typename T >
int olb::BlockLoadBalancer< T >::lastGlobNum ( ) const

Definition at line 100 of file blockLoadBalancer.hh.

101{
102 return _lastGlobNum;
103}

◆ locChunkSize()

template<typename T >
int olb::BlockLoadBalancer< T >::locChunkSize ( ) const

Definition at line 88 of file blockLoadBalancer.hh.

89{
90 return _locChunkSize;
91}

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