30 alpaka::concepts::Api T_Api,
32 alpaka::concepts::Vector T_Extents,
33 alpaka::concepts::Alignment T_MemAlignment =
Alignment<>>
36 template<
typename T_ValueType, concepts::Alignment T_MemAlignment = Alignment<>>
41 T_MemAlignment
const memAlignment = T_MemAlignment{})
47 template<
typename T_ValueType, concepts::Alignment T_MemAlignment = Alignment<>>
53 T_MemAlignment
const memAlignment = T_MemAlignment{})
74 struct View :
MdSpan<T_Type, typename T_Extents::UniVec, typename T_Extents::UniVec, T_MemAlignment>
93 T_UserExtents
const& extents,
94 T_UserPitches
const& pitches,
95 T_MemAlignment
const memAlignment = T_MemAlignment{})
98 typename T_UserExtents::UniVec{extents},
99 typename T_UserPitches::UniVec{pitches},
105 "extent type and pitch type must be lossless convertible");
108 template<
typename T_Type_Other>
109 requires alpaka::internal::concepts::InnerTypeAllowedCast<T_Type, T_Type_Other>
111 : BaseMdSpan{static_cast<BaseMdSpan>(other)}
117 template<
typename T_Type_Other>
118 requires alpaka::internal::concepts::InnerTypeAllowedCast<T_Type, T_Type_Other>
120 : BaseMdSpan{
std::move(static_cast<BaseMdSpan>(other))}
146 return BaseMdSpan{*
this};
152 using ConstValueType = std::add_const_t<typename BaseMdSpan::value_type>;
155 static_cast<ConstValueType*
>(this->
data()),
174 Vec extentMd = extents;
175 assert((extentMd <= this->
getExtents()).reduce(std::logical_and{}));
182 Vec extentMd = extents;
183 assert((extentMd <= this->
getExtents()).reduce(std::logical_and{}));
209 Vec offsetMd = offset;
210 Vec extentMd = extents;
211 assert((offsetMd + extentMd <= this->
getExtents()).reduce(std::logical_and{}));
212 auto shiftedPtr = &(*this)[offsetMd];
223 Vec offsetMd = offset;
224 Vec extentMd = extents;
225 assert((offsetMd + extentMd <= this->
getExtents()).reduce(std::logical_and{}));
226 auto shiftedPtr = &(*this)[offsetMd];
232 template<alpaka::concepts::Vector LowHaloVecType, alpaka::concepts::Vector UpHaloVecType>
240 for(uint32_t i = 0; i <
dim; ++i)
242 switch(boundaryDir.data[i])
246 extents[i] = boundaryDir.lowerHaloSize[i];
249 offset[i] = this->
getExtents()[i] - boundaryDir.upperHaloSize[i];
250 extents[i] = boundaryDir.upperHaloSize[i];
253 offset[i] = boundaryDir.lowerHaloSize[i];
254 extents[i] = this->
getExtents()[i] - boundaryDir.lowerHaloSize[i] - boundaryDir.upperHaloSize[i];
257 throw std::invalid_argument(
"invalid direction");
264 template<
typename T_Api,
typename T_Type, concepts::Vector T_Extents, concepts::Alignment T_MemAlignment>
269 <<
" , alignment=" << T_MemAlignment::template
get<T_Type>() <<
" }";
281 T_UserExtents
const&,
282 T_UserPitches
const&,
283 T_MemAlignment
const memAlignment)
295namespace alpaka::internal
303 struct GetApi::Op<
alpaka::
View<T_Api, T_Type, T_Extents, T_MemAlignment>>
305 inline constexpr auto operator()(
auto&& view)
const
307 alpaka::unused(view);
313 alpaka::concepts::Api T_Api,
315 alpaka::concepts::Vector T_Extents,
316 alpaka::concepts::Alignment T_MemAlignment>
317 struct CopyConstructableDataSource<
View<T_Api, T_Type, T_Extents, T_MemAlignment>> : std::true_type
#define ALPAKA_FN_HOST_ACC
All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_F...
#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:...
Interface concept for objects describing multidimensional memory access.
Concept to check if a type is a vector or scalar variable.
Concept to check if a type is a vector.
decltype(auto) data(auto &&any)
pointer to data of an object
decltype(auto) getExtents(auto &&any)
Object extents.
std::convertible_to< std::string > auto getName(auto &&any)
Runtime name for a given object.
decltype(auto) getPitches(auto &&any)
Object pitches.
constexpr uint32_t getDim_v
std::ostream & operator<<(std::ostream &os, concepts::BoundaryDirection auto const &bd)
constexpr auto calculatePitchesFromExtents(T_Vec const &extent)
Calculate the pitches purely from the extents.
ALPAKA_FN_HOST_ACC View(T_Any const &, T_Type *, T_UserExtents const &, T_UserPitches const &, T_MemAlignment const memAlignment) -> View< ALPAKA_TYPEOF(getApi(std::declval< T_Any >())), T_Type, typename T_UserPitches::UniVec, T_MemAlignment >
constexpr auto getAlignment(auto &&any)
Get the value type alignment of an object.
constexpr bool isLosslesslyConvertible_v
constexpr decltype(auto) getApi(auto &&any)
Get the API an object depends on.
constexpr auto makeView(auto &&anyWithApi, T_ValueType *pointer, concepts::Vector auto const &extents, T_MemAlignment const memAlignment=T_MemAlignment{})
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
Strongly typed and constexpr representation of a byte-alignment of memory.
An n-dimensional boundary direction.
constexpr MdSpan()=default
constexpr auto getExtents() const
static consteval uint32_t dim()
constexpr auto getConstMdSpan() const
constexpr const_pointer data() const
constexpr T_Pitches getPitches() const
constexpr View & operator=(View const &)=default
Assignment operator keeping const-ness.
constexpr auto getSubView(alpaka::BoundaryDirection< View::dim(), LowHaloVecType, UpHaloVecType > boundaryDir) const
constexpr auto getSubView(alpaka::concepts::VectorOrScalar auto const &extents)
Creates a sub view to a part of the memory.
static consteval T_Api getApi()
constexpr alpaka::concepts::IMdSpan auto getMdSpan() const
constexpr auto getSubView(alpaka::concepts::VectorOrScalar auto const &offset, alpaka::concepts::VectorOrScalar auto const &extents)
Creates a sub view to a part of the memory.
constexpr View(View< T_Api, T_Type_Other, T_Extents, T_MemAlignment > const &other)
constexpr View & operator=(View &&)=default
constexpr auto getSubView(alpaka::concepts::VectorOrScalar auto const &offset, alpaka::concepts::VectorOrScalar auto const &extents) const
Creates a sub view to a part of the memory.
constexpr auto getConstView() const
create a read only view
constexpr alpaka::concepts::IMdSpan auto getMdSpan()
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 getSubView(alpaka::concepts::VectorOrScalar auto const &extents) const
Creates a sub view to a part of the memory.
constexpr View(View< T_Api, T_Type_Other, T_Extents, T_MemAlignment > &&other)
constexpr View(View &&)=default
constexpr View(View const &)=default