35 alpaka::concepts::Api T_Api,
37 alpaka::concepts::Vector T_Extents,
38 alpaka::concepts::Alignment T_MemAlignment = Alignment<>>
48 T_Extents
const& extents,
49 T_Extents
const& pitches,
50 std::shared_ptr<internal::ManagedDealloc> managedDeleter,
51 T_MemAlignment
const memAlignment)
82 T_UserExtents
const& extents,
83 T_UserPitches
const& pitches,
84 std::invocable<>
auto deleter,
85 T_MemAlignment
const memAlignment =
Alignment{})
91 "extent type and pitch type must be lossless convertible");
94 template<
typename T_Type_Other>
110 template<
typename T_Type_Other>
130 return static_cast<BaseView>(*this);
136 using ConstValueType = std::add_const_t<typename BaseView::value_type>;
139 static_cast<ConstValueType*
>(this->
data()),
153 Vec extentMd = extents;
166 Vec extentMd = extents;
188 Vec offsetMd = offsets;
189 Vec extentMd = extents;
190 assert((offsetMd + extentMd <= this->
getExtents()).
reduce(std::logical_and{}));
191 auto shiftedPtr = &(*this)[offsetMd];
205 Vec offsetMd = offsets;
206 Vec extentMd = extents;
207 assert((offsetMd + extentMd <= this->
getExtents()).
reduce(std::logical_and{}));
208 auto shiftedPtr = &(*this)[offsetMd];
258 queue.enqueueHostFnDeferred([_ = std::move(del)] {});
268 [[nodiscard]]
constexpr explicit operator bool() const noexcept
275 template<alpaka::concepts::Po
inter T>
276 using ConstPtr_t = std::add_pointer_t<std::add_const_t<std::remove_pointer_t<T>>>;
290 T_UserExtents
const&,
291 T_UserPitches
const&,
292 std::invocable<>
auto,
293 T_MemAlignment
const)
297 typename T_UserPitches::UniVec,
305 SharedBuffer(T_Any
const&, T_Type*, T_UserExtents
const&, T_UserPitches
const&, std::invocable<>
auto)
309 typename T_UserPitches::UniVec,
321 return any.getView();
334 <<
" , alignment=" << T_MemAlignment::template
get<T_Type>() <<
" }";
351 alpaka::unused(buffer);
#define ALPAKA_TYPEOF(...)
Get the type of instance.
#define ALPAKA_FORWARD(instance)
Perfectly forward an instance as argument.
Concept to check for an alignment object.
Concept to check for APIs.
Concept to check if the given type implements the getApi(T x) function returning an alpaka::concepts:...
Concept to check if a type is a vector or scalar variable.
Concept to check if a type is a vector.
Concept to restrict copy or move constructor of a DataSource which creates a new object with a differ...
alpaka internal implementations.
Functionality which is usable on the host CPU controller thread.
SharedBuffer(T_Any const &, T_Type *, T_UserExtents const &, T_UserPitches const &, std::invocable<> auto, T_MemAlignment const) -> SharedBuffer< ALPAKA_TYPEOF(getApi(std::declval< T_Any >())), T_Type, typename T_UserPitches::UniVec, T_MemAlignment >
std::ostream & operator<<(std::ostream &s, DeviceProperties const &p)
decltype(auto) data(auto &&any)
pointer to data of an object
std::convertible_to< std::string > auto getName(auto &&any)
Runtime name for a given object.
void wait(alpaka::concepts::HasGet auto &handle)
wait for all work to be finished
void reduce(Queue< T_Device, T_QueueKind > const &queue, alpaka::concepts::Executor auto const exec, DataType const &neutralElement, alpaka::concepts::IMdSpan auto out, auto &&binaryReduceFn, auto &&in)
accumulate the results into a scalar value.
constexpr bool isLosslesslyConvertible_v
constexpr decltype(auto) getApi(auto &&any)
Get the API an object depends on.
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
Strongly typed and constexpr representation of a byte-alignment of memory.
constexpr auto getExtents() const
constexpr const_pointer data() const
constexpr T_Pitches getPitches() const
constexpr auto getConstView() const
create a read only view
constexpr View(T_Any const &any, T_Type *data, T_UserExtents const &extents, T_UserPitches const &pitches, T_MemAlignment const memAlignment=T_MemAlignment{})
onHost::SharedBuffer< T_Api, std::add_const_t< T_Type >, T_Extents, T_MemAlignment > InnerConst
onHost::SharedBuffer< T_Api, std::remove_const_t< T_Type >, T_Extents, T_MemAlignment > InnerMutable
Specialize the trait for DataSource class if the object is copyable.
constexpr auto operator()(auto &&buffer) const
auto operator()(auto &&any) const
Life time managed buffer with contiguous data.
auto getSubSharedBuffer(alpaka::concepts::VectorOrScalar auto const &extents) const
Creates a buffer pointing to a part of the memory.
SharedBuffer(SharedBuffer const &)=default
constexpr long getUseCount() const noexcept
Return the number of SharedBuffers which points to the same memory.
void keepAlive(auto &queue)
Keep the buffer alive until at least the current spot in the queue, even if it runs out of scope.
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{})
SharedBuffer & operator=(SharedBuffer const &otherSharedBuffer)=default
Assignment operator keeping const-ness.
void addDestructorAction(std::function< void()> &&action)
Adds a destructor action to the shared buffer.
View< T_Api, T_Type, T_Extents, T_MemAlignment > BaseView
SharedBuffer(SharedBuffer &&)=default
friend std::ostream & operator<<(std::ostream &s, SharedBuffer< T_OtherApi, T_OtherType, T_OtherExtents, T_OtherMemAlignment2 > const &buffer)
SharedBuffer(SharedBuffer< T_Api, T_Type_Other, T_Extents, T_MemAlignment > &&other)
auto getConstSharedBuffer() const
create a read shared buffer view
std::add_pointer_t< std::add_const_t< std::remove_pointer_t< T > > > ConstPtr_t
auto getSubSharedBuffer(alpaka::concepts::VectorOrScalar auto const &offsets, alpaka::concepts::VectorOrScalar auto const &extents)
friend struct SharedBuffer
SharedBuffer & operator=(SharedBuffer &&)=default
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.
void destructorWaitFor(auto const &any)
Add an action to be executed when the shared_ptr is destroyed.
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.
std::shared_ptr< internal::ManagedDealloc > m_deleter
auto getSubSharedBuffer(alpaka::concepts::VectorOrScalar auto const &extents)
SharedBuffer(SharedBuffer< T_Api, T_Type_Other, T_Extents, T_MemAlignment > const &other)