31 template<
typename T_Type, u
int32_t T_w
idth>
32 struct alignas(alpaka::internal::optimalAlignment<
34 ALPAKA_TYPEOF(internal::valueMaskCast<T_Type>(true)),
38 Alignment<sizeof(ALPAKA_TYPEOF(internal::valueMaskCast<T_Type>(true))) * T_width>>())
39 EmuSimdMask :
protected std::array<ALPAKA_TYPEOF(internal::valueMaskCast<T_Type>(true)), T_width>
41 using ValueMaskType =
ALPAKA_TYPEOF(internal::valueMaskCast<T_Type>(
true));
43 using BaseType = std::array<ValueMaskType, T_width>;
45 using value_type = bool;
46 using reference = SmartMaskValueRef<bool, ValueMaskType>;
48 using BaseType::operator[];
50 constexpr reference operator[](std::integral
auto const idx)
52 return reference(BaseType::operator[](idx));
55 constexpr EmuSimdMask() =
default;
57 constexpr EmuSimdMask(EmuSimdMask
const& other)
60 for(uint32_t i = 0u; i < T_width; ++i)
61 BaseType::operator[](i) = other[i];
64 constexpr EmuSimdMask(EmuSimdMask&&) =
default;
66 constexpr EmuSimdMask& operator=(EmuSimdMask&& rhs) =
default;
68 constexpr EmuSimdMask& operator=(EmuSimdMask
const& rhs) =
default;
70 constexpr EmuSimdMask& operator=(T_Type
const value)
72 for(uint32_t i = 0u; i < T_width; i++)
74 asNativeType()[i] = value;
80 template<
typename... T_Args>
81 requires(
sizeof...(T_Args) == T_width && (std::same_as<T_Args, T_Type> && ...))
82 constexpr EmuSimdMask(T_Args const&... args) : BaseType{args...}
86 template<
typename... T_Args>
87 requires(
sizeof...(T_Args) == T_width && (std::same_as<T_Args, bool> && ...))
88 constexpr EmuSimdMask(T_Args... args) : BaseType{valueMaskCast<T_Type>(args)...}
92 constexpr EmuSimdMask(BaseType
const& base) : BaseType{base}
101 constexpr auto& asNativeType()
103 return static_cast<EmuSimdMask&
>(*this);
106 constexpr auto const& asNativeType()
const
108 return static_cast<EmuSimdMask const&
>(*this);
113 static constexpr auto fill(
bool value)
115 auto maskValue = valueMaskCast<T_Type>(value);
117 for(uint32_t i = 0u; i < T_width; ++i)
120 return EmuSimdMask(ret);
123 constexpr void copyFrom(T_Type
const* data, alpaka::concepts::Alignment
auto alignment)
126 *(
this) = *
reinterpret_cast<ALPAKA_TYPEOF(*this) const*
>(data);
129 for(uint32_t i = 0u; i < T_width; ++i)
130 asNativeType()[i] =
data[i];
134 constexpr void copyTo(
auto* data, alpaka::concepts::Alignment
auto alignment)
const
140 for(uint32_t i = 0u; i < T_width; ++i)
141 data[i] = asNativeType()[i];
147#define ALPAKA_VECTOR_ASSIGN_OP(op) \
148 template<typename T_OtherStorage> \
149 constexpr EmuSimdMask& operator op(EmuSimdMask const& rhs) \
151 for(uint32_t i = 0u; i < T_width; i++) \
153 asNativeType()[i] op rhs[i]; \
157 constexpr EmuSimdMask& operator op(T_Type const value) \
159 for(uint32_t i = 0u; i < T_width; i++) \
161 asNativeType()[i] op value; \
169#undef ALPAKA_VECTOR_ASSIGN_OP
172#define ALPAKA_VECTOR_BINARY_CMP_OP(returnSimdType, argSimdType, typenameOrConcept, op) \
173 template<typenameOrConcept T_Type, uint32_t T_width> \
174 constexpr auto operator op(const argSimdType<T_Type, T_width>& lhs, const argSimdType<T_Type, T_width>& rhs) \
176 returnSimdType<T_Type, T_width> ret{}; \
177 for(uint32_t i = 0u; i < T_width; i++) \
178 ret[i] = valueMaskCast<T_Type>(lhs[i] op rhs[i]); \
181 template<typenameOrConcept T_Type, uint32_t T_width> \
182 constexpr auto operator op(const argSimdType<T_Type, T_width>& lhs, T_Type rhs) \
184 returnSimdType<T_Type, T_width> ret{}; \
185 for(uint32_t i = 0u; i < T_width; i++) \
186 ret[i] = valueMaskCast<T_Type>(lhs[i] op rhs); \
189 template<typenameOrConcept T_Type, uint32_t T_width> \
190 constexpr auto operator op(T_Type lhs, const argSimdType<T_Type, T_width>& rhs) \
192 returnSimdType<T_Type, T_width> ret{}; \
193 for(uint32_t i = 0u; i < T_width; i++) \
194 ret[i] = valueMaskCast<T_Type>(lhs op rhs[i]); \
210#undef ALPAKA_VECTOR_BINARY_CMP_OP
215 template<concepts::Api T_Api,
typename T_Type, u
int32_t T_w
idth>
218 using type = internal::EmuSimdMask<T_Type, T_width>;
}; } }
#define ALPAKA_VECTOR_BINARY_CMP_OP(typenameOrConcept, op)
binary operators
#define ALPAKA_VECTOR_ASSIGN_OP(op)
assign operator
#define ALPAKA_TYPEOF(...)
Get the type of instance.
decltype(auto) data(auto &&any)
pointer to data of an object
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
Get the storage type for a SIMD mask pack.
internal::EmuSimdMask< T_Type, T_width > type