logging_resource_adaptor.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
7 #include <rmm/detail/export.hpp>
8 #include <rmm/mr/detail/logging_resource_adaptor_impl.hpp>
9 #include <rmm/resource_ref.hpp>
10 
11 #include <cuda/memory_resource>
12 
13 #include <initializer_list>
14 #include <ostream>
15 #include <string>
16 
17 namespace RMM_NAMESPACE {
18 namespace mr {
19 
37 class RMM_EXPORT logging_resource_adaptor
38  : public cuda::mr::shared_resource<detail::logging_resource_adaptor_impl> {
39  using shared_base = cuda::mr::shared_resource<detail::logging_resource_adaptor_impl>;
40 
41  public:
47  RMM_CONSTEXPR_FRIEND void get_property(logging_resource_adaptor const&,
48  cuda::mr::device_accessible) noexcept
49  {
50  }
51 
72  logging_resource_adaptor(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
73  std::string const& filename = get_default_filename(),
74  bool auto_flush = false);
75 
88  logging_resource_adaptor(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
89  std::ostream& stream,
90  bool auto_flush = false);
91 
104  logging_resource_adaptor(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
105  std::initializer_list<rapids_logger::sink_ptr> sinks,
106  bool auto_flush = false);
107 
112 
116  void flush();
117 
123  [[nodiscard]] std::string header() const;
124 
132  static std::string get_default_filename();
133 };
134 
135 static_assert(cuda::mr::resource_with<logging_resource_adaptor, cuda::mr::device_accessible>,
136  "logging_resource_adaptor does not satisfy the cuda::mr::resource concept");
137  // end of group
139 } // namespace mr
140 } // namespace RMM_NAMESPACE
Resource that uses an upstream resource to allocate memory and logs information about the requested a...
Definition: logging_resource_adaptor.hpp:38
rmm::device_async_resource_ref get_upstream_resource() const noexcept
rmm::device_async_resource_ref to the upstream resource
logging_resource_adaptor(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::ostream &stream, bool auto_flush=false)
Construct a new logging resource adaptor using upstream to satisfy allocation requests and logging in...
logging_resource_adaptor(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::string const &filename=get_default_filename(), bool auto_flush=false)
Construct a new logging resource adaptor using upstream to satisfy allocation requests and logging in...
logging_resource_adaptor(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::initializer_list< rapids_logger::sink_ptr > sinks, bool auto_flush=false)
Construct a new logging resource adaptor using upstream to satisfy allocation requests and logging in...
friend void get_property(logging_resource_adaptor const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: logging_resource_adaptor.hpp:47
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