thrust::device_ptr_memory_resource
Defined in thrust/device_allocator.h
- 
template<typename Upstream>
 class device_ptr_memory_resource : public thrust::mr::memory_resource<device_ptr<void>>
- 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.- Public Types - 
using pointer = device_ptr<void>
- Alias for the template parameter. 
 - Public Functions - 
inline device_ptr_memory_resource()
- Initialize the adaptor with the global instance of the upstream resource. Obtains the global instance by calling - get_global_resource.
 - 
inline device_ptr_memory_resource(Upstream *upstream)
- Initialize the adaptor with an upstream resource. - Parameters
- upstream – the upstream memory resource to adapt. 
 
 - 
inline virtual pointer do_allocate(std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) override
- Allocates memory of size at least - bytesand alignment at least- alignment.- Parameters
- bytes – size, in bytes, that is requested from this allocation 
- alignment – alignment that is requested from this allocation 
 
- Throws
- thrust::bad_alloc – when no memory with requested size and alignment can be allocated. 
- Returns
- A pointer to void to the newly allocated memory. 
 
 - 
inline virtual void do_deallocate(pointer p, std::size_t bytes, std::size_t alignment) override
- Deallocates memory pointed to by - p.- Parameters
- p – pointer to be deallocated 
- bytes – the size of the allocation. This must be equivalent to the value of - bytesthat was passed to the allocation function that returned- p.
- alignment – the size of the allocation. This must be equivalent to the value of - alignmentthat was passed to the allocation function that returned- p.
 
 
 - 
inline pointer allocate(std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT)
- Allocates memory of size at least - bytesand alignment at least- alignment.- Parameters
- bytes – size, in bytes, that is requested from this allocation 
- alignment – alignment that is requested from this allocation 
 
- Throws
- thrust::bad_alloc – when no memory with requested size and alignment can be allocated. 
- Returns
- A pointer to void to the newly allocated memory. 
 
 - 
inline void deallocate(pointer p, std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) noexcept
- Deallocates memory pointed to by - p.- Parameters
- p – pointer to be deallocated 
- bytes – the size of the allocation. This must be equivalent to the value of - bytesthat was passed to the allocation function that returned- p.
- alignment – the alignment of the allocation. This must be equivalent to the value of - alignmentthat was passed to the allocation function that returned- p.
 
 
 - 
inline bool is_equal(const memory_resource &other) const noexcept
- Compares this resource to the other one. The default implementation uses identity comparison, which is often the right thing to do and doesn’t require RTTI involvement. - Parameters
- other – the other resource to compare this resource to 
- Returns
- whether the two resources are equivalent. 
 
 - 
inline virtual bool do_is_equal(const memory_resource &other) const noexcept
- Compares this resource to the other one. The default implementation uses identity comparison, which is often the right thing to do and doesn’t require RTTI involvement. - Parameters
- other – the other resource to compare this resource to 
- Returns
- whether the two resources are equivalent. 
 
 
- 
using pointer = device_ptr<void>