20 #include <rmm/detail/aligned.hpp>
21 #include <rmm/detail/error.hpp>
22 #include <rmm/detail/export.hpp>
27 namespace RMM_NAMESPACE {
64 return do_allocate(bytes, alignment);
78 return do_allocate(bytes);
114 void* do_allocate(std::size_t bytes, std::size_t alignment =
alignof(std::max_align_t))
override
117 if (0 == bytes) {
return nullptr; }
123 return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) {
125 RMM_CUDA_TRY_ALLOC(cudaMallocHost(&ptr, size), size);
143 void do_deallocate(
void* ptr,
145 std::size_t alignment =
alignof(std::max_align_t))
override
147 if (
nullptr == ptr) {
return; }
148 rmm::detail::aligned_host_deallocate(
149 ptr, bytes, alignment, [](
void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); });
152 static_assert(cuda::mr::async_resource_with<pinned_memory_resource,
153 cuda::mr::host_accessible,
154 cuda::mr::device_accessible>);
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:39
Base class for host memory allocation.
Definition: host_memory_resource.hpp:57
A host_memory_resource that uses cudaMallocHost to allocate pinned/page-locked host memory.
Definition: pinned_memory_resource.hpp:41
friend void get_property(pinned_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: pinned_memory_resource.hpp:99
void * allocate_async(std::size_t bytes, cuda_stream_view)
Pretend to support the allocate_async interface, falling back to stream 0.
Definition: pinned_memory_resource.hpp:76
pinned_memory_resource & operator=(pinned_memory_resource const &)=default
Default copy assignment operator.
pinned_memory_resource(pinned_memory_resource &&)=default
Default move constructor.
pinned_memory_resource & operator=(pinned_memory_resource &&)=default
Default move assignment operator.
void * allocate_async(std::size_t bytes, std::size_t alignment, cuda_stream_view)
Pretend to support the allocate_async interface, falling back to stream 0.
Definition: pinned_memory_resource.hpp:62
void deallocate_async(void *ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view)
Pretend to support the deallocate_async interface, falling back to stream 0.
Definition: pinned_memory_resource.hpp:89
pinned_memory_resource(pinned_memory_resource const &)=default
Default copy constructor.
static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT
Default alignment used for host memory allocated by RMM.
Definition: aligned.hpp:37
constexpr bool is_supported_alignment(std::size_t alignment) noexcept
Returns whether or not alignment is a valid memory alignment.
Definition: aligned.hpp:64
constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept
Align up to nearest multiple of specified power of 2.
Definition: aligned.hpp:77