Documentation 6b54b78464
Loading...
Searching...
No Matches
GPUMemoryAllocation Namespace Reference

Functions

template<class T , bool ZeroInit = false>
T * gpu_alloc (size_t size) noexcept
 Memory allocation for variables on the GPU.
 
template<class T >
void gpu_free (T *ptr) noexcept
 Free memory allocated on the GPU with gpu_alloc.
 
template<class T >
T * gpu_alloc_cpy (const T *src_ptr, size_t size) noexcept
 Memory allocation for variables on the GPU along with initialization from a source host array.
 
template<class T , bool ZeroInit = false>
T * pinned_alloc (size_t size) noexcept
 Page-locked ("pinned") host memory allocation.
 
template<class T >
void pinned_free (T *ptr) noexcept
 Free memory allocated with pinned_alloc.
 

Function Documentation

◆ gpu_alloc()

template<class T , bool ZeroInit = false>
T * GPUMemoryAllocation::gpu_alloc ( size_t  size)
inlinenoexcept

Memory allocation for variables on the GPU.

Parameters
[in]sizein bytes.
Template Parameters
ZeroInit,initializememory to 0.
Returns
Pointer to memory, always use gpu_free to deallocate.

◆ gpu_alloc_cpy()

template<class T >
T * GPUMemoryAllocation::gpu_alloc_cpy ( const T *  src_ptr,
size_t  size 
)
inlinenoexcept

Memory allocation for variables on the GPU along with initialization from a source host array.

Parameters
[in]sizein bytes.
Returns
Pointer to memory, always use gpu_free to deallocate.

◆ gpu_free()

template<class T >
void GPUMemoryAllocation::gpu_free ( T *  ptr)
inlinenoexcept

Free memory allocated on the GPU with gpu_alloc.

Parameters
[in]ptr,pointerto memory we want to release.

◆ pinned_alloc()

template<class T , bool ZeroInit = false>
T * GPUMemoryAllocation::pinned_alloc ( size_t  size)
inlinenoexcept

Page-locked ("pinned") host memory allocation.

Note
Unlike regular (pageable) host memory, cudaMemcpyAsync from/to a pinned buffer is actually asynchronous with respect to the host thread; from pageable memory the driver silently falls back to a synchronous staged copy. Only worth it for host buffers that are the source/destination of an async transfer meant to overlap with other host work.
Parameters
[in]sizein bytes.
Template Parameters
ZeroInit,initializememory to 0.
Returns
Pointer to memory, always use pinned_free to deallocate.

◆ pinned_free()

template<class T >
void GPUMemoryAllocation::pinned_free ( T *  ptr)
inlinenoexcept

Free memory allocated with pinned_alloc.

Parameters
[in]ptr,pointerto memory we want to release.