![]() |
alpaka
Abstraction Library for Parallel Kernel Acceleration
|
Life time managed buffer with contiguous data. More...
#include <SharedBuffer.hpp>
Public Member Functions | |
| SharedBuffer (SharedBuffer &&)=default | |
| SharedBuffer (SharedBuffer const &)=default | |
| template<typename T_Type_Other> | |
| SharedBuffer (SharedBuffer< T_Api, T_Type_Other, T_Extents, T_MemAlignment > &&other) | |
| template<typename T_Type_Other> | |
| SharedBuffer (SharedBuffer< T_Api, T_Type_Other, T_Extents, T_MemAlignment > const &other) | |
| template<alpaka::concepts::HasApi T_Any, alpaka::concepts::Vector T_UserExtents, alpaka::concepts::Vector T_UserPitches> | |
| SharedBuffer (T_Any const &any, T_Type *data, T_UserExtents const &extents, T_UserPitches const &pitches, std::invocable<> auto deleter, T_MemAlignment const memAlignment=Alignment{}) | |
| void | addDestructorAction (std::function< void()> &&action) |
| Adds a destructor action to the shared buffer. | |
| void | destructorWaitFor (auto const &any) |
| Add an action to be executed when the shared_ptr is destroyed. | |
| auto | getConstSharedBuffer () const |
| create a read shared buffer view | |
| auto | getSubSharedBuffer (alpaka::concepts::VectorOrScalar auto const &extents) |
| auto | getSubSharedBuffer (alpaka::concepts::VectorOrScalar auto const &extents) const |
| Creates a buffer pointing to a part of the memory. | |
| auto | getSubSharedBuffer (alpaka::concepts::VectorOrScalar auto const &offsets, alpaka::concepts::VectorOrScalar auto const &extents) |
| auto | getSubSharedBuffer (alpaka::concepts::VectorOrScalar auto const &offsets, alpaka::concepts::VectorOrScalar auto const &extents) const |
| Creates a shared sub-buffer view to a part of the memory. | |
| constexpr long | getUseCount () const noexcept |
| Return the number of SharedBuffers which points to the same memory. | |
| auto | getView () |
| auto | getView () const |
| void | keepAlive (auto &queue) |
| Keep the buffer alive until at least the current spot in the queue, even if it runs out of scope. | |
| constexpr | operator bool () const noexcept |
| True if SharedBuffer is pointing to valid memory. | |
| SharedBuffer & | operator= (SharedBuffer &&)=default |
| SharedBuffer & | operator= (SharedBuffer const &otherSharedBuffer)=default |
| Assignment operator keeping const-ness. | |
| Public Member Functions inherited from alpaka::View< T_Api, T_Type, T_Extents, Alignment<> > | |
| constexpr | View (T_Any const &any, T_Type *data, T_UserExtents const &extents, T_UserPitches const &pitches, T_MemAlignment const memAlignment=T_MemAlignment{}) |
| Creates a view. | |
| constexpr auto | getConstView () const |
| create a read only view | |
| constexpr alpaka::concepts::IMdSpan auto | getMdSpan () const |
| constexpr View & | operator= (View const &)=default |
| Assignment operator keeping const-ness. | |
| constexpr auto | getSubView (alpaka::concepts::VectorOrScalar auto const &extents) const |
| Creates a sub view to a part of the memory. | |
| Public Member Functions inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment > | |
| constexpr | MdSpan ()=default |
| constexpr auto | begin () const |
| constexpr auto | cbegin () const |
| constexpr auto | cend () const |
| constexpr const_pointer | data () const |
| get origin pointer | |
| constexpr auto | end () const |
| constexpr auto | getConstMdSpan () const |
| constexpr auto | getExtents () const |
| constexpr T_Pitches | getPitches () const |
| constexpr | operator bool () const noexcept |
| True if MdSpan is pointing to valid memory. | |
| constexpr const_reference | operator* () const |
| return value the origin pointer is pointing to | |
| constexpr MdSpan & | operator= (MdSpan const &)=default |
| Assignment operator keeping const-ness. | |
| constexpr const_reference | operator[] (concepts::IndexVec< index_type, alpaka::trait::GetDim< T_Extents >::value > auto const &idx) const |
| get value at the given index | |
Private Types | |
| using | BaseView = View<T_Api, T_Type, T_Extents, T_MemAlignment> |
| template<alpaka::concepts::Pointer T> | |
| using | ConstPtr_t = std::add_pointer_t<std::add_const_t<std::remove_pointer_t<T>>> |
Private Member Functions | |
| SharedBuffer (T_Api const api, T_Type *data, T_Extents const &extents, T_Extents const &pitches, std::shared_ptr< internal::ManagedDealloc > managedDeleter, T_MemAlignment const memAlignment) | |
| Constructor with existing managed deleter. | |
Private Attributes | |
| std::shared_ptr< internal::ManagedDealloc > | m_deleter |
Friends | |
| template<alpaka::concepts::Api T_OtherApi, typename T_OtherType, alpaka::concepts::Vector T_OtherExtents, alpaka::concepts::Alignment T_OtherMemAlignment2> | |
| struct | SharedBuffer |
| template<alpaka::concepts::Api T_OtherApi, typename T_OtherType, alpaka::concepts::Vector T_OtherExtents, alpaka::concepts::Alignment T_OtherMemAlignment2> | |
| std::ostream & | operator<< (std::ostream &s, SharedBuffer< T_OtherApi, T_OtherType, T_OtherExtents, T_OtherMemAlignment2 > const &buffer) |
Additional Inherited Members | |
| Public Types inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment > | |
| using | const_pointer |
| using | const_reference |
| using | ConstThis |
| using | index_type |
| using | pointer |
| using | reference |
| using | value_type |
| Static Public Member Functions inherited from alpaka::View< T_Api, T_Type, T_Extents, Alignment<> > | |
| static consteval T_Api | getApi () |
| Static Public Member Functions inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment > | |
| static consteval uint32_t | dim () |
| static constexpr auto | getAlignment () |
| Protected Member Functions inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment > | |
| constexpr auto | ptr (concepts::Vector auto const &idx) const |
| get the pointer of the value relative to the origin pointer m_ptr | |
Life time managed buffer with contiguous data.
This buffer owns the data and will deallocate it when last copy is destroyed. Const-ness of the buffer instance is propagated to the data region. A copy of this instance will only perform a shallow copy, to perform a deep copy to duplicate the data you should use onHost::memcpy.
Definition at line 39 of file SharedBuffer.hpp.
|
private |
Definition at line 42 of file SharedBuffer.hpp.
|
private |
Definition at line 276 of file SharedBuffer.hpp.
|
inlineprivate |
Constructor with existing managed deleter.
Definition at line 45 of file SharedBuffer.hpp.
|
inline |
Definition at line 79 of file SharedBuffer.hpp.
|
inline |
Definition at line 96 of file SharedBuffer.hpp.
|
default |
|
inline |
Definition at line 112 of file SharedBuffer.hpp.
|
default |
|
inline |
Adds a destructor action to the shared buffer.
The action will be executed when the buffer is destroyed. This can be used to add additional cleanup actions e.g. waiting on a specific queue. Actions are executed in FIFO order.
| action | callable to execute on destruction |
Definition at line 226 of file SharedBuffer.hpp.
|
inline |
Add an action to be executed when the shared_ptr is destroyed.
| action | Callable to execute on destruction. |
Definition at line 235 of file SharedBuffer.hpp.
|
inline |
create a read shared buffer view
Definition at line 134 of file SharedBuffer.hpp.
|
inline |
Definition at line 164 of file SharedBuffer.hpp.
|
inline |
Creates a buffer pointing to a part of the memory.
| extents | number of elements for each dimension |
Definition at line 151 of file SharedBuffer.hpp.
|
inline |
Definition at line 201 of file SharedBuffer.hpp.
|
inline |
Creates a shared sub-buffer view to a part of the memory.
| offsets | offset in elements to the original buffer |
| extents | number of elements for each dimension |
Definition at line 184 of file SharedBuffer.hpp.
|
inlinenodiscardconstexprnoexcept |
Return the number of SharedBuffers which points to the same memory.
Definition at line 262 of file SharedBuffer.hpp.
|
inline |
Definition at line 128 of file SharedBuffer.hpp.
|
inline |
Definition at line 123 of file SharedBuffer.hpp.
|
inline |
Keep the buffer alive until at least the current spot in the queue, even if it runs out of scope.
This ensures that the buffer is and stays valid in previously enqueued kernels. There is no guarantee that the buffer is deleted immediately when the last reference to it is deleted.
This differs from destructorWaitFor, because that function waits, while keepAlive does not block anything, it just extends lifetime.
| queue | The queue to enqueue to. |
Definition at line 252 of file SharedBuffer.hpp.
|
inlineexplicitnodiscardconstexprnoexcept |
True if SharedBuffer is pointing to valid memory.
Definition at line 268 of file SharedBuffer.hpp.
|
default |
|
default |
Assignment operator keeping const-ness.
|
friend |
Definition at line 63 of file SharedBuffer.hpp.
|
friend |
|
private |
Definition at line 278 of file SharedBuffer.hpp.