OpenLB 1.7
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
olb::gpu::cuda::CyclicColumn< T > Class Template Referencefinal

Virtual memory based cyclic column for usage in ColumnVector. More...

#include <column.h>

+ Inheritance diagram for olb::gpu::cuda::CyclicColumn< T >:
+ Collaboration diagram for olb::gpu::cuda::CyclicColumn< T >:

Classes

struct  Data
 

Public Types

using value_t = T
 
- Public Types inherited from olb::AbstractCyclicColumn< T >
using value_type = T
 

Public Member Functions

 CyclicColumn (std::size_t count)
 
 ~CyclicColumn ()
 
const T & operator[] (std::size_t i) const override
 
T & operator[] (std::size_t i) override
 
const T * deviceData () const
 
T * deviceData ()
 
std::size_t size () const
 
void refresh ()
 
void rotate (std::ptrdiff_t offset)
 
void resize (std::size_t count)
 
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.
 
void postLoad () override
 
- 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
 

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::gpu::cuda::CyclicColumn< T >

Virtual memory based cyclic column for usage in ColumnVector.

Column type used for propagatable population storage using the virtual memory PS pattern.

Definition at line 101 of file column.h.

Member Typedef Documentation

◆ value_t

template<typename T >
using olb::gpu::cuda::CyclicColumn< T >::value_t = T

Definition at line 116 of file column.h.

Constructor & Destructor Documentation

◆ CyclicColumn()

template<typename T >
olb::gpu::cuda::CyclicColumn< T >::CyclicColumn ( std::size_t count)

Definition at line 259 of file column.hh.

259 :
260 _count(device::getPageAlignedCount<T>(count)),
261 _size(_count * sizeof(T)),
262 _data(new Data(_count)),
263 _shift(0)
264{
265 _deviceBase = reinterpret_cast<T*>(_data->ptr);
266 _devicePopulation = _deviceBase;
267}

◆ ~CyclicColumn()

template<typename T >
olb::gpu::cuda::CyclicColumn< T >::~CyclicColumn ( )

Definition at line 270 of file column.hh.

271{ }

Member Function Documentation

◆ deviceData() [1/2]

template<typename T >
T * olb::gpu::cuda::CyclicColumn< T >::deviceData ( )
inline

Definition at line 129 of file column.h.

130 {
131 return _devicePopulation;
132 }

◆ deviceData() [2/2]

template<typename T >
const T * olb::gpu::cuda::CyclicColumn< T >::deviceData ( ) const
inline

Definition at line 124 of file column.h.

125 {
126 return _devicePopulation;
127 }

◆ getBlock()

template<typename T >
bool * olb::gpu::cuda::CyclicColumn< T >::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 311 of file column.hh.

312{
313 std::size_t currentBlock = 0;
314 bool* dataPtr = nullptr;
315
316 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _shift);
317 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _count);
318 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *_data->host.get(), _count);
319
320 return dataPtr;
321}
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

◆ getNblock()

template<typename T >
std::size_t olb::gpu::cuda::CyclicColumn< T >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 299 of file column.hh.

300{
301 return 3;
302}

◆ getSerializableSize()

template<typename T >
std::size_t olb::gpu::cuda::CyclicColumn< T >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 305 of file column.hh.

306{
307 return _count * sizeof(T) + sizeof(std::ptrdiff_t) + sizeof(std::size_t);
308}

◆ operator[]() [1/2]

template<typename T >
const T & olb::gpu::cuda::CyclicColumn< T >::operator[] ( std::size_t i) const
overridevirtual

Implements olb::AbstractCyclicColumn< T >.

Definition at line 274 of file column.hh.

275{
276 return _data->host[i];
277}

◆ operator[]() [2/2]

template<typename T >
T & olb::gpu::cuda::CyclicColumn< T >::operator[] ( std::size_t i)
overridevirtual

Implements olb::AbstractCyclicColumn< T >.

Definition at line 280 of file column.hh.

281{
282 return _data->host[i];
283}

◆ postLoad()

template<typename T >
void olb::gpu::cuda::CyclicColumn< T >::postLoad ( )
inlineoverridevirtual

Reimplemented from olb::Serializable.

Definition at line 169 of file column.h.

169{ refresh(); }

References olb::gpu::cuda::CyclicColumn< T >::refresh().

+ Here is the call graph for this function:

◆ refresh()

template<typename T >
void olb::gpu::cuda::CyclicColumn< T >::refresh ( )
inline

Definition at line 139 of file column.h.

140 {
141 _devicePopulation = _deviceBase + _shift;
142 }
+ Here is the caller graph for this function:

◆ resize()

template<typename T >
void olb::gpu::cuda::CyclicColumn< T >::resize ( std::size_t count)
inline

Definition at line 156 of file column.h.

157 {
158 throw std::logic_error("Cyclic column can not be resized");
159 }

◆ rotate()

template<typename T >
void olb::gpu::cuda::CyclicColumn< T >::rotate ( std::ptrdiff_t offset)
inline

Definition at line 144 of file column.h.

145 {
146 _shift -= offset;
147 if (_shift >= _count) {
148 _shift -= _count;
149 }
150 else if (_shift < 0) {
151 _shift += _count;
152 }
153 refresh();
154 }

References olb::gpu::cuda::CyclicColumn< T >::refresh().

+ Here is the call graph for this function:

◆ setProcessingContext()

template<typename T >
void olb::gpu::cuda::CyclicColumn< T >::setProcessingContext ( ProcessingContext context)

Definition at line 286 of file column.hh.

287{
288 switch (context) {
290 device::copyToHost(_devicePopulation, _data->host.get(), _size);
291 return;
293 device::copyToDevice(_data->host.get(), _devicePopulation, _size);
294 return;
295 }
296}
void copyToHost(void *src, void *dst, std::size_t count)
Copy data from device to host.
Definition device.hh:78
void copyToDevice(void *src, void *dst, std::size_t count)
Copy data from host to device.
Definition device.hh:83
@ Simulation
Data available on host for e.g. functor evaluation.

References olb::gpu::cuda::device::copyToDevice(), olb::gpu::cuda::device::copyToHost(), olb::Evaluation, and olb::Simulation.

+ Here is the call graph for this function:

◆ size()

template<typename T >
std::size_t olb::gpu::cuda::CyclicColumn< T >::size ( ) const
inline

Definition at line 134 of file column.h.

135 {
136 return _count;
137 }
+ Here is the caller graph for this function:

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