23 std::integral
auto T_limit,
24 std::integral
auto T_index,
25 std::integral
auto T_increment,
26 std::integral
auto... T_idx>
29 if constexpr(input.product() <=
static_cast<typename
ALPAKA_TYPEOF(input)::type
>(T_limit))
33 constexpr uint32_t dim =
static_cast<uint32_t
>(
sizeof...(T_idx));
35 constexpr auto newValue =
CVec<
38 : input[T_idx])...>{};
40 constexpr auto nextIncrement = dim == 1u ? 0u : T_increment;
41 constexpr auto nextIdx = T_index + T_increment;
43 if constexpr(nextIdx == dim)
45 constexpr auto nextIncrement = dim == 1u ? 0u : -1u;
47 return adjustToLimit<T_limit, (dim == 1 ? 0 : dim - 1u), nextIncrement>(
49 std::index_sequence<T_idx...>{});
51 else if constexpr(nextIdx == 0u)
63 template<std::
integral auto T_limit, std::
integral auto T_index, std::
integral auto T_increment>
74 constexpr uint32_t dim = input.dim();
75 IdxType limitValue =
static_cast<IdxType
>(limit);
77 while(input.product() > limitValue)
80 auto maxValue = input[0];
81 for(
auto i = 0u; i < dim; ++i)
82 if(maxValue < input[i])
87 if(input.product() > limitValue)
88 input[maxIdx] =
divExZero(input[maxIdx], IdxType{2u});
100 template<
typename T_ValueType, alpaka::concepts::Vector T_Extents>
103 constexpr auto dim = T_Extents::dim();
104 if constexpr(dim == 1u)
106 size_t memSizeInByte =
static_cast<size_t>(extents.x()) *
sizeof(T_ValueType);
108 return std::make_tuple(memSizeInByte, pitches);
112 using IdxType =
typename T_Extents::type;
113 auto alignment =
static_cast<IdxType
>(alignmentInByte);
115 IdxType rowExtentInBytes = extents.x() *
static_cast<IdxType
>(
sizeof(T_ValueType));
116 IdxType rowPitchInBytes =
alpaka::divCeil(rowExtentInBytes, alignment) * alignment;
119 size_t memSizeInByte =
static_cast<size_t>(pitches[0]) *
static_cast<size_t>(extents[0]);
120 return std::make_tuple(memSizeInByte, pitches);
126 uint32_t result = 1u;
127 while((result << 1u) <= value)
140 template<
typename T_ValueType>
143 constexpr uint32_t typeAlignmentBytes =
alignof(T_ValueType);
144 constexpr uint32_t simdPackBytes
147 constexpr uint32_t optimalAlignment = std::max(bestSimdPackBytes, typeAlignmentBytes);
149 return adjustedAlignment;
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Concept to check if a type is a CVector.
Concept to check if something is a device kind.
Concept to check if a type is a vector.
consteval auto adjustToLimit(concepts::CVector auto const input, std::index_sequence< T_idx... >)
consteval auto adjustToLimit(concepts::CVector auto const input)
adjust the input vector to a given limit by halving all components until the product of these is belo...
consteval uint32_t highestPowerOfTwo(uint32_t value)
auto emulatedAlignedMemDescription(uint32_t alignmentInByte, T_Extents extents)
provides a memory description to create multidimensional linewise aligned memory within a one dimensi...
constexpr auto simdOptimizedAlignment(auto api, alpaka::concepts::DeviceKind auto deviceKind)
Calculate the best alignment for SIMD optimized memory allocation.
ALPAKA_FN_HOST_ACC constexpr auto divExZero(Integral a, Integral b) -> Integral
Returns the max(a / b, 1) as integer.
ALPAKA_FN_HOST_ACC constexpr auto divCeil(Integral a, Integral b) -> Integral
Returns the ceiling of a / b, as integer.
Vec< T, sizeof...(T_values), detail::CVec< T, T_values... > > CVec
A vector with compile-time known values.
constexpr auto calculatePitches(T_Vec const &extent, typename T_Vec::type const &rowPitchBytes)
Calculate the pitches purely from the extents.
consteval uint32_t getArchSimdWidth(concepts::Api auto const api, alpaka::concepts::DeviceKind auto const deviceType)
Get the SIMD width in bytes for an API and device kind combination.
consteval uint32_t getAdjustedAlignment(concepts::Api auto const api, concepts::DeviceKind auto const deviceType, auto const alignment)
Adjusts the memory alignment based on a specific API and device kind.