15 template<concepts::Vector T_ThreadIdx, concepts::Vector T_ThreadCount>
18 constexpr ThreadSpace(T_ThreadIdx
const& threadIdx, T_ThreadCount
const& threadCount)
24 std::string
toString(std::string
const separator =
",", std::string
const enclosings =
"{}")
const
26 std::string locale_enclosing_begin;
27 std::string locale_enclosing_end;
28 size_t enclosing_dim = enclosings.size();
33 locale_enclosing_begin = enclosings[0 % enclosing_dim];
34 locale_enclosing_end = enclosings[1 % enclosing_dim];
37 std::stringstream stream;
38 stream << locale_enclosing_begin;
40 stream << locale_enclosing_end;
44 constexpr auto size()
const
49 constexpr auto idx()
const
54 template<concepts::CVector T_CSelect>
55 constexpr ThreadSpace mapTo(T_CSelect selection)
const requires(T_ThreadIdx::dim() <= T_CSelect::dim())
57 alpaka::unused(selection);
58 static_assert(T_ThreadIdx::dim() == T_CSelect::dim(),
"can not map to a larger dimension");
62 template<concepts::CVector T_CSelect>
63 constexpr auto mapTo(T_CSelect selection)
const requires(T_ThreadIdx::dim() > T_CSelect::dim())
65 alpaka::unused(selection);
67 using IdxType =
typename T_ThreadIdx::type;
68 constexpr uint32_t dim = T_ThreadIdx::dim();
71 constexpr auto notSelectedDims =
filter(allElements, T_CSelect{});
78 for(uint32_t x = 0u; x < notSelectedDims.dim(); ++x)
80 auto d = notSelectedDims[x];
81 auto old = threadIndex[d];
83 threadIndex[T_CSelect{}[0]] += old * numThreads[T_CSelect{}[0]];
86 for(uint32_t x = 0u; x < notSelectedDims.dim(); ++x)
88 auto d = notSelectedDims[x];
89 auto old = numThreads[d];
91 numThreads[T_CSelect{}[0]] *= old;
100 using type =
typename T_ThreadIdx::type;
105 template<
typename T_To,
typename T_ThreadIdx,
typename T_ThreadCount>
106 struct PCast::Op<T_To,
ThreadSpace<T_ThreadIdx, T_ThreadCount>>
108 constexpr auto operator()(
auto&& input)
const
109 requires std::convertible_to<typename T_ThreadIdx::type, T_To>
110 && (!std::same_as<T_To, typename T_ThreadIdx::type>)
115 constexpr decltype(
auto)
operator()(
auto&& input)
const
116 requires std::same_as<T_To, typename T_ThreadIdx::type>
118 return std::forward<decltype(input)>(input);
123 template<std::
size_t I,
typename T_ThreadIdx,
typename T_ThreadCount>
126 return v.m_threadIdx;
129 template<std::
size_t I,
typename T_ThreadIdx,
typename T_ThreadCount>
132 return v.m_threadIdx;
135 template<std::
size_t I,
typename T_ThreadIdx,
typename T_ThreadCount>
138 return v.m_threadCount;
141 template<std::
size_t I,
typename T_ThreadIdx,
typename T_ThreadCount>
144 return v.m_threadCount;
151 template<
typename T_ThreadIdx,
typename T_ThreadCount>
152 struct tuple_size<
alpaka::ThreadSpace<T_ThreadIdx, T_ThreadCount>>
154 static constexpr std::size_t value = 2u;
157 template<std::
size_t I,
typename T_ThreadIdx,
typename T_ThreadCount>
158 struct tuple_element<I,
alpaka::ThreadSpace<T_ThreadIdx, T_ThreadCount>>
160 using type = std::conditional_t<I == 0u, T_ThreadIdx, T_ThreadCount>;
#define ALPAKA_TYPEOF(...)
Get the type of instance.
consteval auto iotaCVec()
Create and return a CVector of the given length with values 1, 2, ...
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
constexpr auto filter(concepts::CVector auto left, concepts::CVector auto right)
Filter the left vector with the right vector's values.
constexpr decltype(auto) pCast(auto &&input)
Performs a static_cast on the storage type of combined data type.
constexpr ThreadSpace mapTo(T_CSelect selection) const
typename T_ThreadIdx::type type
constexpr auto size() const
constexpr auto mapTo(T_CSelect selection) const
constexpr ThreadSpace(T_ThreadIdx const &threadIdx, T_ThreadCount const &threadCount)
std::string toString(std::string const separator=",", std::string const enclosings="{}") const
constexpr auto idx() const
T_ThreadCount m_threadCount