cuda::experimental::uninitialized_async_buffer
Defined in include/cuda/experimental/__container/uninitialized_async_buffer.cuh
-
template<class _Tp, class ..._Properties>
class uninitialized_async_buffer Uninitialized stream-ordered type-safe memory storage
uninitialized_async_buffer
provides a typed buffer allocated in stream order from a given async memory resource. It handles alignment and release of the allocation. The memory is uninitialized, so that a user needs to ensure elements are properly constructed.In addition to being type safe,
uninitialized_async_buffer
also takes a set of properties to ensure that e.g. execution space constraints are checked at compile time. However, only stateless properties can be forwarded. To use a stateful property, implement get_property(const uninitialized_async_buffer&, Property).Warning
uninitialized_async_buffer
uses stream-ordered allocation. It is the user’s resposibility to ensure the lifetime of both the provided async resource and the stream exceed the lifetime of the buffer.- Template Parameters
_T – the type to be stored in the buffer
_Properties... – The properties the allocated memory satisfies
Public Types
-
using size_type = size_t
Public Functions
-
inline uninitialized_async_buffer(__async_resource __mr, const ::cuda::stream_ref __stream, const size_t __count)
Constructs an
uninitialized_async_buffer
, allocating sufficient storage for__count
elements through__mr
.Note
Depending on the alignment requirements of
T
the size of the underlying allocation might be larger thancount * sizeof(T)
. Only allocates memory when__count
> 0- Parameters
__mr – The async memory resource to allocate the buffer with.
__stream – The CUDA stream used for stream-ordered allocation.
__count – The desired size of the buffer.
-
uninitialized_async_buffer(const uninitialized_async_buffer&) = delete
-
uninitialized_async_buffer &operator=(const uninitialized_async_buffer&) = delete
-
inline uninitialized_async_buffer(uninitialized_async_buffer &&__other) noexcept
Move-constructs a
uninitialized_async_buffer
from__other
.- Parameters
__other – Another
uninitialized_async_buffer
Takes ownership of the allocation in__other
and resets it
-
template<class ..._OtherProperties, ::cuda::std::enable_if_t<__properties_match<_OtherProperties...>, int> = 0>
inline uninitialized_async_buffer(uninitialized_async_buffer<_Tp, _OtherProperties...> &&__other) noexcept Move-constructs a
uninitialized_async_buffer
from__other
.- Parameters
__other – Another
uninitialized_async_buffer
with matching properties Takes ownership of the allocation in__other
and resets it
-
inline uninitialized_async_buffer &operator=(uninitialized_async_buffer &&__other) noexcept
Move-assings a
uninitialized_async_buffer
from__other
.- Parameters
__other – Another
uninitialized_async_buffer
Deallocates the current allocation and then takes ownership of the allocation in__other
and resets it
-
inline ~uninitialized_async_buffer()
Destroys an
uninitialized_async_buffer
and deallocates the buffer in stream order on the stream that was used to create the buffer.Warning
The destructor does not destroy any objects that may or may not reside within the buffer. It is the user’s responsibility to ensure that all objects within the buffer have been properly destroyed.
-
inline constexpr pointer begin() const noexcept
Returns an aligned pointer to the first element in the buffer.
-
inline constexpr pointer end() const noexcept
Returns an aligned pointer to the element following the last element of the buffer. This element acts as a placeholder; attempting to access it results in undefined behavior.
-
inline constexpr pointer data() const noexcept
Returns an aligned pointer to the first element in the buffer.
-
inline const __async_resource &get_resource() const noexcept
Returns a c const reference to the any_async_resource that holds the memory resource used to allocate the buffer