Home
librmm
libucxx
ucxx
nightly (26.12)
nightly (26.12)
stable (26.10)
legacy (26.08)
Toggle main menu visibility
Loading...
Searching...
No Matches
include
rmm
mr
failure_callback_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/aligned.hpp
>
8
#include <rmm/detail/error.hpp>
9
#include <rmm/detail/export.hpp>
10
#include <rmm/mr/detail/failure_callback_resource_adaptor_impl.hpp>
11
#include <
rmm/resource_ref.hpp
>
12
13
#include <cuda/memory_resource>
14
15
#include <cstddef>
16
#include <utility>
17
18
RMM_NAMESPACE_BEGIN
19
namespace
mr {
25
42
template
<
typename
ExceptionType = rmm::out_of_memory>
43
class
failure_callback_resource_adaptor
44
:
public
cuda::mr::shared_resource<
45
detail::failure_callback_resource_adaptor_impl<ExceptionType>> {
46
using
shared_base =
47
cuda::mr::shared_resource<detail::failure_callback_resource_adaptor_impl<ExceptionType>>;
48
49
public
:
50
using
exception_type
= ExceptionType;
51
55
RMM_CONSTEXPR_FRIEND
void
get_property
(
failure_callback_resource_adaptor
const
&,
56
cuda::mr::device_accessible)
noexcept
57
{
58
}
59
68
failure_callback_resource_adaptor
(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
69
failure_callback_t
callback,
70
void
* callback_arg)
71
: shared_base(cuda::
mr
::make_shared_resource<
72
detail::failure_callback_resource_adaptor_impl<ExceptionType>>(
73
std::move(upstream), std::move(callback), callback_arg))
74
{
75
}
76
77
~failure_callback_resource_adaptor
() =
default
;
78
82
[[nodiscard]]
device_async_resource_ref
get_upstream_resource
() const noexcept
83
{
84
return
this->get().get_upstream_resource();
85
}
86
};
87
88
static_assert
(
89
cuda::mr::resource_with<failure_callback_resource_adaptor<>, cuda::mr::device_accessible>,
90
"failure_callback_resource_adaptor does not satisfy the cuda::mr::resource concept"
);
91
// end of group
93
}
// namespace mr
94
RMM_NAMESPACE_END
aligned.hpp
rmm::mr::failure_callback_resource_adaptor
A device memory resource that calls a callback function when allocations throw a specified exception ...
Definition
failure_callback_resource_adaptor.hpp:45
rmm::mr::failure_callback_resource_adaptor::failure_callback_resource_adaptor
failure_callback_resource_adaptor(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, failure_callback_t callback, void *callback_arg)
Construct a new failure_callback_resource_adaptor using upstream to satisfy allocation requests.
Definition
failure_callback_resource_adaptor.hpp:68
rmm::mr::failure_callback_resource_adaptor::exception_type
ExceptionType exception_type
The type of exception this object catches/throws.
Definition
failure_callback_resource_adaptor.hpp:50
rmm::mr::failure_callback_resource_adaptor::get_upstream_resource
device_async_resource_ref get_upstream_resource() const noexcept
rmm::device_async_resource_ref to the upstream resource
Definition
failure_callback_resource_adaptor.hpp:82
rmm::mr::failure_callback_resource_adaptor::get_property
friend void get_property(failure_callback_resource_adaptor const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition
failure_callback_resource_adaptor.hpp:55
rmm::mr::failure_callback_t
std::function< bool(std::size_t, void *)> failure_callback_t
Callback function type used by failure_callback_resource_adaptor.
Definition
failure_callback_t.hpp:34
rmm::device_async_resource_ref
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
rmm::mr
Memory Resource classes and adaptors.
resource_ref.hpp
Generated by
1.18.0