Class thrust::device_ptr_memory_resource
Memory resource adaptor that turns any memory resource that returns a fancy with the same tag as device_ptr
, and adapts it to a resource that returns a device_ptr
.
Inherits From: thrust::mr::memory_resource< device_ptr< void > >
#include <thrust/device_allocator.h>
template <typename Upstream> class thrust::device_ptr_memory_resource { public:
/* Inherited from thrust::mr::memory_resource< device_ptr< void > >
*/ typedef see below pointer;
_CCCL_HOST device_ptr_memory_resource();
_CCCL_HOST device_ptr_memory_resource(Upstream * upstream);
virtual _CCCL_NODISCARD virtual _CCCL_HOST pointer do_allocate(std::size_t bytes, std::size_t alignment = alignof(std::max_align_t)) override;
virtual _CCCL_HOST void do_deallocate(pointer p, std::size_t bytes, std::size_t alignment) override;
/* Inherited from thrust::mr::memory_resource< device_ptr< void > >
*/ virtual ~memory_resource() = default;
/* Inherited from thrust::mr::memory_resource< device_ptr< void > >
*/ _CCCL_NODISCARD pointer allocate(std::size_t bytes, std::size_t alignment = alignof(std::max_align_t));
/* Inherited from thrust::mr::memory_resource< device_ptr< void > >
*/ void deallocate(pointer p, std::size_t bytes, std::size_t alignment = alignof(std::max_align_t));
/* Inherited from thrust::mr::memory_resource< device_ptr< void > >
*/ _CCCL_HOST_DEVICE bool is_equal(const memory_resource & other) const;
/* Inherited from thrust::mr::memory_resource< device_ptr< void > >
*/ virtual _CCCL_HOST_DEVICE bool do_is_equal(const memory_resource & other) const; };
Member Functions
Function thrust::device_ptr_memory_resource::device_ptr_memory_resource
_CCCL_HOST device_ptr_memory_resource();
Initialize the adaptor with the global instance of the upstream resource. Obtains the global instance by calling get_global_resource
.
Function thrust::device_ptr_memory_resource::device_ptr_memory_resource
_CCCL_HOST device_ptr_memory_resource(Upstream * upstream);
Initialize the adaptor with an upstream resource.
Function Parameters: upstream
: the upstream memory resource to adapt.
Function thrust::device_ptr_memory_resource::do_allocate
virtual _CCCL_NODISCARD virtual _CCCL_HOST pointer do_allocate(std::size_t bytes, std::size_t alignment = alignof(std::max_align_t)) override;
Allocates memory of size at least bytes
and alignment at least alignment
.
Function Parameters:
bytes
size, in bytes, that is requested from this allocationalignment
alignment that is requested from this allocation
Returns: A pointer to void to the newly allocated memory.
Exceptions: thrust::bad_alloc
: when no memory with requested size and alignment can be allocated.
Implements: do_allocate
Function thrust::device_ptr_memory_resource::do_deallocate
virtual _CCCL_HOST void do_deallocate(pointer p, std::size_t bytes, std::size_t alignment) override;
Deallocates memory pointed to by p
.
Function Parameters:
p
pointer to be deallocatedbytes
the size of the allocation. This must be equivalent to the value ofbytes
that was passed to the allocation function that returnedp
.alignment
the size of the allocation. This must be equivalent to the value ofalignment
that was passed to the allocation function that returnedp
.
Implements: do_deallocate