OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::ConcreteBlockMask< T, Platform::CPU_SIMD > Class Template Referencefinal

#include <mask.h>

+ Inheritance diagram for olb::ConcreteBlockMask< T, Platform::CPU_SIMD >:
+ Collaboration diagram for olb::ConcreteBlockMask< T, Platform::CPU_SIMD >:

Public Member Functions

 ConcreteBlockMask (std::size_t size)
 
 ConcreteBlockMask (const ConcreteBlockMask &rhs)
 
bool operator[] (std::size_t i) const
 
std::size_t weight () const
 
void set (std::size_t i, bool active)
 
auto * raw ()
 
void setProcessingContext (ProcessingContext)
 
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.
 
- 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::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.
 

Detailed Description

template<typename T>
class olb::ConcreteBlockMask< T, Platform::CPU_SIMD >

Definition at line 33 of file mask.h.

Constructor & Destructor Documentation

◆ ConcreteBlockMask() [1/2]

template<typename T >
olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::ConcreteBlockMask ( std::size_t size)
inline

Definition at line 45 of file mask.h.

45 :
46 _size(size + cpu::simd::Pack<T>::size),
47 _weight(0),
48 _mask(_size),
49 _serializedSize((_size + cpu::simd::Pack<T>::size - 1) / cpu::simd::Mask<T>::storage_size + 1),
50 _serialized(new typename cpu::simd::Mask<T>::storage_t[_serializedSize] { }),
51 _modified(true)
52 { }

◆ ConcreteBlockMask() [2/2]

template<typename T >
olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::ConcreteBlockMask ( const ConcreteBlockMask< T, Platform::CPU_SIMD > & rhs)
inline

Definition at line 54 of file mask.h.

54 :
55 _size(rhs._size),
56 _weight(rhs._size),
57 _mask(rhs._mask),
58 _serializedSize(rhs._serializedSize),
59 _serialized(new typename cpu::simd::Mask<T>::storage_t[_serializedSize] { }),
60 _modified(rhs._modified)
61 {
62 std::copy(rhs._serialized.get(),
63 rhs._serialized.get() + _serializedSize,
64 _serialized.get());
65 }

Member Function Documentation

◆ getBlock()

template<typename T >
bool * olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::getBlock ( std::size_t iBlock,
std::size_t & sizeBlock,
bool loadingMode )
overridevirtual

Return a pointer to the memory of the current block and its size for the serializable interface.

Implements olb::Serializable.

Definition at line 125 of file mask.h.

126{
127 std::size_t currentBlock = 0;
128 bool* dataPtr = nullptr;
129
130 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _weight);
131 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _mask, loadingMode);
132
133 return dataPtr;
134}
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.
Definition serializer.h:212
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.
Definition serializer.h:239

◆ getNblock()

template<typename T >
std::size_t olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 113 of file mask.h.

114{
115 return 1 + _mask.getNblock();
116}

◆ getSerializableSize()

template<typename T >
std::size_t olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 119 of file mask.h.

120{
121 return sizeof(_weight) + _mask.getSerializableSize();
122}

◆ operator[]()

template<typename T >
bool olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::operator[] ( std::size_t i) const
inline

Definition at line 67 of file mask.h.

67 {
68 return _mask[i];
69 }

◆ raw()

template<typename T >
auto * olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::raw ( )
inline

Definition at line 85 of file mask.h.

86 {
87 if constexpr (cpu::simd::Mask<T>::storage_size == 1) {
88 return _mask.data(); // Transparently convert bools to std::uint64_t for AVX2
89 } else {
90 return _serialized.get(); // Use serialized bit-mask for AVX-512
91 }
92 }

References olb::cpu::simd::Column< T >::data().

+ Here is the call graph for this function:

◆ set()

template<typename T >
void olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::set ( std::size_t i,
bool active )
inline

Definition at line 75 of file mask.h.

75 {
76 if ( _mask[i] && !active) {
77 _weight -= 1;
78 } else if (!_mask[i] && active) {
79 _weight += 1;
80 }
81 _mask[i] = active;
82 _modified = true;
83 }

◆ setProcessingContext()

template<typename T >
void olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::setProcessingContext ( ProcessingContext )
inline

Definition at line 94 of file mask.h.

94 {
95 if (_modified) {
96 for (std::size_t i=0; i < _size; i += cpu::simd::Mask<T>::storage_size) {
97 _serialized[i / cpu::simd::Mask<T>::storage_size] = cpu::simd::Mask<T>::encode(_mask.data() + i);
98 }
99 _modified = false;
100 }
101 }

References olb::cpu::simd::Column< T >::data().

+ Here is the call graph for this function:

◆ weight()

template<typename T >
std::size_t olb::ConcreteBlockMask< T, Platform::CPU_SIMD >::weight ( ) const
inline

Definition at line 71 of file mask.h.

71 {
72 return _weight;
73 }

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