33 template<
typename T_Type, u
int32_t T_dim>
34 struct ReducedVector :
private Vec<T_Type, T_dim - 1u>
37 :
Vec<T_Type, T_dim - 1u>{first.template
rshrink<T_dim - 1u>()}
41 constexpr decltype(
auto)
operator[](T_Type idx)
const
46 constexpr decltype(
auto)
operator[](T_Type idx)
52 template<
typename T_Type>
53 struct ReducedVector<T_Type, 1u>
62 alpaka::concepts::IdxRange T_IdxRange,
63 typename T_ThreadSpace,
64 typename T_IdxMapperFn,
65 alpaka::concepts::CVector T_CSelect>
70 static_assert(std::ranges::forward_range<TiledIdxContainer>);
71 static_assert(std::ranges::borrowed_range<TiledIdxContainer>);
72 static_assert(std::ranges::range<TiledIdxContainer>);
73 static_assert(std::ranges::input_range<TiledIdxContainer>);
77 using IdxType =
typename T_IdxRange::IdxType;
78 static constexpr uint32_t
dim = T_IdxRange::dim();
82 T_IdxRange
const& idxRange,
83 T_ThreadSpace
const& threadSpace,
84 T_IdxMapperFn idxMapping,
85 T_CSelect
const& = T_CSelect{})
86 : m_idxRange(idxRange)
87 , m_threadSpace{threadSpace}
89 alpaka::unused(idxMapping);
102 class const_iterator_end
108 static_assert(std::forward_iterator<const_iterator_end>);
112 : m_extentSlowDim{extent[T_CSelect{}][0]}
118 return m_extentSlowDim;
122 constexpr bool operator==(const_iterator_end
const& other)
const
124 return (m_extentSlowDim == other.m_extentSlowDim);
127 constexpr bool operator!=(const_iterator_end
const& other)
const
129 return !(*
this == other);
134 return (m_extentSlowDim <= other.slowCurrent);
139 return !(*
this == other);
151 static constexpr uint32_t iterDim = T_CSelect::dim();
156 static_assert(std::forward_iterator<const_iterator>);
157 static_assert(std::input_iterator<const_iterator>);
165 : m_current{first + offset}
166 , m_stride{stride[T_CSelect{}]}
167 , m_extent{(extent + offset)[T_CSelect{}]}
168 , m_first((m_current)[T_CSelect{}])
171 if constexpr(iterDim > 1u)
174 bool isIndexValid =
true;
175 for(uint32_t d = 1u; d < iterDim; ++d)
176 isIndexValid = isIndexValid && (m_first[d] < m_extent[d]);
178 m_current[T_CSelect{}[0]] = m_extent[0];
186 return m_current[T_CSelect{}[0]];
198 for(uint32_t d = 0; d < iterDim; ++d)
200 uint32_t
const idx = iterDim - 1u - d;
201 m_current[T_CSelect{}[idx]] += m_stride[idx];
202 if constexpr(iterDim != 1u)
204 if(idx >= 1u && m_current[T_CSelect{}[idx]] >= m_extent[idx])
206 m_current[T_CSelect{}[idx]] = m_first[idx];
218 const_iterator old = *
this;
225 return (m_current == other.m_current);
230 return !(*
this == other);
235 return (slowCurrent() >= *other);
240 return !(*
this == other);
247 IterIdxVecType m_stride;
248 IterIdxVecType m_extent;
249 detail::ReducedVector<IdxType, iterDim> m_first;
254 constexpr auto selectedDims = T_CSelect{};
255 auto [threadIdx, numThreads] = m_threadSpace.mapTo(selectedDims);
257 if constexpr(std::is_same_v<T_IdxMapperFn, layout::Strided>)
261 threadIdx * m_idxRange.m_stride,
262 m_idxRange.distance(),
263 numThreads * m_idxRange.m_stride);
265 else if constexpr(std::is_same_v<T_IdxMapperFn, layout::Contiguous>)
275 IdxVecType firstLogical = threadIdx * base + threadIdx.
min(rem);
276 IdxVecType first = firstLogical * m_idxRange.m_stride;
279 IdxVecType endLogical = nextThreadIdx * base + nextThreadIdx.
min(rem);
289 constexpr auto selectedDims = T_CSelect{};
290 auto [threadIdx, numThreads] = m_threadSpace.mapTo(selectedDims);
292 if constexpr(std::is_same_v<T_IdxMapperFn, layout::Strided>)
296 else if constexpr(std::is_same_v<T_IdxMapperFn, layout::Contiguous>)
307 IdxVecType endLogical = nextSlotIdx * base + nextSlotIdx.
min(rem);
324 T_IdxRange m_idxRange;
325 T_ThreadSpace m_threadSpace;
special implementation to define the end
constexpr bool operator!=(const_iterator_end const &other) const
constexpr bool operator==(const_iterator const &other) const
friend class TiledIdxContainer
constexpr bool operator==(const_iterator_end const &other) const
constexpr bool operator!=(const_iterator const &other) const
constexpr bool operator==(const_iterator_end const &other) const
ALPAKA_FN_ACC const_iterator operator++(int)
constexpr bool operator!=(const_iterator_end const &other) const
constexpr bool operator!=(const_iterator const &other) const
constexpr bool operator==(const_iterator const &other) const
ALPAKA_FN_ACC const_iterator & operator++()
friend class TiledIdxContainer
constexpr IdxVecType operator*() const
friend class const_iterator_end
ALPAKA_FN_ACC const_iterator begin() const
constexpr TiledIdxContainer(TiledIdxContainer &&)=default
Vec< IdxType, dim > IdxVecType
static constexpr uint32_t dim
ALPAKA_FN_ACC TiledIdxContainer(T_IdxRange const &idxRange, T_ThreadSpace const &threadSpace, T_IdxMapperFn idxMapping, T_CSelect const &=T_CSelect{})
ALPAKA_FN_ACC const_iterator_end end() const
typename T_IdxRange::IdxType IdxType
ALPAKA_FN_HOST_ACC constexpr auto operator[](alpaka::concepts::CVector auto const iterDir) const
constexpr TiledIdxContainer(TiledIdxContainer const &)=default
#define ALPAKA_FN_ACC
All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_F...
#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...
Concept to check if a type is a CVector.
Concept to check if a type is a vector.
functionality which is usable on the accelerator compute device from within a kernel.
ALPAKA_FN_HOST_ACC constexpr auto divCeil(Integral a, Integral b) -> Integral
Returns the ceiling of a / b, as integer.
ALPAKA_FN_HOST_ACC Vec(T_1, T_Args...) -> Vec< T_1, uint32_t(sizeof...(T_Args)+1u), ArrayStorage< T_1, uint32_t(sizeof...(T_Args)+1u)> >
constexpr auto operator*(const Simd< T_Type, T_width, T_Storage > &lhs, const Simd< T_Type, T_width, T_OtherStorage > &rhs)
binary operators
constexpr auto min(Vec< T_Type, T_dim, T_OtherStorage > const &rhs) const
constexpr Vec< T_Type, T_numElements > rshrink() const
constexpr decltype(auto) operator[](std::integral auto const idx)