25 #include <type_traits>
114 template <
typename T,
typename U>
115 bool operator==(polymorphic_allocator<T>
const& lhs, polymorphic_allocator<U>
const& rhs)
117 return lhs.resource()->is_equal(*rhs.resource());
120 template <
typename T,
typename U>
121 bool operator!=(polymorphic_allocator<T>
const& lhs, polymorphic_allocator<U>
const& rhs)
123 return not(lhs == rhs);
148 template <
typename Allocator>
152 typename std::allocator_traits<Allocator>::value_type;
167 : alloc_{allocator}, stream_{
stream}
179 template <
typename OtherAllocator>
190 template <
typename T>
193 Allocator>::template rebind_alloc<T>>;
231 template <
typename A,
typename O>
232 bool operator==(stream_allocator_adaptor<A>
const& lhs, stream_allocator_adaptor<O>
const& rhs)
234 return lhs.underlying_allocator() == rhs.underlying_allocator();
237 template <
typename A,
typename O>
238 bool operator!=(stream_allocator_adaptor<A>
const& lhs, stream_allocator_adaptor<O>
const& rhs)
240 return not(lhs == rhs);
253 template <
typename Allocator>
254 auto make_stream_allocator_adaptor(Allocator
const& allocator, cuda_stream_view stream)
256 return stream_allocator_adaptor<Allocator>{allocator, stream};
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:41
Base class for all libcudf device memory allocation.
Definition: device_memory_resource.hpp:89
void * allocate(std::size_t bytes, cuda_stream_view stream=cuda_stream_view{})
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:116
void deallocate(void *ptr, std::size_t bytes, cuda_stream_view stream=cuda_stream_view{})
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:137
A stream ordered Allocator using a rmm::mr::device_memory_resource to satisfy (de)allocations.
Definition: polymorphic_allocator.hpp:44
device_memory_resource * resource() const noexcept
Returns pointer to the underlying rmm::mr::device_memory_resource.
Definition: polymorphic_allocator.hpp:107
T value_type
T, the value type of objects allocated by this allocator.
Definition: polymorphic_allocator.hpp:46
polymorphic_allocator(device_memory_resource *mr)
Construct a polymorphic_allocator using the provided memory resource.
Definition: polymorphic_allocator.hpp:61
polymorphic_allocator()=default
Construct a polymorphic_allocator using the return value of rmm::mr::get_current_device_resource() as...
void deallocate(value_type *ptr, std::size_t num, cuda_stream_view stream)
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:82
polymorphic_allocator(polymorphic_allocator< U > const &other) noexcept
Construct a polymorphic_allocator using other.resource() as the underlying memory resource.
Definition: polymorphic_allocator.hpp:71
Adapts a stream ordered allocator to provide a standard Allocator interface.
Definition: polymorphic_allocator.hpp:149
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:203
typename std::allocator_traits< Allocator >::value_type value_type
Definition: polymorphic_allocator.hpp:153
void deallocate(value_type *ptr, std::size_t num)
Deallocates storage pointed to by ptr using the underlying allocator on stream().
Definition: polymorphic_allocator.hpp:214
Allocator underlying_allocator() const noexcept
The underlying allocator.
Definition: polymorphic_allocator.hpp:224
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:166
stream_allocator_adaptor(stream_allocator_adaptor< OtherAllocator > const &other)
Construct a stream_allocator_adaptor using other.underlying_allocator() and other....
Definition: polymorphic_allocator.hpp:180
cuda_stream_view stream() const noexcept
The stream on which calls to the underlying allocator are made.
Definition: polymorphic_allocator.hpp:219
bool operator==(cuda_stream_view lhs, cuda_stream_view rhs)
Equality comparison operator for streams.
Definition: cuda_stream_view.hpp:177
bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs)
Inequality comparison operator for streams.
Definition: cuda_stream_view.hpp:189
device_memory_resource * get_current_device_resource()
Get the memory resource for the current device.
Definition: per_device_resource.hpp:207
Management of per-device device_memory_resources.
Rebinds the allocator to the specified type.
Definition: polymorphic_allocator.hpp:191