test if a type can be vectorized
Matthias Kretz
[please enable javascript to see the address]
Thu Oct 5 11:11:17 CEST 2017
On Montag, 2. Oktober 2017 19:17:03 CEST Kay F. Jahnke wrote:
> // instead of the blanket statement:
>
> // template<typename T> struct
> // is_simd_vector_internal<Vector<T, VectorAbi::Avx>>
> // : public std::true_type {};
>
> // partial specialization only for vectorizable types,
> // which is a bit like an 'enumeration'
>
> template<> struct
> is_simd_vector_internal<Vector<double, VectorAbi::Avx>>
>
> : public std::true_type {};
>
> template<> struct
> is_simd_vector_internal<Vector<float, VectorAbi::Avx>>
>
> : public std::true_type {};
> [...]
Ah yes. This can be generalized further to:
template <class T> struct is_valid_vector_argument
: public std::false_type {};
template <> struct is_valid_vector_argument<double>
: public std::true_type {};
template <> struct is_valid_vector_argument<float>
: public std::true_type {};
template <> struct is_valid_vector_argument<int>
: public std::true_type {};
template <> struct is_valid_vector_argument<uint>
: public std::true_type {};
template <> struct is_valid_vector_argument<short>
: public std::true_type {};
template <> struct is_valid_vector_argument<ushort>
: public std::true_type {};
And then:
template <class T> struct
is_simd_vector_internal<Vector<T, VectorAbi::Avx>>
: public is_valid_vector_argument<T> {};
I'd accept a pull request. ;-)
Cheers,
Matthias
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://kretzfamily.de
GSI Helmholtzzentrum für Schwerionenforschung https://gsi.de
SIMD easy and portable https://github.com/VcDevel/Vc
──────────────────────────────────────────────────────────────────────────
More information about the Vc
mailing list