Class thrust::device_malloc_allocator

device_malloc_allocator is a device memory allocator that employs the device_malloc function for allocation.

device_malloc_allocator is deprecated in favor of thrust::mr memory resource-based allocators.

See:

#include <thrust/device_malloc_allocator.h>
template <typename T> class thrust::device_malloc_allocator { public:  typedef see below value_type;
  typedef see below pointer;
  typedef see below const_pointer;
  typedef see below reference;
  typedef see below const_reference;
  typedef see below size_type;
  typedef see below difference_type;
  template <typename U>   struct rebind;
  _CCCL_HOST_DEVICE   device_malloc_allocator();
  _CCCL_HOST_DEVICE   ~device_malloc_allocator();
  _CCCL_HOST_DEVICE   device_malloc_allocator(device_malloc_allocator const &);
  template <typename U>   _CCCL_HOST_DEVICE   device_malloc_allocator(device_malloc_allocator< U > const &);
  device_malloc_allocator &   operator=(const device_malloc_allocator &) = default;
  _CCCL_HOST_DEVICE pointer   address(reference r);
  _CCCL_HOST_DEVICE const_pointer   address(const_reference r);
  _CCCL_HOST pointer   allocate(size_type cnt,     const_pointer = const_pointer(static_cast< T * >(0)));
  _CCCL_HOST void   deallocate(pointer p,     size_type cnt);
  size_type   max_size() const;
  _CCCL_HOST_DEVICE bool   operator==(device_malloc_allocator const &) const;
  _CCCL_HOST_DEVICE bool   operator!=(device_malloc_allocator const & a) const; };

Member Classes

Struct thrust::device_malloc_allocator::rebind

Member Types

Typedef thrust::device_malloc_allocator::value_type

typedef Tvalue_type; Type of element allocated, T.

Typedef thrust::device_malloc_allocator::pointer

typedef device_ptr< T >pointer; Pointer to allocation, device_ptr<T>.

Typedef thrust::device_malloc_allocator::const_pointer

typedef device_ptr< const T >const_pointer; const pointer to allocation, device_ptr<const T>.

Typedef thrust::device_malloc_allocator::reference

typedef device_reference< T >reference; Reference to allocated element, device_reference<T>.

Typedef thrust::device_malloc_allocator::const_reference

typedef device_reference< const T >const_reference; const reference to allocated element, device_reference<const T>.

Typedef thrust::device_malloc_allocator::size_type

typedef std::size_tsize_type; Type of allocation size, std::size_t.

Typedef thrust::device_malloc_allocator::difference_type

typedef pointer::difference_typedifference_type; Type of allocation difference, pointer::difference_type.

Member Functions

Function thrust::device_malloc_allocator::device_malloc_allocator

_CCCL_HOST_DEVICE device_malloc_allocator(); No-argument constructor has no effect.

Function thrust::device_malloc_allocator::~device_malloc_allocator

_CCCL_HOST_DEVICE ~device_malloc_allocator(); No-argument destructor has no effect.

Function thrust::device_malloc_allocator::device_malloc_allocator

_CCCL_HOST_DEVICE device_malloc_allocator(device_malloc_allocator const &); Copy constructor has no effect.

Function thrust::device_malloc_allocator::device_malloc_allocator

template <typename U> _CCCL_HOST_DEVICE device_malloc_allocator(device_malloc_allocator< U > const &); Constructor from other device_malloc_allocator has no effect.

Function thrust::device_malloc_allocator::operator=

device_malloc_allocator & operator=(const device_malloc_allocator &) = default;

Function thrust::device_malloc_allocator::address

_CCCL_HOST_DEVICE pointer address(reference r); Returns the address of an allocated object.

Returns: &r.

Function thrust::device_malloc_allocator::address

_CCCL_HOST_DEVICE const_pointer address(const_reference r); Returns the address an allocated object.

Returns: &r.

Function thrust::device_malloc_allocator::allocate

_CCCL_HOST pointer allocate(size_type cnt,   const_pointer = const_pointer(static_cast< T * >(0))); Allocates storage for cnt objects.

Note: Memory allocated by this function must be deallocated with deallocate.

Function Parameters: cnt: The number of objects to allocate.

Returns: A pointer to uninitialized storage for cnt objects.

Function thrust::device_malloc_allocator::deallocate

_CCCL_HOST void deallocate(pointer p,   size_type cnt); Deallocates storage for objects allocated with allocate.

Note: Memory deallocated by this function must previously have been allocated with allocate.

Function Parameters:

  • p A pointer to the storage to deallocate.
  • cnt The size of the previous allocation.

Function thrust::device_malloc_allocator::max_size

size_type max_size() const; Returns the largest value n for which allocate(n) might succeed.

Returns: The largest value n for which allocate(n) might succeed.

Function thrust::device_malloc_allocator::operator==

_CCCL_HOST_DEVICE bool operator==(device_malloc_allocator const &) const; Compares against another device_malloc_allocator for equality.

Returns: true

Function thrust::device_malloc_allocator::operator!=

_CCCL_HOST_DEVICE bool operator!=(device_malloc_allocator const & a) const; Compares against another device_malloc_allocator for inequality.

Returns: false