13 #include <unordered_map>
14 #include <unordered_set>
17 #include <rmm/error.hpp>
21 #include <rapidsmpf/memory/scoped_memory_record.hpp>
42 std::optional<rmm::device_async_resource_ref> fallback_mr = std::nullopt
44 : primary_mr_{std::move(primary_mr)}, fallback_mr_{std::move(fallback_mr)} {}
65 [[nodiscard]] std::optional<rmm::device_async_resource_ref>
137 void* do_allocate(std::
size_t bytes,
rmm::cuda_stream_view stream) override;
147 void* ptr, std::
size_t bytes,
rmm::cuda_stream_view stream
158 [[nodiscard]]
bool do_is_equal(
160 ) const noexcept override;
162 mutable std::mutex mutex_;
165 std::unordered_set<
void*> fallback_allocations_;
172 std::unordered_map<
void*, std::thread::
id> allocating_threads_;
A RMM memory resource adaptor tailored to RapidsMPF.
RmmResourceAdaptor(rmm::device_async_resource_ref primary_mr, std::optional< rmm::device_async_resource_ref > fallback_mr=std::nullopt)
Construct with specified primary and optional fallback memory resource.
void begin_scoped_memory_record()
Begin recording a new scoped memory usage record for the current thread.
ScopedMemoryRecord get_main_record() const
Returns a copy of the main memory record.
std::int64_t current_allocated() const noexcept
Get the total current allocated memory from both primary and fallback.
rmm::device_async_resource_ref get_upstream_resource() const noexcept
Get a reference to the primary upstream resource.
std::optional< rmm::device_async_resource_ref > get_fallback_resource() const noexcept
Get a reference to the fallback upstream resource.
ScopedMemoryRecord end_scoped_memory_record()
End the current scoped memory record and return it.
device_memory_resource(device_memory_resource const &)=default
detail::cccl_async_resource_ref< cuda::mr::resource_ref< cuda::mr::device_accessible > > device_async_resource_ref
RAPIDS Multi-Processor interfaces.
Memory statistics for a specific scope.