Loading...
Searching...
No Matches
statistics_resource_adaptor.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5#pragma once
6
7#include <rmm/detail/export.hpp>
8#include <rmm/mr/detail/statistics_resource_adaptor_impl.hpp>
10
11#include <cuda/memory_resource>
12
13#include <cstddef>
14#include <utility>
15
16RMM_NAMESPACE_BEGIN
17namespace mr {
33 : public cuda::mr::shared_resource<detail::statistics_resource_adaptor_impl> {
34 using shared_base = cuda::mr::shared_resource<detail::statistics_resource_adaptor_impl>;
35
36 public:
38 using counter = detail::statistics_resource_adaptor_impl::counter;
40 using read_lock_t = detail::statistics_resource_adaptor_impl::read_lock_t;
42 using write_lock_t = detail::statistics_resource_adaptor_impl::write_lock_t;
43
47 RMM_CONSTEXPR_FRIEND void get_property(statistics_resource_adaptor const&,
48 cuda::mr::device_accessible) noexcept
49 {
50 }
51
58 cuda::mr::any_resource<cuda::mr::device_accessible> upstream);
59
61
65 [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept;
66
72 [[nodiscard]] counter get_bytes_counter() const noexcept;
73
79 [[nodiscard]] counter get_allocations_counter() const noexcept;
80
87
95};
96
97static_assert(cuda::mr::resource_with<statistics_resource_adaptor, cuda::mr::device_accessible>,
98 "statistics_resource_adaptor does not satisfy the cuda::mr::resource concept");
99 // end of group
101} // namespace mr
102RMM_NAMESPACE_END
detail::statistics_resource_adaptor_impl::read_lock_t read_lock_t
Shared-reader lock type used to protect the counter stack.
Definition statistics_resource_adaptor.hpp:40
detail::statistics_resource_adaptor_impl::write_lock_t write_lock_t
Exclusive-writer lock type used to protect the counter stack.
Definition statistics_resource_adaptor.hpp:42
statistics_resource_adaptor(cuda::mr::any_resource< cuda::mr::device_accessible > upstream)
Construct a statistics resource adaptor using upstream to satisfy allocation requests.
counter get_bytes_counter() const noexcept
Returns a counter struct for bytes allocated since construction (or last push).
std::pair< counter, counter > pop_counters()
Pop a pair of counters from the stack.
detail::statistics_resource_adaptor_impl::counter counter
Counter type tracking current, peak, and total bytes or allocations.
Definition statistics_resource_adaptor.hpp:38
std::pair< counter, counter > push_counters()
Push a pair of zero counters — new counters start fresh.
friend void get_property(statistics_resource_adaptor const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition statistics_resource_adaptor.hpp:47
counter get_allocations_counter() const noexcept
Returns a counter struct for number of allocations since construction (or last push).
device_async_resource_ref get_upstream_resource() const noexcept
rmm::device_async_resource_ref to the upstream resource
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
Alias for a cuda::mr::resource_ref with the property cuda::mr::device_accessible.
Definition resource_ref.hpp:30
Memory Resource classes and adaptors.