21 #include <rmm/detail/error.hpp>
73 void* do_allocate(std::size_t bytes, [[maybe_unused]]
cuda_stream_view stream)
override
77 if (bytes == 0) {
return nullptr; }
80 RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes));
94 void do_deallocate(
void* ptr,
95 [[maybe_unused]] std::size_t bytes,
96 [[maybe_unused]] cuda_stream_view stream)
override
98 RMM_ASSERT_CUDA_SUCCESS(cudaFree(ptr));
111 [[nodiscard]]
bool do_is_equal(device_memory_resource
const& other)
const noexcept
override
113 return dynamic_cast<managed_memory_resource const*
>(&other) !=
nullptr;
124 [[nodiscard]] std::pair<std::size_t, std::size_t> do_get_mem_info(
125 [[maybe_unused]] cuda_stream_view stream)
const override
127 std::size_t free_size{};
128 std::size_t total_size{};
129 RMM_CUDA_TRY(cudaMemGetInfo(&free_size, &total_size));
130 return std::make_pair(free_size, total_size);
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
device_memory_resource derived class that uses cudaMallocManaged/Free for allocation/deallocation.
Definition: managed_memory_resource.hpp:35
managed_memory_resource(managed_memory_resource &&)=default
Default move constructor.
bool supports_get_mem_info() const noexcept override
Query whether the resource supports the get_mem_info API.
Definition: managed_memory_resource.hpp:59
bool supports_streams() const noexcept override
Query whether the resource supports use of non-null streams for allocation/deallocation.
Definition: managed_memory_resource.hpp:52
managed_memory_resource & operator=(managed_memory_resource &&)=default
Default move assignment operator.
managed_memory_resource & operator=(managed_memory_resource const &)=default
Default copy assignment operator.
managed_memory_resource(managed_memory_resource const &)=default
Default copy constructor.