mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
A smart-pointer wrapper for cuda device pointers.
Definition at line 46 of file cudaPtr.hpp.
#include <math/cuda/cudaPtr.hpp>
Public Types | |
typedef T | hostPtrT |
The host data type. More... | |
typedef T | devicePtrT |
The device data type. More... | |
Public Member Functions | |
~cudaPtr () | |
Destructor, frees memory if allocated. More... | |
int | resize (size_t sz) |
Resize the memory allocation, in 1D. More... | |
int | resize (size_t x_sz, size_t y_sz) |
Resize the memory allocation, in 2D. More... | |
int | resize (size_t x_sz, size_t y_sz, size_t z_sz) |
Resize the memory allocation, in 3D. More... | |
cudaError_t | initialize () |
Initialize the array bytes to 0. More... | |
int | free () |
Free the memory allocation. More... | |
int | upload (const hostPtrT *src) |
Copy from the host to the device, after allocation. More... | |
int | upload (const hostPtrT *src, size_t sz) |
Copy from the host to the device with allocation. More... | |
int | download (hostPtrT *dest) |
Copy from the device to the host. More... | |
cpp2cudaType< devicePtrT >::cudaType * | operator() () |
Conversion operator, accesses the device pointer for use in Cuda functions. More... | |
const cpp2cudaType< devicePtrT >::cudaType * | operator() () const |
Conversion operator, accesses the device pointer for use in Cuda functions. More... | |
Public Attributes | |
devicePtrT * | m_devicePtr {nullptr} |
The device pointer. More... | |
size_t | m_size {0} |
The allocated size. More... | |
typedef T mx::cuda::cudaPtr< T >::devicePtrT |
The device data type.
Definition at line 54 of file cudaPtr.hpp.
typedef T mx::cuda::cudaPtr< T >::hostPtrT |
The host data type.
Definition at line 50 of file cudaPtr.hpp.
mx::cuda::cudaPtr< T >::~cudaPtr |
Destructor, frees memory if allocated.
Definition at line 177 of file cudaPtr.hpp.
int mx::cuda::cudaPtr< T >::download | ( | hostPtrT * | dest | ) |
Copy from the device to the host.
Scenario: scaling a vector with cublas [test doc]
Scenario: scaling and accumulating a vector with cublas [test doc]
Scenario: multiplying two vectors element by element [test doc]
[in] | dest | The host location, allocated. |
Definition at line 274 of file cudaPtr.hpp.
Referenced by SCENARIO().
int mx::cuda::cudaPtr< T >::free |
Free the memory allocation.
Definition at line 225 of file cudaPtr.hpp.
cudaError_t mx::cuda::cudaPtr< T >::initialize |
Initialize the array bytes to 0.
Just a wrapper to cudaMemset.
Definition at line 219 of file cudaPtr.hpp.
Referenced by SCENARIO().
|
inline |
Conversion operator, accesses the device pointer for use in Cuda functions.
Scenario: scaling and accumulating a vector with cublas [test doc]
Scenario: multiplying two vectors element by element [test doc]
Definition at line 159 of file cudaPtr.hpp.
References mx::cuda::cudaPtr< T >::m_devicePtr.
|
inline |
Conversion operator, accesses the device pointer for use in Cuda functions.
Definition at line 169 of file cudaPtr.hpp.
References mx::cuda::cudaPtr< T >::m_devicePtr.
int mx::cuda::cudaPtr< T >::resize | ( | size_t | sz | ) |
Resize the memory allocation, in 1D.
If no size change, this is a no-op.
Scenario: scaling a vector with cublas [test doc]
Scenario: scaling and accumulating a vector with cublas [test doc]
Scenario: multiplying two vectors element by element [test doc]
[in] | sz | the new size |
Definition at line 183 of file cudaPtr.hpp.
Referenced by SCENARIO().
int mx::cuda::cudaPtr< T >::resize | ( | size_t | x_sz, |
size_t | y_sz | ||
) |
Resize the memory allocation, in 2D.
If no size change, this is a no-op.
[in] | x_sz | the new x size, |
[in] | y_sz | the new y size |
Definition at line 202 of file cudaPtr.hpp.
int mx::cuda::cudaPtr< T >::resize | ( | size_t | x_sz, |
size_t | y_sz, | ||
size_t | z_sz | ||
) |
Resize the memory allocation, in 3D.
If no size change, this is a no-op.
[in] | x_sz | the new x size, |
[in] | y_sz | the new y size, |
[in] | z_sz | the new z size |
Definition at line 210 of file cudaPtr.hpp.
int mx::cuda::cudaPtr< T >::upload | ( | const hostPtrT * | src | ) |
Copy from the host to the device, after allocation.
The device pointer must be allocated.
[in] | src | The host location |
Definition at line 245 of file cudaPtr.hpp.
Referenced by SCENARIO().
int mx::cuda::cudaPtr< T >::upload | ( | const hostPtrT * | src, |
size_t | sz | ||
) |
Copy from the host to the device with allocation.
The device pointer will be re-allocated as needed.
Scenario: scaling a vector with cublas [test doc]
Scenario: scaling and accumulating a vector with cublas [test doc]
Scenario: multiplying two vectors element by element [test doc]
[in] | src | The host location |
[in] | sz | The size of the array |
Definition at line 260 of file cudaPtr.hpp.
devicePtrT* mx::cuda::cudaPtr< T >::m_devicePtr {nullptr} |
The device pointer.
Definition at line 57 of file cudaPtr.hpp.
Referenced by mx::cuda::cudaPtr< T >::operator()().
size_t mx::cuda::cudaPtr< T >::m_size {0} |
The allocated size.
Definition at line 60 of file cudaPtr.hpp.