20 #include <rmm/detail/error.hpp>
21 #include <rmm/detail/export.hpp>
22 #include <rmm/detail/thrust_namespace.h>
25 #include <cuda_runtime_api.h>
29 namespace RMM_NAMESPACE {
54 : cuda_pool_handle_{[pool_handle]() {
55 RMM_EXPECTS(
nullptr != pool_handle,
"Unexpected null pool handle.");
60 RMM_EXPECTS(rmm::detail::runtime_async_alloc::is_supported(),
61 "cudaMallocAsync not supported with this CUDA driver/runtime version");
69 [[nodiscard]] cudaMemPool_t
pool_handle() const noexcept {
return cuda_pool_handle_; }
83 cudaMemPool_t cuda_pool_handle_{};
98 RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.
value()),
112 void do_deallocate(
void* ptr,
113 [[maybe_unused]] std::size_t bytes,
116 if (ptr !=
nullptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeAsync(ptr, stream.
value())); }
126 [[nodiscard]]
bool do_is_equal(device_memory_resource
const& other)
const noexcept
override
128 return dynamic_cast<cuda_async_view_memory_resource const*
>(&other) !=
nullptr;
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:39
cudaStream_t value() const noexcept
Get the wrapped stream.
device_memory_resource derived class that uses cudaMallocAsync/cudaFreeAsync for allocation/deallocat...
Definition: cuda_async_view_memory_resource.hpp:41
cuda_async_view_memory_resource & operator=(cuda_async_view_memory_resource &&)=default
Default move assignment operator.
cuda_async_view_memory_resource(cuda_async_view_memory_resource &&)=default
Default move constructor.
cudaMemPool_t pool_handle() const noexcept
Returns the underlying native handle to the CUDA pool.
Definition: cuda_async_view_memory_resource.hpp:69
cuda_async_view_memory_resource(cudaMemPool_t pool_handle)
Constructs a cuda_async_view_memory_resource which uses an existing CUDA memory pool....
Definition: cuda_async_view_memory_resource.hpp:53
cuda_async_view_memory_resource(cuda_async_view_memory_resource const &)=default
Default copy constructor.
cuda_async_view_memory_resource & operator=(cuda_async_view_memory_resource const &)=default
Default copy assignment operator.
Base class for all librmm device memory allocation.
Definition: device_memory_resource.hpp:94