Template Class device_ptr¶
Defined in File device_malloc_allocator.h
Inheritance Relationships¶
Base Type¶
public thrust::pointer< T, thrust::device_system_tag, thrust::device_reference< T >, thrust::device_ptr< T > >
Class Documentation¶
-
template<typename
T
>
classdevice_ptr
: public thrust::pointer<T, thrust::device_system_tag, thrust::device_reference<T>, thrust::device_ptr<T>>¶ device_ptr
stores a pointer to an object allocated in device memory. This type provides type safety when dispatching standard algorithms on ranges resident in device memory.device_ptr
has pointer semantics: it may be dereferenced safely from the host and may be manipulated with pointer arithmetic.device_ptr
can be created with the functions device_malloc, device_new, or device_pointer_cast, or by explicitly calling its constructor with a raw pointer.The raw pointer encapsulated by a
device_ptr
may be obtained by either itsget
method or theraw_pointer_cast
free function.- Note
device_ptr
is not a smart pointer; it is the programmer’s responsibility to deallocate memory pointed to bydevice_ptr
.- See
- See
- See
- See
Public Functions
-
__host__ __device__ thrust::device_ptr::device_ptr()
device_ptr's
null constructor initializes its raw pointer to0
.
-
template<typename OtherT>__host__ __device__ thrust::device_ptr::device_ptr(OtherT * ptr)
device_ptr's
copy constructor is templated to allow copying to adevice_ptr<const T>
from aT *
.- Parameters
ptr
: A raw pointer to copy from, presumed to point to a location in device memory.
-
__host__ __device__ thrust::device_ptr::device_ptr(T * ptr)
-
template<typename OtherT>__host__ __device__ thrust::device_ptr::device_ptr(const device_ptr < OtherT > & other)
device_ptr's
copy constructor allows copying from another device_ptr with related type.- Parameters
other
: Thedevice_ptr
to copy from.
-
template<typename OtherT>__host__ __device__ device_ptr& thrust::device_ptr::operator=(const device_ptr < OtherT > & other)
device_ptr's
assignment operator allows assigning from anotherdevice_ptr
with related type.- Return
*this
- Parameters
other
: The otherdevice_ptr
to copy from.