18 #include <rmm/mr/device/device_memory_resource.hpp>
41 using allocate_callback_t = std::function<
void*(std::size_t, cuda_stream_view,
void*)>;
59 using deallocate_callback_t = std::function<void(
void*, std::size_t, cuda_stream_view,
void*)>;
83 deallocate_callback_t deallocate_callback,
84 void* allocate_callback_arg =
nullptr,
85 void* deallocate_callback_arg =
nullptr) noexcept
86 : allocate_callback_(allocate_callback),
87 deallocate_callback_(deallocate_callback),
88 allocate_callback_arg_(allocate_callback_arg),
89 deallocate_callback_arg_(deallocate_callback_arg)
103 return allocate_callback_(bytes, stream, allocate_callback_arg_);
106 void do_deallocate(
void* ptr, std::size_t bytes,
cuda_stream_view stream)
override
108 deallocate_callback_(ptr, bytes, stream, deallocate_callback_arg_);
111 [[nodiscard]] std::pair<std::size_t, std::size_t> do_get_mem_info(cuda_stream_view)
const override
113 throw std::runtime_error(
"cannot get free / total memory");
116 [[nodiscard]]
virtual bool supports_streams() const noexcept {
return false; }
117 [[nodiscard]]
virtual bool supports_get_mem_info() const noexcept {
return false; }
119 allocate_callback_t allocate_callback_;
120 deallocate_callback_t deallocate_callback_;
121 void* allocate_callback_arg_;
122 void* deallocate_callback_arg_;