Template Class device_ptr

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>
class device_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 its get method or the raw_pointer_cast free function.

Note

device_ptr is not a smart pointer; it is the programmer’s responsibility to deallocate memory pointed to by device_ptr.

See

device_malloc

See

device_new

See

device_pointer_cast

See

raw_pointer_cast

Public Functions

__host__ __device__ thrust::device_ptr::device_ptr()

device_ptr's null constructor initializes its raw pointer to 0.

template<typename OtherT>__host__ __device__ thrust::device_ptr::device_ptr(OtherT * ptr)

device_ptr's copy constructor is templated to allow copying to a device_ptr<const T> from a T *.

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

template<typename OtherT>__host__ __device__ device_ptr& thrust::device_ptr::operator=(const device_ptr < OtherT > & other)

device_ptr's assignment operator allows assigning from another device_ptr with related type.

Return

*this

Parameters