19 #include <rmm/detail/aligned.hpp>
21 #include <cuda/memory_resource>
118 return do_allocate(bytes, stream);
139 do_deallocate(ptr, bytes, stream);
157 return do_is_equal(other);
172 void*
allocate(std::size_t bytes, std::size_t alignment)
174 return do_allocate(rmm::detail::align_up(bytes, alignment),
cuda_stream_view{});
190 void deallocate(
void* ptr, std::size_t bytes, std::size_t alignment)
192 do_deallocate(ptr, rmm::detail::align_up(bytes, alignment),
cuda_stream_view{});
210 return do_allocate(rmm::detail::align_up(bytes, alignment), stream);
227 return do_allocate(bytes, stream);
246 std::size_t alignment,
249 do_deallocate(ptr, rmm::detail::align_up(bytes, alignment), stream);
267 do_deallocate(ptr, bytes, stream);
279 return do_is_equal(other);
291 return !do_is_equal(other);
319 return do_get_mem_info(stream);
355 virtual void do_deallocate(
void* ptr, std::size_t bytes,
cuda_stream_view stream) = 0;
373 return this == &other;
384 [[nodiscard]]
virtual std::pair<std::size_t, std::size_t> do_get_mem_info(
387 static_assert(cuda::mr::async_resource_with<device_memory_resource, cuda::mr::device_accessible>);
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
std::pair< std::size_t, std::size_t > get_mem_info(cuda_stream_view stream) const
Queries the amount of free and total memory for the resource.
Definition: device_memory_resource.hpp:317
virtual bool supports_streams() const noexcept=0
Query whether the resource supports use of non-null CUDA streams for allocation/deallocation.
void deallocate_async(void *ptr, std::size_t bytes, cuda_stream_view stream)
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:265
friend void get_property(device_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: device_memory_resource.hpp:327
device_memory_resource(device_memory_resource &&) noexcept=default
Default move constructor.
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, std::size_t alignment)
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:190
void * allocate(std::size_t bytes, std::size_t alignment)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:172
void * allocate_async(std::size_t bytes, cuda_stream_view stream)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:225
bool operator==(device_memory_resource const &other) const noexcept
Comparison operator with another device_memory_resource.
Definition: device_memory_resource.hpp:277
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
virtual bool supports_get_mem_info() const noexcept=0
Query whether the resource supports the get_mem_info API.
void deallocate_async(void *ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view stream)
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:244
bool operator!=(device_memory_resource const &other) const noexcept
Comparison operator with another device_memory_resource.
Definition: device_memory_resource.hpp:289
device_memory_resource(device_memory_resource const &)=default
Default copy constructor.
void * allocate_async(std::size_t bytes, std::size_t alignment, cuda_stream_view stream)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:208
bool is_equal(device_memory_resource const &other) const noexcept
Compare this resource to another.
Definition: device_memory_resource.hpp:155