thrust::device_ptr#
-
template<typename T>
class device_ptr : public thrust::pointer<T, thrust::device_system_tag, thrust::device_reference<T>, thrust::device_ptr<T>># device_ptr
is a pointer-like object which points to an object that resides in memory associated with the device system.device_ptr
has pointer semantics: it may be dereferenced safely from anywhere, including the host, and may be manipulated with pointer arithmetic.device_ptr
can be created with device_new, device_malloc, device_malloc_allocator, device_allocator, or device_pointer_cast, or by explicitly calling its constructor with a raw pointer.The raw pointer contained in a
device_ptr
may be obtained viaget
member function or the raw_pointer_cast free function.Algorithms operating on
device_ptr
types will automatically be dispatched to the device system.See also
See also
See also
See also
See also
See also
Note
device_ptr
is not a smart pointer; it is the programmer’s responsibility to deallocate memory pointed to bydevice_ptr
.Public Types
-
using raw_pointer = typename super_t::base_type#
The type of the raw pointer
-
using base_type = Base#
The type of iterator this
iterator_adaptor's
adapts
.
Public Functions
-
device_ptr() = default#
-
inline device_ptr(std::nullptr_t)#
Construct a null
device_ptr
.This constructor accepts a
std::nullptr_t
value.- Post:
get() == nullptr
.
-
template<typename U>
inline explicit device_ptr(U *ptr)# Construct a
device_ptr
from a raw pointer which is convertible toT*
.- Template Parameters:
U – A type whose pointer is convertible to
T*
.- Parameters:
ptr – A raw pointer to a
U
in device memory to construct from.- Pre:
std::is_convertible_v<U*, T*> == true
.- Pre:
ptr
points to a location in device memory.- Post:
get() == nullptr
.
-
template<typename U>
inline device_ptr(device_ptr<U> const &other)# Copy construct a
device_ptr
from anotherdevice_ptr
whose pointer type is convertible toT*
.- Template Parameters:
U – A type whose pointer is convertible to
T*
.- Parameters:
other – A
device_ptr
to aU
to construct from.- Pre:
std::is_convertible_v<U*, T*> == true
.- Post:
get() == other.get()
.
-
template<typename U>
inline device_ptr &operator=( - device_ptr<U> const &other,
Set this
device_ptr
to point to the same object as anotherdevice_ptr
whose pointer type is convertible toT*
.- Template Parameters:
U – A type whose pointer is convertible to
T*
.- Parameters:
other – A
device_ptr
to aU
to assign from.- Pre:
std::is_convertible_v<U*, T*> == true
.- Post:
get() == other.get()
.- Returns:
*this
.
-
inline device_ptr &operator=(std::nullptr_t)#
Set this
device_ptr
to null.This operator accepts a
std::nullptr_t
value.- Post:
get() == nullptr
.- Returns:
*this
.
-
inline T *get() const#
get
returns thispointer's
encapsulated raw pointer.- Returns:
This
pointer's
raw pointer.
-
inline explicit operator bool() const#
-
inline Base const &base() const#
- Returns:
A
const
reference to theBase
iterator thisiterator_adaptor
adapts.
-
using raw_pointer = typename super_t::base_type#