cuda::experimental::legacy_managed_memory_resource#

class legacy_managed_memory_resource#

managed_memory_resource uses cudaMallocManaged / cudaFree for allocation / deallocation.

Public Types

using default_queries = properties_list<device_accessible, host_accessible>#

Public Functions

inline constexpr legacy_managed_memory_resource(
const unsigned int __flags = cudaMemAttachGlobal,
) noexcept#
inline void *allocate_sync(
const size_t __bytes,
const size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment,
) const#

Allocate CUDA unified 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_alignment,
) const noexcept#

Deallocate memory pointed to by __ptr.

Parameters:
  • __ptr – Pointer to be deallocated. Must have been allocated through a call to allocate or 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_managed_memory_resource const &__other,
) const noexcept#

Equality comparison with another managed_memory_resource.

Parameters:

__other – The other managed_memory_resource.

Returns:

Whether both managed_memory_resource were constructed with the same flags.

Friends

inline friend constexpr void get_property(
legacy_managed_memory_resource const&,
device_accessible,
) noexcept#

Enables the device_accessible property.

inline friend constexpr void get_property(
legacy_managed_memory_resource const&,
host_accessible,
) noexcept#

Enables the host_accessible property.