19 #include <rmm/detail/aligned.hpp>
20 #include <rmm/detail/error.hpp>
21 #include <rmm/detail/export.hpp>
22 #include <rmm/detail/nvtx/ranges.hpp>
24 #include <cuda/memory_resource>
25 #include <cuda/stream_ref>
26 #include <cuda_runtime_api.h>
31 namespace RMM_NAMESPACE {
72 if (0 == bytes) {
return nullptr; }
74 return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) {
76 RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault));
94 rmm::detail::aligned_host_deallocate(
95 ptr, bytes, alignment, [](
void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); });
112 static void*
allocate_async(std::size_t bytes, [[maybe_unused]] cuda::stream_ref stream)
116 return allocate(bytes);
135 std::size_t alignment,
136 [[maybe_unused]] cuda::stream_ref stream)
140 return allocate(bytes, alignment);
154 [[maybe_unused]] cuda::stream_ref stream) noexcept
158 return deallocate(ptr, bytes);
174 std::size_t alignment,
175 [[maybe_unused]] cuda::stream_ref stream) noexcept
179 return deallocate(ptr, bytes, alignment);
213 static_assert(cuda::mr::async_resource_with<pinned_host_memory_resource,
214 cuda::mr::device_accessible,
215 cuda::mr::host_accessible>);
Memory resource class for allocating pinned host memory.
Definition: pinned_host_memory_resource.hpp:47
bool operator==(const pinned_host_memory_resource &) const
true if the specified resource is the same type as this resource.
Definition: pinned_host_memory_resource.hpp:186
static void deallocate_async(void *ptr, std::size_t bytes, [[maybe_unused]] cuda::stream_ref stream) noexcept
Deallocate memory pointed to by ptr of size bytes bytes.
Definition: pinned_host_memory_resource.hpp:152
static void * allocate_async(std::size_t bytes, [[maybe_unused]] cuda::stream_ref stream)
Allocates pinned host memory of size at least bytes bytes.
Definition: pinned_host_memory_resource.hpp:112
static void * allocate(std::size_t bytes, [[maybe_unused]] std::size_t alignment=rmm::RMM_DEFAULT_HOST_ALIGNMENT)
Allocates pinned host memory of size at least bytes bytes.
Definition: pinned_host_memory_resource.hpp:66
static void deallocate(void *ptr, std::size_t bytes, std::size_t alignment=rmm::RMM_DEFAULT_HOST_ALIGNMENT) noexcept
Deallocate memory pointed to by ptr of size bytes bytes.
Definition: pinned_host_memory_resource.hpp:88
static void deallocate_async(void *ptr, std::size_t bytes, std::size_t alignment, [[maybe_unused]] cuda::stream_ref stream) noexcept
Deallocate memory pointed to by ptr of size bytes bytes and alignment alignment bytes.
Definition: pinned_host_memory_resource.hpp:172
static void * allocate_async(std::size_t bytes, std::size_t alignment, [[maybe_unused]] cuda::stream_ref stream)
Allocates pinned host memory of size at least bytes bytes and alignment alignment.
Definition: pinned_host_memory_resource.hpp:134
bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs)
Inequality comparison operator for streams.
Definition: cuda_stream_view.hpp:189
static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT
Default alignment used for host memory allocated by RMM.
Definition: aligned.hpp:37