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

Plain column for CUDA GPU targets. More...

#include <column.h>

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

Classes

struct  Data
 

Public Types

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

Public Member Functions

 Column (std::size_t count)
 
 Column (Column< T > &&rhs)
 
 Column (const Column< T > &rhs)
 
 ~Column ()
 
const T & operator[] (std::size_t i) const override
 
T & operator[] (std::size_t i) override
 
std::size_t size () const
 
const T * data () const
 
T * data ()
 
const T * deviceData () const
 
T * deviceData ()
 
void clear ()
 Reset size to zero.
 
void resize (std::size_t newCount)
 
void push_back (T value)
 
void deduplicate ()
 Combined ascending sort and removal of duplicate entries.
 
void setProcessingContext (ProcessingContext)
 
void setProcessingContext (ProcessingContext, device::Stream &)
 
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::gpu::cuda::Column< T >

Plain column for CUDA GPU targets.

Definition at line 48 of file column.h.

Member Typedef Documentation

◆ value_t

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

Definition at line 57 of file column.h.

Constructor & Destructor Documentation

◆ Column() [1/3]

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

Definition at line 65 of file column.hh.

65 :
66 _count(count),
67 _data(new Data(count))
68{ }

◆ Column() [2/3]

template<typename T >
olb::gpu::cuda::Column< T >::Column ( Column< T > && rhs)

Definition at line 71 of file column.hh.

71 :
72 _count(rhs._count),
73 _data(rhs._data.release())
74{ }

◆ Column() [3/3]

template<typename T >
olb::gpu::cuda::Column< T >::Column ( const Column< T > & rhs)

Definition at line 77 of file column.hh.

77 :
78 _count(rhs._count),
79 _data(new Data(*rhs._data))
80{ }

◆ ~Column()

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

Definition at line 83 of file column.hh.

84{ }

Member Function Documentation

◆ clear()

template<typename T >
void olb::gpu::cuda::Column< T >::clear ( )

Reset size to zero.

Definition at line 87 of file column.hh.

88{
89 _data->device.clear();
90 _data->host.clear();
91 _count = _data->host.size();
92}
+ Here is the caller graph for this function:

◆ data() [1/2]

template<typename T >
T * olb::gpu::cuda::Column< T >::data ( )

Definition at line 140 of file column.hh.

141{
142 return _data->host.data();
143}

◆ data() [2/2]

template<typename T >
const T * olb::gpu::cuda::Column< T >::data ( ) const

Definition at line 134 of file column.hh.

135{
136 return _data->host.data();
137}
+ Here is the caller graph for this function:

◆ deduplicate()

template<typename T >
void olb::gpu::cuda::Column< T >::deduplicate ( )

Combined ascending sort and removal of duplicate entries.

Definition at line 109 of file column.hh.

110{
111 std::sort(_data->host.begin(), _data->host.end());
112 _data->host.erase(std::unique(_data->host.begin(), _data->host.end()), _data->host.end());
113}

◆ deviceData() [1/2]

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

Definition at line 152 of file column.hh.

153{
154 return _data->device.data().get();
155}

References olb::gpu::cuda::Column< T >::data().

+ Here is the call graph for this function:

◆ deviceData() [2/2]

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

Definition at line 146 of file column.hh.

147{
148 return _data->device.data().get();
149}

References olb::gpu::cuda::Column< T >::data().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBlock()

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

203{
204 std::size_t currentBlock = 0;
205 bool* dataPtr = nullptr;
206
207 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _count);
208 if (loadingMode && iBlock == 1) {
209 resize(_count);
210 }
211 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *data(), _count);
212
213 return dataPtr;
214}
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
const T * data() const
Definition column.hh:134
void resize(std::size_t newCount)
Definition column.hh:95

◆ getNblock()

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

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 190 of file column.hh.

191{
192 return 2;
193}

◆ getSerializableSize()

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

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 196 of file column.hh.

197{
198 return _count * sizeof(T) + sizeof(std::size_t);
199}

◆ operator[]() [1/2]

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

Implements olb::AbstractColumn< T >.

Definition at line 116 of file column.hh.

117{
118 return _data->host[i];
119}

◆ operator[]() [2/2]

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

Implements olb::AbstractColumn< T >.

Definition at line 122 of file column.hh.

123{
124 return _data->host[i];
125}

◆ push_back()

template<typename T >
void olb::gpu::cuda::Column< T >::push_back ( T value)

Definition at line 102 of file column.hh.

103{
104 _data->host.push_back(value);
105 _count = _data->host.size();
106}

References olb::gpu::cuda::Column< T >::push_back().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resize()

template<typename T >
void olb::gpu::cuda::Column< T >::resize ( std::size_t newCount)

Definition at line 95 of file column.hh.

96{
97 _data->resize(newCount);
98 _count = newCount;
99}

◆ setProcessingContext() [1/2]

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

Definition at line 158 of file column.hh.

159{
160 if (_count != _data->device.size()) {
161 _data->device.resize(_count);
162 }
163 switch (context) {
165 device::copyToHost(_data->device.data().get(), _data->host.data(), size()*sizeof(T));
166 return;
168 device::copyToDevice(_data->host.data(), _data->device.data().get(), size()*sizeof(T));
169 return;
170 }
171}
std::size_t size() const
Definition column.hh:128
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:
+ Here is the caller graph for this function:

◆ setProcessingContext() [2/2]

template<typename T >
void olb::gpu::cuda::Column< T >::setProcessingContext ( ProcessingContext context,
device::Stream & stream )

Definition at line 174 of file column.hh.

175{
176 if (_count != _data->device.size()) {
177 _data->device.resize(_count);
178 }
179 switch (context) {
181 device::asyncCopyToHost(stream, _data->device.data().get(), _data->host.data(), size()*sizeof(T));
182 return;
184 device::asyncCopyToDevice(stream, _data->host.data(), _data->device.data().get(), size()*sizeof(T));
185 return;
186 }
187}
void asyncCopyToDevice(Stream &stream, void *src, void *dst, std::size_t count)
Copy data from host to device (async)
Definition device.hh:145
void asyncCopyToHost(Stream &stream, void *src, void *dst, std::size_t count)
Copy data from device to host (async)
Definition device.hh:141

References olb::gpu::cuda::device::asyncCopyToDevice(), olb::gpu::cuda::device::asyncCopyToHost(), olb::Evaluation, olb::gpu::cuda::device::Stream::get(), and olb::Simulation.

+ Here is the call graph for this function:

◆ size()

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

Definition at line 128 of file column.hh.

129{
130 return _count;
131}
+ Here is the caller graph for this function:

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