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>
30 namespace RMM_NAMESPACE {
71 if (0 == bytes) {
return nullptr; }
73 return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) {
75 RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault), size);
93 rmm::detail::aligned_host_deallocate(
94 ptr, bytes, alignment, [](
void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); });
111 static void*
allocate_async(std::size_t bytes, [[maybe_unused]] cuda::stream_ref stream)
115 return allocate(bytes);
134 std::size_t alignment,
135 [[maybe_unused]] cuda::stream_ref stream)
139 return allocate(bytes, alignment);
153 [[maybe_unused]] cuda::stream_ref stream) noexcept
157 return deallocate(ptr, bytes);
173 std::size_t alignment,
174 [[maybe_unused]] cuda::stream_ref stream) noexcept
178 return deallocate(ptr, bytes, alignment);
212 static_assert(cuda::mr::async_resource_with<pinned_host_memory_resource,
213 cuda::mr::device_accessible,
214 cuda::mr::host_accessible>);
Memory resource class for allocating pinned host memory.
Definition: pinned_host_memory_resource.hpp:46
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:185
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:151
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:111
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:65
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:87
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:171
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:133
bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs)
Inequality comparison operator for streams.
Definition: cuda_stream_view.hpp:187
static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT
Default alignment used for host memory allocated by RMM.
Definition: aligned.hpp:37