cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
Classes | Namespaces | Macros | Enumerations | Functions
pointer.hpp File Reference

A wrapper class for host and/or device pointers, allowing easy access to CUDA's pointer attributes. More...

#include <cuda/api/constants.hpp>
#include <cuda/api/error.hpp>
#include <cuda/api/types.hpp>
#include <cuda_runtime_api.h>
#include <cuda.h>
#include <cassert>
Include dependency graph for pointer.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cuda::memory::pointer_t< T >
 A convenience wrapper around a raw pointer "known" to the CUDA runtime and which thus has various kinds of associated information which this wrapper allows access to. More...
 

Namespaces

 cuda
 All definitions and functionality wrapping the CUDA Runtime API.
 

Enumerations

enum  cuda::memory::type_t : ::std::underlying_type< CUmemorytype >::type {
  host_ = CU_MEMORYTYPE_HOST,
  device_ = CU_MEMORYTYPE_DEVICE,
  array = CU_MEMORYTYPE_ARRAY,
  unified_ = CU_MEMORYTYPE_UNIFIED,
  managed_ = CU_MEMORYTYPE_UNIFIED
}
 see memory::host, memory::device, memory::managed
 

Functions

memory::type_t cuda::memory::type_of (const void *ptr)
 
template<typename T >
pointer_t< T > cuda::memory::pointer::wrap (T *ptr) noexcept
 Wraps an existing pointer in a pointer_t wrapper. More...
 

Detailed Description

A wrapper class for host and/or device pointers, allowing easy access to CUDA's pointer attributes.

Note
at the moment, this class is not used by other sections of the API wrappers; specifically, freestanding functions and methods returning pointers return raw T*'s rather than pointer_t<T>'s. This may change in the future.
Todo:
Consider allowing for storing attributes within the class, lazily (e.g. with an ::std::optional).

Function Documentation

◆ wrap()

template<typename T >
pointer_t<T> cuda::memory::pointer::wrap ( T *  ptr)
inlinenoexcept

Wraps an existing pointer in a pointer_t wrapper.

Parameters
ptra pointer - into either device or host memory - to be wrapped.