10 #include <rmm/detail/export.hpp>
14 #include <cuda/memory_resource>
19 namespace RMM_NAMESPACE {
70 : mr_(other.get_upstream_resource())
111 mutable cuda::mr::any_resource<cuda::mr::device_accessible> mr_{
126 template <
typename T,
typename U>
144 template <
typename T,
typename U>
147 return not(lhs == rhs);
172 template <
typename Allocator>
176 typename std::allocator_traits<Allocator>::value_type;
191 : alloc_{allocator}, stream_{stream}
203 template <
typename OtherAllocator>
214 template <
typename T>
217 Allocator>::template rebind_alloc<T>>;
240 alloc_.deallocate(ptr, num, stream());
269 template <
typename A,
typename O>
286 template <
typename A,
typename O>
289 return not(lhs == rhs);
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:28
A stream ordered Allocator using a device_async_resource_ref to satisfy (de)allocations.
Definition: polymorphic_allocator.hpp:41
T value_type
T, the value type of objects allocated by this allocator.
Definition: polymorphic_allocator.hpp:43
rmm::device_async_resource_ref get_upstream_resource() const noexcept
rmm::device_async_resource_ref to the upstream resource
Definition: polymorphic_allocator.hpp:105
polymorphic_allocator()=default
Construct a polymorphic_allocator using the return value of rmm::mr::get_current_device_resource_ref(...
void deallocate(value_type *ptr, std::size_t num, cuda_stream_view stream) noexcept
Deallocates storage pointed to by ptr.
Definition: polymorphic_allocator.hpp:97
value_type * allocate(std::size_t num, cuda_stream_view stream)
Allocates storage for num objects of type T using the underlying memory resource.
Definition: polymorphic_allocator.hpp:81
polymorphic_allocator(cuda::mr::any_resource< cuda::mr::device_accessible > mr)
Construct a polymorphic_allocator using the provided memory resource.
Definition: polymorphic_allocator.hpp:58
polymorphic_allocator(polymorphic_allocator< U > const &other) noexcept
Construct a polymorphic_allocator using the underlying memory resource of other.
Definition: polymorphic_allocator.hpp:69
Adapts a stream ordered allocator to provide a standard Allocator interface.
Definition: polymorphic_allocator.hpp:173
value_type * allocate(std::size_t num)
Allocates storage for num objects of type T using the underlying allocator on stream().
Definition: polymorphic_allocator.hpp:227
typename std::allocator_traits< Allocator >::value_type value_type
Definition: polymorphic_allocator.hpp:177
Allocator underlying_allocator() const noexcept
The underlying allocator.
Definition: polymorphic_allocator.hpp:251
stream_allocator_adaptor(Allocator const &allocator, cuda_stream_view stream)
Construct a stream_allocator_adaptor using a as the underlying allocator.
Definition: polymorphic_allocator.hpp:190
stream_allocator_adaptor(stream_allocator_adaptor< OtherAllocator > const &other)
Construct a stream_allocator_adaptor using other.underlying_allocator() and other....
Definition: polymorphic_allocator.hpp:204
void deallocate(value_type *ptr, std::size_t num) noexcept
Deallocates storage pointed to by ptr using the underlying allocator on stream().
Definition: polymorphic_allocator.hpp:238
cuda_stream_view stream() const noexcept
The stream on which calls to the underlying allocator are made.
Definition: polymorphic_allocator.hpp:246
bool operator==(stream_allocator_adaptor< A > const &lhs, stream_allocator_adaptor< O > const &rhs)
Compare two stream_allocator_adaptors for equality.
Definition: polymorphic_allocator.hpp:270
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
bool operator!=(stream_allocator_adaptor< A > const &lhs, stream_allocator_adaptor< O > const &rhs)
Compare two stream_allocator_adaptors for inequality.
Definition: polymorphic_allocator.hpp:287
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.
Rebinds the allocator to the specified type.
Definition: polymorphic_allocator.hpp:215