cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
Public Member Functions | List of all members
cuda::memory::pointer_t< T > Class Template Reference

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...

#include <pointer.hpp>

Public Member Functions

T * get () const
 
 operator T* () const
 
device_t device () const
 Returns a proxy for the device into whose global memory the pointer points.
 
context_t context () const
 Returns a proxy for the context in which the memory area, into which the pointer points, was allocated.
 
T * get_for_device () const
 
T * get_for_host () const
 
pointer_t other_side_of_region_pair () const
 
 pointer_t (T *ptr) noexcept
 
 pointer_t (const pointer_t &other) noexcept=default
 
 pointer_t (pointer_t &&other) noexcept=default
 

Detailed Description

template<typename T>
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.

Member Function Documentation

◆ get()

template<typename T >
T* cuda::memory::pointer_t< T >::get ( ) const
inline
Returns
Address of the pointed-to memory, regardless of which memory space it's in and whether or not it is accessible from the host

◆ get_for_device()

template<typename T >
T* cuda::memory::pointer_t< T >::get_for_device ( ) const
inline
Returns
A pointer into device-accessible memory (not necessary on-device memory though). CUDA ensures that, for pointers to memory not accessible on the CUDA device, nullptr is returned.
Note
With unified memory, this will typically return the same value as the original pointer.

◆ get_for_host()

template<typename T >
T* cuda::memory::pointer_t< T >::get_for_host ( ) const
inline
Returns
A pointer into device-accessible memory (not necessary on-device memory though). CUDA ensures that, for pointers to memory not accessible on the CUDA device, nullptr is returned.
Note
With unified memory, this will typically return the same value as the original pointer.

◆ other_side_of_region_pair()

template<typename T >
pointer_t cuda::memory::pointer_t< T >::other_side_of_region_pair ( ) const
inline
Returns
For a mapped-memory pointer, returns the other side of the mapping, i.e. if this is the device pointer, returns the host pointer, otherwise returns the device pointer. For a managed-memory pointer, or in a unified setting, returns the single pointer usable on both device and host. In other cases returns nullptr.
Note
this relies on either the device and host pointers being nullptr in the case of a non-mapped pointer; and on the device and host pointers being identical to ptr_ for managed-memory pointers.

The documentation for this class was generated from the following file: