thrust::device_allocator
Defined in thrust/device_allocator.h
-
template<typename T>
class device_allocator : public thrust::mr::stateless_resource_allocator<T, device_ptr_memory_resource<device_memory_resource>> An allocator which creates new elements in memory accessible by devices.
Public Types
-
using void_pointer = typename MR::pointer
The pointer to void type of this allocator.
-
using pointer = typename thrust::detail::pointer_traits<void_pointer>::template rebind<T>::other
The pointer type allocated by this allocator. Equivaled to the pointer type of
MR
rebound toT
.
-
using const_pointer = typename thrust::detail::pointer_traits<void_pointer>::template rebind<const T>::other
The pointer to const type. Equivalent to a pointer type of
MR
rebound toconst T
.
-
using reference = typename thrust::detail::pointer_traits<pointer>::reference
The reference to the type allocated by this allocator. Supports smart references.
-
using const_reference = typename thrust::detail::pointer_traits<const_pointer>::reference
The const reference to the type allocated by this allocator. Supports smart references.
-
using difference_type = typename thrust::detail::pointer_traits<pointer>::difference_type
The difference type between pointers allocated by this allocator.
-
using propagate_on_container_copy_assignment = detail::true_type
Specifies that the allocator shall be propagated on container copy assignment.
-
using propagate_on_container_move_assignment = detail::true_type
Specifies that the allocator shall be propagated on container move assignment.
-
using propagate_on_container_swap = detail::true_type
Specifies that the allocator shall be propagated on container swap.
Public Functions
-
inline device_allocator()
Default constructor has no effect.
-
inline device_allocator(const device_allocator &other)
Copy constructor has no effect.
-
template<typename U>
inline device_allocator(const device_allocator<U> &other) Constructor from other
device_allocator
has no effect.
-
device_allocator &operator=(const device_allocator&) = default
-
inline ~device_allocator()
Destructor has no effect.
-
inline size_type max_size() const
Calculates the maximum number of elements allocated by this allocator.
- Returns
the maximum value of
std::size_t
, divided by the size ofT
.
-
inline pointer allocate(size_type n)
Allocates objects of type
T
.- Parameters
n – number of elements to allocate
- Returns
a pointer to the newly allocated storage.
-
inline void deallocate(pointer p, size_type n) noexcept
Deallocates objects of type
T
.- Parameters
p – pointer returned by a previous call to
allocate
n – number of elements, passed as an argument to the
allocate
call that producedp
-
inline device_ptr_memory_resource<device_memory_resource> *resource() const
Extracts the memory resource used by this allocator.
- Returns
the memory resource used by this allocator.
-
template<typename U>
struct rebind The
rebind
metafunction provides the type of adevice_allocator
instantiated with another type.- Template Parameters
U – the other type to use for instantiation.
Public Types
-
using other = device_allocator<U>
The alias
other
gives the type of the rebounddevice_allocator
.
-
using void_pointer = typename MR::pointer