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 "constants.hpp"
#include "error.hpp"
#include "types.hpp"
#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,
  non_cuda = ~(::std::underlying_type<CUmemorytype>::type{0})
}
 see memory::host, memory::device, memory::managed
 

Functions

memory::type_t cuda::memory::type_of (const void *ptr)
 
context_t cuda::memory::context_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.