26#if ALPAKA_HAS_STD_SIMD
32 template<
typename T_Type, u
int32_t T_w
idth>
34 :
protected alpakaStdSimd::rebind_simd_t<T_Type, alpakaStdSimd::fixed_size_simd<T_Type, T_width>>
36 using BaseType = alpakaStdSimd::rebind_simd_t<T_Type, alpakaStdSimd::fixed_size_simd<T_Type, T_width>>;
38 using value_type =
typename BaseType::value_type;
39 using reference =
typename BaseType::reference;
41 using BaseType::operator[];
43 constexpr StdSimd() =
default;
44 constexpr StdSimd(StdSimd
const&) =
default;
45 constexpr StdSimd(StdSimd&&) =
default;
46 constexpr StdSimd& operator=(StdSimd&& rhs) =
default;
48 constexpr StdSimd& operator=(StdSimd
const& rhs) =
default;
50 constexpr StdSimd& operator=(T_Type
const value)
52 this->asNativeType() = value;
57 template<
typename... T_Args>
58 requires(
sizeof...(T_Args) == T_width && (std::same_as<T_Args, T_Type> && ...))
60 : BaseType([=](
int i) constexpr {
return std::array<T_Type, T_width>{args...}[i]; })
64 constexpr StdSimd(BaseType
const& nativeSimd) : BaseType{nativeSimd}
73 constexpr auto& asNativeType()
75 return static_cast<BaseType&
>(*this);
78 constexpr auto const& asNativeType()
const
80 return static_cast<BaseType const&
>(*this);
85 constexpr decltype(
auto)
where(alpaka::concepts::SimdMask
auto const& mask)
const
87 return alpakaStdSimd::where(mask.asNativeType(), asNativeType());
90 constexpr decltype(
auto)
where(alpaka::concepts::SimdMask
auto const& mask)
92 return alpakaStdSimd::where(mask.asNativeType(), asNativeType());
95 static constexpr auto fill(T_Type value)
97 return StdSimd{BaseType(value)};
100 constexpr void copyFrom(T_Type
const* data, alpaka::concepts::Alignment
auto alignment)
102 if constexpr((alignment.template get<T_Type>() % alpakaStdSimd::memory_alignment_v<BaseType>) == 0u)
103 this->asNativeType().copy_from(data, alpakaStdSimd::vector_aligned);
105 this->asNativeType().copy_from(data, alpakaStdSimd::element_aligned);
108 constexpr void copyTo(
auto* data, alpaka::concepts::Alignment
auto alignment)
const
110 if constexpr((alignment.template get<T_Type>() % alpakaStdSimd::memory_alignment_v<BaseType>) == 0u)
111 this->asNativeType().copy_to(data, alpakaStdSimd::vector_aligned);
113 this->asNativeType().copy_to(data, alpakaStdSimd::element_aligned);
118# define ALPAKA_VECTOR_ASSIGN_OP(op) \
119 constexpr StdSimd& operator op(StdSimd const& rhs) \
121 this->asNativeType() op rhs.asNativeType(); \
124 constexpr StdSimd& operator op(T_Type const value) \
126 this->asNativeType() op value; \
135# undef ALPAKA_VECTOR_ASSIGN_OP
138# define ALPAKA_VECTOR_BINARY_OP(typenameOrConcept, op) \
139 template<typenameOrConcept T_Type, uint32_t T_width> \
140 constexpr auto operator op(const StdSimd<T_Type, T_width>& lhs, const StdSimd<T_Type, T_width>& rhs) \
142 return StdSimd<T_Type, T_width>{lhs.asNativeType() op rhs.asNativeType()}; \
144 template<typenameOrConcept T_Type, uint32_t T_width> \
145 constexpr auto operator op(const StdSimd<T_Type, T_width>& lhs, T_Type rhs) \
147 return StdSimd<T_Type, T_width>{lhs.asNativeType() op rhs}; \
149 template<typenameOrConcept T_Type, uint32_t T_width> \
150 constexpr auto operator op(T_Type lhs, const StdSimd<T_Type, T_width>& rhs) \
152 return StdSimd<T_Type, T_width>{lhs op rhs.asNativeType()}; \
174# if defined(__clang__) && defined(__GLIBCXX__) && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE == 12)
175 template<std::
integral T_Type, u
int32_t T_w
idth>
176 constexpr auto operator%(
const StdSimd<T_Type, T_width>& lhs,
const StdSimd<T_Type, T_width>& rhs)
178 using BaseType =
typename StdSimd<T_Type, T_width>::BaseType;
179 return StdSimd<T_Type, T_width>(
180 BaseType([&](
int i) {
return lhs.asNativeType()[i] % rhs.asNativeType()[i]; }));
183 template<std::
integral T_Type, u
int32_t T_w
idth>
184 constexpr auto operator%(StdSimd<T_Type, T_width>
const& lhs, T_Type rhs)
186 using BaseType =
typename StdSimd<T_Type, T_width>::BaseType;
187 return StdSimd<T_Type, T_width>(BaseType([&](
int i) {
return lhs.asNativeType()[i] % rhs; }));
190 template<std::
integral T_Type, u
int32_t T_w
idth>
191 constexpr auto operator%(T_Type lhs, StdSimd<T_Type, T_width>
const& rhs)
193 using BaseType =
typename StdSimd<T_Type, T_width>::BaseType;
194 return StdSimd<T_Type, T_width>(BaseType([&](
int i) {
return lhs % rhs.asNativeType()[i]; }));
199# undef ALPAKA_VECTOR_BINARY_OP
205 template<
typename T_Type, u
int32_t T_w
idth>
207 std::has_single_bit(T_width) && std::has_single_bit(
sizeof(T_Type))
208 && alpakaStdSimd::fixed_size_simd<T_Type, T_width>::size() > 0)
211 using type = internal::StdSimd<T_Type, T_width>;
#define ALPAKA_VECTOR_ASSIGN_OP(op)
assign operator
#define ALPAKA_VECTOR_BINARY_OP(typenameOrConcept, op)
binary operators
#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...
void fill(auto &internalQueue, auto executor, alpaka::concepts::IMdSpan< T_Value > auto &&dest, T_Value elementValue)
alpaka internal implementations.
constexpr auto operator%(const EmuSimd< T_Type, T_width > &lhs, const EmuSimd< T_Type, T_width > &rhs)
constexpr SimdWhereExpr< T_Mask, T_Simd > where(T_Mask const &mask, T_Simd &value)
Conditionally update each component of an SIMD pack.
Get the storage type for a SIMD pack.