Argon 0.1.0
Loading...
Searching...
No Matches
mve_compare.hpp
1#pragma once
2#include <type_traits>
3#include "argon/features.h"
4
5#ifdef ARGON_PLATFORM_MVE
6#include <arm_mve.h>
7#include "arm_simd.hpp"
8#include "bool.hpp"
9
12
13namespace argon::helpers {
14
16enum class MveComparison { Equal, GreaterThan, GreaterThanOrEqual };
17
26template <MveComparison op, typename VectorType, typename... PredicateType>
27[[gnu::always_inline]] inline mve_pred16_t mve_compare(VectorType a, VectorType b, PredicateType... active) {
28 using scalar_type = mve::Scalar_t<VectorType>;
29 if constexpr (op == MveComparison::Equal) {
30 if constexpr (!std::is_integral_v<scalar_type>) {
31 return mve::compare_equal(a, b, active...);
32 } else {
33 return mve::equal(a, b, active...);
34 }
35 } else if constexpr (op == MveComparison::GreaterThan) {
36 if constexpr (!std::is_integral_v<scalar_type>) {
37 return mve::compare_greater_than(a, b, active...);
38 } else if constexpr (std::is_signed_v<scalar_type>) {
39 return mve::greater_than(a, b, active...);
40 } else {
41 return mve::higher(a, b, active...);
42 }
43 } else {
44 if constexpr (!std::is_integral_v<scalar_type>) {
45 return mve::compare_greater_than_or_equal(a, b, active...);
46 } else if constexpr (std::is_signed_v<scalar_type>) {
47 return mve::greater_than_or_equal(a, b, active...);
48 } else {
49 return mve::higher_or_same(a, b, active...);
50 }
51 }
52}
53
58template <typename VectorType>
59[[gnu::always_inline]] inline Bool_t<VectorType> mve_mask(mve_pred16_t p) {
60 using mask_type = Bool_t<VectorType>;
61 using mask_scalar = mve::Scalar_t<mask_type>;
62 return mve::predicate_select(mve::duplicate(static_cast<mask_scalar>(~mask_scalar{0})),
63 mve::duplicate(mask_scalar{0}), p);
64}
65
66} // namespace argon::helpers
67#endif
Header file for SIMD features and platform detection.
Contains helper templates and concepts for type manipulation and compile-time utilities.
Definition argon.hpp:156
Bool< T >::type Bool_t
Helper alias to get the boolean type of a SIMD operation.
Definition bool.hpp:49