20 #include <rmm/detail/error.hpp>
21 #include <rmm/detail/export.hpp>
22 #include <rmm/detail/format.hpp>
28 namespace RMM_NAMESPACE {
40 int pageableMemoryAccess;
41 RMM_CUDA_TRY(cudaDeviceGetAttribute(
42 &pageableMemoryAccess, cudaDevAttrPageableMemoryAccess, device_id.
value()));
43 return pageableMemoryAccess == 1;
79 "System memory allocator is not supported with this hardware/software version.");
101 void* do_allocate(std::size_t bytes, [[maybe_unused]]
cuda_stream_view stream)
override
104 return rmm::detail::aligned_host_allocate(
106 }
catch (std::bad_alloc
const& e) {
107 auto const msg = std::string(
"Failed to allocate ") + rmm::detail::format_bytes(bytes) +
108 std::string(
"of memory: ") + e.what();
123 void do_deallocate(
void* ptr,
124 [[maybe_unused]] std::size_t bytes,
133 rmm::detail::aligned_host_deallocate(
147 [[nodiscard]]
bool do_is_equal(device_memory_resource
const& other)
const noexcept
override
149 return dynamic_cast<system_memory_resource const*
>(&other) !=
nullptr;
167 static_assert(cuda::mr::async_resource_with<system_memory_resource, cuda::mr::device_accessible>);
168 static_assert(cuda::mr::async_resource_with<system_memory_resource, cuda::mr::host_accessible>);
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:39
void synchronize() const
Synchronize the viewed CUDA stream.
Definition: cuda_stream_view.hpp:106
Base class for all librmm device memory allocation.
Definition: device_memory_resource.hpp:93
device_memory_resource derived class that uses malloc/free for allocation/deallocation.
Definition: system_memory_resource.hpp:74
system_memory_resource(system_memory_resource const &)=default
Default copy constructor.
system_memory_resource(system_memory_resource &&)=default
Default copy constructor.
system_memory_resource & operator=(system_memory_resource const &)=default
Default copy assignment operator.
friend void get_property(system_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: system_memory_resource.hpp:156
friend void get_property(system_memory_resource const &, cuda::mr::host_accessible) noexcept
Enables the cuda::mr::host_accessible property.
Definition: system_memory_resource.hpp:163
system_memory_resource & operator=(system_memory_resource &&)=default
Default move assignment operator.
Exception thrown when RMM runs out of memory.
Definition: error.hpp:87
cuda_device_id get_current_cuda_device()
Returns a cuda_device_id for the current device.
Definition: cuda_device.hpp:99
static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT
Default alignment used for CUDA memory allocation.
Definition: aligned.hpp:43
Strong type for a CUDA device identifier.
Definition: cuda_device.hpp:41
constexpr value_type value() const noexcept
The wrapped integer value.
Definition: cuda_device.hpp:57
static bool is_system_memory_supported(cuda_device_id device_id)
Check if system allocated memory (SAM) is supported on the specified device.
Definition: system_memory_resource.hpp:38