19 #include <thrust/device_vector.h> 20 #include <thrust/mr/allocator.h> 21 #include <thrust/mr/memory_resource.h> 34 template <
typename Po
inter>
36 using base = thrust::mr::memory_resource<Pointer>;
50 std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT)
final {
53 reinterpret_cast<typename thrust::detail::pointer_traits<Pointer>::element_type*
>(
61 void do_deallocate(Pointer p, std::size_t bytes, std::size_t alignment)
final {
64 reinterpret_cast<int8_t*>(thrust::detail::pointer_traits<Pointer>::get(p)),
86 pointer<void, thrust::device_system_tag, thrust::use_default, thrust::use_default>;
91 thrust::device_ptr_memory_resource<DataMgrMemoryResource<Pointer>>;
94 : data_mgr_mem_rsrc_(thrust_allocator), device_rsrc_(&data_mgr_mem_rsrc_) {}
99 : data_mgr_mem_rsrc_(other.data_mgr_mem_rsrc_), device_rsrc_(&data_mgr_mem_rsrc_) {}
102 : data_mgr_mem_rsrc_(
std::move(other.data_mgr_mem_rsrc_))
103 , device_rsrc_(&data_mgr_mem_rsrc_) {}
106 assert(data_mgr_mem_rsrc_.getThrustAllocator() ==
135 template <
typename T>
138 public thrust::mr::allocator<T, detail::TypedThrustAllocatorState::DeviceResource> {
140 thrust::mr::allocator<T, detail::TypedThrustAllocatorState::DeviceResource>;
144 : detail::TypedThrustAllocatorState(thrust_allocator),
Base(&device_rsrc_) {}
150 : detail::TypedThrustAllocatorState(other),
Base(&device_rsrc_) {}
153 : detail::TypedThrustAllocatorState(
std::move(other)),
Base(&device_rsrc_) {}
163 template <
typename T>
DataMgrMemoryResource(const DataMgrMemoryResource &other)
void do_deallocate(Pointer p, std::size_t bytes, std::size_t alignment) final
Overrides a pure virtual function defined in thrust::mr::memory_resource to deallocate memory from a ...
int8_t * allocate(std::ptrdiff_t num_bytes)
DeviceResource device_rsrc_
__host__ __device__ void operator=(const TypedThrustAllocator< T > &other)
void deallocate(int8_t *ptr, size_t num_bytes)
Pointer do_allocate(std::size_t bytes, std::size_t alignment=THRUST_MR_DEFAULT_ALIGNMENT) final
Overrides a pure virtual function defined in thrust::mr::memory_resource to allocate from a ThrustAll...
Manages the underlying state of a TypedThrustAllocator. The state consists of: DataMgrMemoryResource:...
A thrust memory resource wrapped around a Data_Namespace::ThrustAllocator that allocates memory via D...
__host__ __device__ void operator=(const TypedThrustAllocatorState &other)
thrust::pointer< void, thrust::device_system_tag, thrust::use_default, thrust::use_default > Pointer
thrust::mr::allocator< T, detail::TypedThrustAllocatorState::DeviceResource > Base
~DataMgrMemoryResource() final=default
TypedThrustAllocatorState(ThrustAllocator &thrust_allocator)
__host__ __device__ const ThrustAllocator * getThrustAllocator() const
DataMgrMemoryResource(ThrustAllocator &thrust_allocator)
a Templated version of Data_Namespace::ThrustAllocator that can be used as a custom allocator in thru...
ThrustAllocator * thrust_allocator_
TypedThrustAllocatorState(TypedThrustAllocatorState &&other)
TypedThrustAllocator(ThrustAllocator &thrust_allocator)
DataMgrMemoryResource< Pointer > data_mgr_mem_rsrc_
TypedThrustAllocatorState(const TypedThrustAllocatorState &other)
thrust::device_vector< T, TypedThrustAllocator< T > > ThrustAllocatorDeviceVector
TypedThrustAllocator(TypedThrustAllocator &&other)
thrust::device_ptr_memory_resource< DataMgrMemoryResource< Pointer > > DeviceResource
thrust::mr::memory_resource< Pointer > base
TypedThrustAllocator(const TypedThrustAllocator &other)