10 #include <rmm/detail/exec_check_disable.hpp>
11 #include <rmm/detail/export.hpp>
12 #include <rmm/detail/thrust_namespace.h>
16 #include <cuda/memory_resource>
17 #include <thrust/device_malloc_allocator.h>
18 #include <thrust/device_ptr.h>
19 #include <thrust/memory.h>
21 namespace RMM_NAMESPACE {
44 using Base = thrust::device_malloc_allocator<T>;
63 RMM_EXEC_CHECK_DISABLE
72 RMM_EXEC_CHECK_DISABLE
82 RMM_EXEC_CHECK_DISABLE
84 : _stream{stream}, _mr(std::move(mr))
93 RMM_EXEC_CHECK_DISABLE
95 :
Base(other), _stream{other._stream}, _mr(other._mr), _device{other._device}
104 RMM_EXEC_CHECK_DISABLE
106 :
Base(std::move(other)),
107 _stream{other._stream},
108 _mr(std::move(other._mr)),
109 _device{other._device}
124 RMM_EXEC_CHECK_DISABLE
125 template <typename U>
127 : _mr(other.resource()), _stream{other.
stream()}, _device{other._device}
140 return thrust::device_pointer_cast(
154 return _mr.deallocate(
177 cuda::mr::device_accessible) noexcept
183 mutable cuda::mr::any_resource<cuda::mr::device_accessible> _mr{
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:28
An allocator compatible with Thrust containers and algorithms using a device_async_resource_ref for m...
Definition: thrust_allocator_adaptor.hpp:42
thrust_allocator(cuda_stream_view stream, cuda::mr::any_resource< cuda::mr::device_accessible > mr)
Constructs a thrust_allocator using a device memory resource and stream.
Definition: thrust_allocator_adaptor.hpp:83
typename Base::pointer pointer
The pointer type.
Definition: thrust_allocator_adaptor.hpp:45
void deallocate(pointer ptr, size_type num) noexcept
Deallocates objects of type T
Definition: thrust_allocator_adaptor.hpp:151
thrust_allocator(thrust_allocator const &other)
Copy constructor. Copies the resource pointer and stream.
Definition: thrust_allocator_adaptor.hpp:94
thrust_allocator(thrust_allocator &&other) noexcept
Move constructor. Moves the resource pointer and stream.
Definition: thrust_allocator_adaptor.hpp:105
pointer allocate(size_type num)
Allocate objects of type T
Definition: thrust_allocator_adaptor.hpp:137
cuda_stream_view stream() const noexcept
The stream used by this allocator.
Definition: thrust_allocator_adaptor.hpp:169
rmm::device_async_resource_ref get_upstream_resource() const noexcept
rmm::device_async_resource_ref to the upstream resource
Definition: thrust_allocator_adaptor.hpp:161
thrust_allocator()
Default constructor creates an allocator using the default memory resource and default stream.
Definition: thrust_allocator_adaptor.hpp:64
thrust_allocator & operator=(thrust_allocator const &)=default
Default copy assignment operator.
typename Base::size_type size_type
The size type.
Definition: thrust_allocator_adaptor.hpp:46
thrust::device_malloc_allocator< T > Base
The base type of this allocator.
Definition: thrust_allocator_adaptor.hpp:44
friend void get_property(thrust_allocator const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: thrust_allocator_adaptor.hpp:176
thrust_allocator(cuda_stream_view stream)
Constructs a thrust_allocator using the default device memory resource and specified stream.
Definition: thrust_allocator_adaptor.hpp:73
thrust_allocator & operator=(thrust_allocator &&) noexcept=default
Default move assignment operator.
cuda_device_id get_current_cuda_device()
Returns a cuda_device_id for the current device.
device_async_resource_ref get_current_device_resource_ref()
Get the device_async_resource_ref for the current device.
Definition: per_device_resource.hpp:223
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
Alias for a cuda::mr::resource_ref with the property cuda::mr::device_accessible.
Definition: resource_ref.hpp:30
static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT
Default alignment used for CUDA memory allocation.
Definition: aligned.hpp:25
Management of per-device memory resources.
RAII class that sets the current CUDA device to the specified device on construction and restores the...
Definition: cuda_device.hpp:115
Provides the type of a thrust_allocator instantiated with another type.
Definition: thrust_allocator_adaptor.hpp:55