cuda::experimental::managed_memory_resource#
-
class managed_memory_resource#
managed_memory_resource
usescudaMallocManaged
/cudaFree
for allocation / deallocation.Public Types
-
using default_queries = properties_list<device_accessible, host_accessible>#
Public Functions
- inline constexpr managed_memory_resource(
- const unsigned int __flags = cudaMemAttachGlobal,
- inline void *allocate_sync(
- const size_t __bytes,
- const size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment,
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 *allocate(
- const ::cuda::stream_ref __stream,
- const size_t __bytes,
- const size_t __alignment,
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.
__stream – Stream on which to perform allocation. Currently ignored
- Throws:
std::invalid_argument – In case of invalid alignment.
cuda::cuda_error – If an error code was return by the cuda api call.
- Returns:
Pointer to the newly allocated memory.
- inline void *allocate(
- const ::cuda::stream_ref __stream,
- const size_t __bytes,
Allocate CUDA unified memory of size at least
__bytes
.- Parameters:
__bytes – The size in bytes of the allocation.
__stream – Stream on which to perform allocation.
- Throws:
cuda::cuda_error – If an error code was return by the cuda api call.
- 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,
Deallocate memory pointed to by
__ptr
.- Parameters:
__ptr – Pointer to be deallocated. Must have been allocated through a call to
allocate
orallocate_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 void deallocate(
- const ::cuda::stream_ref __stream,
- void *__ptr,
- const size_t __bytes,
- const size_t __alignment,
Deallocate memory pointed to by
__ptr
.Note
The pointer passed to
deallocate
must not be in use in a stream other than__stream
. It is the caller’s responsibility to properly synchronize all relevant streams before callingdeallocate
.- 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 allocation call that returned
__ptr
.__alignment – The alignment that was passed to the allocation call that returned
__ptr
.__stream – A stream that has a stream ordering relationship with the stream used in the allocate call that returned
__ptr
.
- inline void deallocate(
- const ::cuda::stream_ref __stream,
- void *__ptr,
- size_t __bytes,
Deallocate memory pointed to by
__ptr
.Note
The pointer passed to
deallocate
must not be in use in a stream other than__stream
. It is the caller’s responsibility to properly synchronize all relevant streams before callingdeallocate
.- 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 allocation call that returned
__ptr
.__stream – A stream that has a stream ordering relationship with the stream used in the allocate call that returned
__ptr
.
- inline constexpr bool operator==(
- managed_memory_resource const &__other,
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(
- managed_memory_resource const&,
- device_accessible,
Enables the
device_accessible
property.
- inline friend constexpr void get_property(
- managed_memory_resource const&,
- host_accessible,
Enables the
host_accessible
property.
-
using default_queries = properties_list<device_accessible, host_accessible>#