cuda::experimental::uninitialized_buffer
Defined in include/cuda/experimental/__container/uninitialized_buffer.cuh
-
template<class _Tp, class ..._Properties>
class uninitialized_buffer Uninitialized type-safe memory storage
uninitialized_buffer
provides a typed buffer allocated from a given 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_buffer
also takes a set of properties to ensure that e.g. execution space constraints are checked at compile time. However, we can only forward stateless properties. If a user wants to use a stateful one, then they need to implement get_property(const device_buffer&, Property).- Template Parameters
_Tp – 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_buffer(__resource __mr, const size_t __count)
Constructs an
uninitialized_buffer
and allocates 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)
.Note
Only allocates memory when
__count
> 0- Parameters
__mr – The memory resource to allocate the buffer with.
__count – The desired size of the buffer.
-
uninitialized_buffer(const uninitialized_buffer&) = delete
-
uninitialized_buffer &operator=(const uninitialized_buffer&) = delete
-
inline uninitialized_buffer(uninitialized_buffer &&__other) noexcept
Move-constructs a
uninitialized_buffer
from__other
.- Parameters
__other – Another
uninitialized_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_buffer(uninitialized_buffer<_Tp, _OtherProperties...> &&__other) noexcept Move-constructs a
uninitialized_buffer
from anotheruninitialized_buffer
with matching properties.- Parameters
__other – Another
uninitialized_buffer
Takes ownership of the allocation in__other
and resets it
-
inline uninitialized_buffer &operator=(uninitialized_buffer &&__other) noexcept
Move-assings a
uninitialized_buffer
from__other
.- Parameters
__other – Another
uninitialized_buffer
Deallocates the current allocation and then takes ownership of the allocation in__other
and resets it
-
inline ~uninitialized_buffer()
Destroys an
uninitialized_buffer
and deallocates 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 pointer begin() const noexcept
Returns an aligned pointer to the first element in the buffer.
-
inline 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 pointer data() const noexcept
Returns an aligned pointer to the first element in the buffer.
-
inline const __resource &get_resource() const noexcept
Returns a c const reference to the any_resource that holds the memory resource used to allocate the buffer