cuda::experimental::legacy_pinned_memory_resource#
-
class legacy_pinned_memory_resource#
legacy_pinned_memory_resource uses
cudaMallocHost
/cudaFreeAsync
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 Types
-
using default_queries = ::cuda::mr::properties_list<::cuda::mr::device_accessible, ::cuda::mr::host_accessible>#
Public Functions
- inline constexpr legacy_pinned_memory_resource(
- device_ref __device = {0},
Construct a new legacy_pinned_memory_resource.
Note
Synchronous allocations in CUDA are tied to a device, even if not located in device memory. This constructor takes an optional device argument to specify the device that should be tied to allocations for the resource. This association has the effect of initializing that device and the memory being implicitly freed if the device is reset.
- inline void *allocate_sync(
- const size_t __bytes,
- const size_t __alignment = ::cuda::mr::default_cuda_malloc_host_alignment,
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_sync(
- void *__ptr,
- const size_t,
- const size_t __alignment = ::cuda::mr::default_cuda_malloc_host_alignment,
Deallocate memory pointed to by
__ptr
.- Parameters:
__ptr – Pointer to be deallocated. Must have been allocated through a call to
allocate_sync
.__bytes – The number of bytes that was passed to the allocation call that returned
__ptr
.__alignment – The alignment that was passed to the allocation call that returned
__ptr
.
- inline constexpr bool operator==(
- legacy_pinned_memory_resource const&,
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.
Friends
- inline friend constexpr void get_property(
- legacy_pinned_memory_resource const&,
- ::cuda::mr::device_accessible,
Enables the
device_accessible
property.
- inline friend constexpr void get_property(
- legacy_pinned_memory_resource const&,
- ::cuda::mr::host_accessible,
Enables the
host_accessible
property.
-
using default_queries = ::cuda::mr::properties_list<::cuda::mr::device_accessible, ::cuda::mr::host_accessible>#