65 template<
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
72 template<concepts::SimdMask T_Mask, concepts::Simd T_Simd>
75 template<
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
91 static_assert(T_width > 0u);
103 requires(std::is_invocable_v<F, std::integral_constant<uint32_t, 0u>>)
105 :
SimdMask(std::forward<F>(generator), std::make_integer_sequence<uint32_t, T_width>{})
125 template<
typename... T_Args>
127 ((std::is_convertible_v<T_Args, T_Type> && !std::same_as<bool, T_Args>) && ...)
128 && (
sizeof...(T_Args) == T_width))
133 template<
typename... T_Args>
134 requires((std::same_as<T_Args, bool> && ...) && (
sizeof...(T_Args) == T_width))
151 template<
typename T_OtherStorage>
158 constexpr explicit operator bool()
requires(T_width == 1u)
160 return static_cast<bool>(Storage::operator[](0));
171 Storage::copyFrom(data, alignment);
176 Storage::copyTo(data, alignment);
185 static constexpr auto fill(
bool value)
187 return SimdMask{Storage::fill(value)};
198 using Storage::asNativeType;
209 return static_cast<Storage&
>(*this);
214 return static_cast<Storage const&
>(*this);
222#define ALPAKA_VECTOR_ASSIGN_OP(op) \
223 template<typename T_OtherStorage> \
224 constexpr SimdMask& operator op(SimdMask<T_Type, T_width, T_OtherStorage> const& rhs) \
226 this->asStorage() op rhs.asStorage(); \
229 constexpr SimdMask& operator op(concepts::LosslesslyConvertible<T_Type> auto const value) \
231 this->asStorage() op static_cast<T_Type>(value); \
240#undef ALPAKA_VECTOR_ASSIGN_OP
246 return Storage::operator[](idx);
251 return static_cast<type>(Storage::operator[](idx));
270#define ALPAKA_NAMED_ARRAY_ACCESS(functionName, laneIdx) \
271 constexpr reference functionName() requires(T_width >= laneIdx + 1) \
273 return (*this)[laneIdx]; \
275 constexpr type functionName() const requires(T_width >= laneIdx + 1) \
277 return (*this)[laneIdx]; \
307#undef ALPAKA_NAMED_ARRAY_ACCESS
337 std::string
toString(std::string
const separator =
",", std::string
const enclosings =
"{}")
const
339 std::string locale_enclosing_begin;
340 std::string locale_enclosing_end;
341 size_t enclosingLaneIdx = enclosings.size();
343 if(enclosingLaneIdx > 0)
346 locale_enclosing_begin = enclosings[0 % enclosingLaneIdx];
347 locale_enclosing_end = enclosings[1 % enclosingLaneIdx];
350 std::stringstream stream;
351 stream << locale_enclosing_begin << Storage::operator[](0);
353 for(uint32_t i = 1u; i < T_width; ++i)
354 stream << separator << Storage::operator[](i);
355 stream << locale_enclosing_end;
360 template<
typename F, uint32_t... Is>
362 :
Storage{generator(
std::integral_constant<uint32_t, Is>{})...}
373 template<u
int32_t T_start = 0u, u
int32_t T_end = w
idth()>
377 constexpr uint32_t size = T_end - T_start;
379 if constexpr(size == 1u)
381 return (*
this)[T_start];
385 auto result = (*this)[T_start];
386 for(uint32_t i = T_start + 1u; i < T_end; ++i)
388 result = reduceFunc(result, (*
this)[i]);
393 constexpr uint32_t mid = T_start + size / 2u;
402 template<concepts::SimdMask Mask, concepts::Simd T_Simd>
406 template<std::
size_t I,
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
412 template<std::
size_t I,
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
418 template<
typename Type, u
int32_t T_w
idth,
typename T_Storage>
425 template<
typename T_1,
typename... T_Args>
433 template<
typename T,
typename... T_Args>
434 requires((std::same_as<std::remove_cvref_t<T_Args>,
bool>) && ...)
442#define ALPAKA_VECTOR_BINARY_OP(typenameOrConcept, op) \
443 template<typenameOrConcept T_Type, uint32_t T_width, typename T_Storage, typename T_OtherStorage> \
444 constexpr auto operator op( \
445 const SimdMask<T_Type, T_width, T_Storage>& lhs, \
446 const SimdMask<T_Type, T_width, T_OtherStorage>& rhs) \
448 using StoreageType = ALPAKA_TYPEOF(lhs.asStorage() op rhs.asStorage()); \
449 return SimdMask<T_Type, T_width, StoreageType>(lhs.asStorage() op rhs.asStorage()); \
452 typenameOrConcept T_Type, \
453 concepts::LosslesslyConvertible<T_Type> T_ValueType, \
455 typename T_Storage> \
456 constexpr auto operator op(const SimdMask<T_Type, T_width, T_Storage>& lhs, T_ValueType rhs) \
458 using StoreageType = ALPAKA_TYPEOF(lhs.asStorage() op static_cast<T_Type>(rhs)); \
459 return SimdMask<T_Type, T_width, StoreageType>(lhs.asStorage() op static_cast<T_Type>(rhs)); \
462 typenameOrConcept T_Type, \
463 concepts::LosslesslyConvertible<T_Type> T_ValueType, \
465 typename T_Storage> \
466 constexpr auto operator op(T_ValueType lhs, const SimdMask<T_Type, T_width, T_Storage>& rhs) \
468 using StoreageType = ALPAKA_TYPEOF(static_cast<T_Type>(lhs) op rhs.asStorage()); \
469 return SimdMask<T_Type, T_width, StoreageType>(static_cast<T_Type>(lhs) op rhs.asStorage()); \
480#undef ALPAKA_VECTOR_BINARY_OP
487 template<
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
490 static constexpr uint32_t
value = T_width;
493 template<
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
502 template<
typename T_To,
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
506 requires std::convertible_to<T_Type, T_To> && (!std::same_as<T_To, T_Type>)
509 [&](uint32_t idx)
constexpr {
return static_cast<T_To
>(input[idx]); });
512 constexpr decltype(
auto)
operator()(
auto&& input)
const requires std::same_as<T_To, T_Type>
514 return std::forward<decltype(input)>(input);
522 template<
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
523 struct tuple_size<
alpaka::SimdMask<T_Type, T_width, T_Storage>>
525 static constexpr std::size_t
value = T_width;
528 template<std::
size_t I,
typename T_Type, u
int32_t T_w
idth,
typename T_Storage>
529 struct tuple_element<I,
alpaka::SimdMask<T_Type, T_width, T_Storage>>
#define ALPAKA_VECTOR_BINARY_OP(typenameOrConcept, op)
#define ALPAKA_NAMED_ARRAY_ACCESS(functionName, laneIdx)
#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...
#define ALPAKA_TYPEOF(...)
Get the type of instance.
#define ALPAKA_FORWARD(instance)
Perfectly forward an instance as argument.
Concept to check for an alignment object.
alpaka internal implementations.
std::ostream & operator<<(std::ostream &os, concepts::BoundaryDirection auto const &bd)
constexpr auto makeSimdMask(T_Args... args)
Creates a mask for the given type.
constexpr auto thisApi()
provides the API used during the execution of the current code path
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
constexpr type reduce_range(auto &&reduceFunc) const
reduce over a range of elements
constexpr type reduce(auto &&reduceFunc) const
reduce all elements to a single value
ALPAKA_FN_HOST_ACC SimdMask(F &&generator)
Initialize via a generator expression.
constexpr reference operator[](std::integral auto const idx)
static consteval uint32_t width()
Number of components/lanes in the SIMD pack.
constexpr SimdMask toRT() const
friend struct SimdWhereExpr
constexpr SimdMask & operator=(SimdMask &&)=default
constexpr void copyTo(auto *data, concepts::Alignment auto alignment) const
ALPAKA_FN_HOST_ACC SimdMask(SimdMask< T_Type, T_width, T_OtherStorage > const &other)
constructor allows changing the storage policy
constexpr auto & asStorage()
std::string toString(std::string const separator=",", std::string const enclosings="{}") const
create string out of the SIMD pack
constexpr SimdMask & operator=(SimdMask const &)=default
ALPAKA_FN_HOST_ACC SimdMask(typename T_Storage::BaseType const &base)
SimdMask< T_Type, T_width > UniSimdMask
ALPAKA_FN_HOST_ACC SimdMask(F &&generator, std::integer_sequence< uint32_t, Is... >)
constexpr type operator[](std::integral auto const idx) const
ALPAKA_FN_HOST_ACC SimdMask(T_Args const &... args)
Constructor for SIMD pack.
ALPAKA_FN_HOST_ACC SimdMask(T_Storage const &other)
typename Storage::reference reference
type is an implementation detail, can be a proxy type.
constexpr auto const & asStorage() const
static cast the instance to the storage type
static constexpr auto fill(bool value)
Creates a Simd where all lanes are set to the same value.
constexpr void copyFrom(T_Type const *data, concepts::Alignment auto alignment)
SimdMask(SimdMask const &other)=default
constexpr auto operator()(auto &&input) const
static constexpr uint32_t value
Get the storage type for a SIMD mask pack.
static constexpr std::size_t value