cuda::experimental::legacy_pinned_memory_resource

Defined in include/cuda/experimental/__memory_resource/legacy_pinned_memory_resource.cuh

class legacy_pinned_memory_resource

legacy_pinned_memory_resource uses cudaMallocHost / cudaFreeHost for allocation / deallocation.

Note

This memory resource will be deprecated in the future. For CUDA 12.6 and above, use cuda::experimental::pinned_memory_resource instead, which is the long-term replacement.

Public Functions

inline constexpr legacy_pinned_memory_resource() noexcept
inline void *allocate(const size_t __bytes, const size_t __alignment = cuda::mr::default_cuda_malloc_host_alignment) const

Allocate host memory of size at least __bytes.

Parameters
  • __bytes – The size in bytes of the allocation.

  • __alignment – The requested alignment of the allocation.

Throws

std::invalid_argument – in case of invalid alignment or cuda::cuda_error of the returned error code.

Returns

Pointer to the newly allocated memory

inline void deallocate(void *__ptr, const size_t, const size_t __alignment = cuda::mr::default_cuda_malloc_host_alignment) const noexcept

Deallocate memory pointed to by __ptr.

Parameters
  • __ptr – Pointer to be deallocated. Must have been allocated through a call to allocate.

  • __bytes – The number of bytes that was passed to the allocate call that returned __ptr.

  • __alignment – The alignment that was passed to the allocate call that returned __ptr.

inline constexpr bool operator==(legacy_pinned_memory_resource const&) const noexcept

Equality comparison with another legacy_pinned_memory_resource.

Parameters

__other – The other legacy_pinned_memory_resource.

Returns

Whether both legacy_pinned_memory_resource were constructed with the same flags.