My Project
|
The GpuView class is provides a view of some data allocated on the GPU Essenstially is only stores a pointer and a size. More...
#include <GpuView.hpp>
Classes | |
class | iterator |
Iterator class to make GpuViews more similar to std containers. More... | |
Public Types | |
using | value_type = T |
Public Member Functions | |
GpuView ()=default | |
Default constructor that will initialize cublas and allocate 0 bytes of memory. | |
GpuView (std::vector< T > &data) | |
constructor based on std::vectors, this will make a view on the CPU | |
__host__ __device__ T & | operator[] (size_t idx) |
operator[] to retrieve a reference to an item in the buffer | |
__host__ __device__ T | operator[] (size_t idx) const |
operator[] to retrieve a copy of an item in the buffer | |
GpuView (T *dataOnHost, size_t numberOfElements) | |
GpuView allocates new GPU memory of size numberOfElements * sizeof(T) and copies numberOfElements from data. | |
~GpuView ()=default | |
~GpuView calls cudaFree | |
__host__ __device__ T * | data () |
__host__ __device__ const T * | data () const |
__host__ __device__ T & | front () |
__host__ __device__ T & | back () |
__host__ __device__ T | front () const |
__host__ __device__ T | back () const |
void | copyFromHost (const T *dataPointer, size_t numberOfElements) |
copyFromHost copies numberOfElements from the CPU memory dataPointer | |
void | copyToHost (T *dataPointer, size_t numberOfElements) const |
copyFromHost copies numberOfElements to the CPU memory dataPointer | |
void | copyFromHost (const std::vector< T > &data) |
copyToHost copies data from an std::vector | |
void | copyToHost (std::vector< T > &data) const |
copyToHost copies data to an std::vector | |
__host__ __device__ size_t | size () const |
size returns the size (number of T elements) in the vector | |
std::vector< T > | asStdVector () const |
creates an std::vector of the same size and copies the GPU data to this std::vector | |
__host__ __device__ iterator | begin () |
Get an iterator pointing to the first element of the buffer. | |
__host__ __device__ iterator | begin () const |
Get a const iterator pointing to the first element of the buffer. | |
__host__ __device__ iterator | end () |
Get an iterator pointing to the address after the last element of the buffer. | |
__host__ __device__ iterator | end () const |
Get a const iterator pointing to the address after the last element of the buffer. | |
The GpuView class is provides a view of some data allocated on the GPU Essenstially is only stores a pointer and a size.
This class supports being used from inside a CUDA/HIP Kernel. Implementations are placed in this headerfile for functions that may be called inside a kernel to avoid expensive RDC (relocatable device code)
The view will typically provide a view into a GpuBuffer and be able to manipulate the data within it
T | Type of the data we store, typically int/float/double w/o const specifier |
Opm::gpuistl::GpuView< T >::GpuView | ( | std::vector< T > & | data | ) |
constructor based on std::vectors, this will make a view on the CPU
data | std vector to pr |
|
inline |
GpuView allocates new GPU memory of size numberOfElements * sizeof(T) and copies numberOfElements from data.
numberOfElements | number of T elements to allocate |
dataOnHost | data on host/CPU |
std::vector< T > Opm::gpuistl::GpuView< T >::asStdVector | ( | ) | const |
creates an std::vector of the same size and copies the GPU data to this std::vector
|
inline |
|
inline |
|
inline |
Get an iterator pointing to the first element of the buffer.
iterator | to traverse the buffer |
|
inline |
Get a const iterator pointing to the first element of the buffer.
iterator | to traverse the buffer |
void Opm::gpuistl::GpuView< T >::copyFromHost | ( | const std::vector< T > & | data | ) |
copyToHost copies data from an std::vector
data | the vector to copy from |
void Opm::gpuistl::GpuView< T >::copyFromHost | ( | const T * | dataPointer, |
size_t | numberOfElements | ||
) |
copyFromHost copies numberOfElements from the CPU memory dataPointer
dataPointer | raw pointer to CPU memory |
numberOfElements | number of elements to copy |
void Opm::gpuistl::GpuView< T >::copyToHost | ( | std::vector< T > & | data | ) | const |
copyToHost copies data to an std::vector
data | the vector to copy to |
void Opm::gpuistl::GpuView< T >::copyToHost | ( | T * | dataPointer, |
size_t | numberOfElements | ||
) | const |
copyFromHost copies numberOfElements to the CPU memory dataPointer
dataPointer | raw pointer to CPU memory |
numberOfElements | number of elements to copy |
|
inline |
|
inline |
|
inline |
Get an iterator pointing to the address after the last element of the buffer.
iterator | pointing to the first value after the end of the buffer |
|
inline |
Get a const iterator pointing to the address after the last element of the buffer.
iterator | pointing to the first value after the end of the buffer |
|
inline |
|
inline |
|
inline |
operator[] to retrieve a reference to an item in the buffer
idx | The index of the element |
|
inline |
operator[] to retrieve a copy of an item in the buffer
idx | The index of the element |
|
inline |
size returns the size (number of T elements) in the vector