Commit 01dbb494 authored by Jö Fahlke's avatar Jö Fahlke

Merge branch 'full-simd-vector-test-for-indices' into 'master'

[SIMD] Test the index vectors the same way we test other vectors

See merge request lukas.renelt/dune-vectorclass!6
parents 0ad70d40 02933e6b
Pipeline #9631 failed with stage
in 24 minutes
......@@ -8,21 +8,17 @@ dune_instance_begin(FILES vectorclasstest.hh vectorclasstest.cc)
foreach(VECTOR_SIZE IN ITEMS 128 256 512)
# float and associated types
math(EXPR LANES "${VECTOR_SIZE} / 32")
set(TYPE f)
dune_instance_add(TEMPLATE VECTOR ID "${LANES}${TYPE}"
FILES vectorclasstest_vector.cc vectorclasstest_mask.cc)
set(TYPE i)
dune_instance_add(TEMPLATE INDEX ID "${LANES}${TYPE}"
FILES vectorclasstest_index.cc vectorclasstest_mask.cc)
foreach(TYPE IN ITEMS f i)
dune_instance_add(ID "${LANES}${TYPE}"
FILES vectorclasstest_vector.cc vectorclasstest_mask.cc)
endforeach(TYPE)
# double and associated types
math(EXPR LANES "${VECTOR_SIZE} / 64")
set(TYPE d)
dune_instance_add(TEMPLATE VECTOR ID "${LANES}${TYPE}"
FILES vectorclasstest_vector.cc vectorclasstest_mask.cc)
set(TYPE q)
dune_instance_add(TEMPLATE INDEX ID "${LANES}${TYPE}"
FILES vectorclasstest_index.cc vectorclasstest_mask.cc)
foreach(TYPE IN ITEMS d q)
dune_instance_add(ID "${LANES}${TYPE}"
FILES vectorclasstest_vector.cc vectorclasstest_mask.cc)
endforeach(TYPE)
endforeach(VECTOR_SIZE)
dune_instance_end()
......
......@@ -14,7 +14,7 @@
int main() {
Dune::Simd::UnitTest test;
#cmake @template VECTOR@
#cmake @template@
#if MAX_VECTOR_SIZE >= @VECTOR_SIZE@
test.checkVector<Vec@LANES@@TYPE@>();
#endif // MAX_VECTOR_SIZE >= @VECTOR_SIZE@
......
......@@ -11,18 +11,11 @@
namespace Dune {
namespace Simd {
#cmake @template VECTOR@
#cmake @template@
#if MAX_VECTOR_SIZE >= @VECTOR_SIZE@
extern template void UnitTest::checkVector<Vec@LANES@@TYPE@>();
extern template void UnitTest::checkMask<Vec@LANES@@TYPE@b>();
#endif // MAX_VECTOR_SIZE >= @VECTOR_SIZE@
#cmake @endtemplate@
#cmake @template INDEX@
#if MAX_VECTOR_SIZE >= @VECTOR_SIZE@
extern template void UnitTest::checkIndex<Vec@LANES@@TYPE@>();
extern template void UnitTest::checkMask<Vec@LANES@@TYPE@b>();
#endif // MAX_VECTOR_SIZE >= @VECTOR_SIZE@
#cmake @endtemplate@
}
......
// @GENERATED_SOURCE@
#include <config.h>
#include <dune/common/simd/test.hh>
#include <dune/vectorclass/test/vectorclasstest.hh>
namespace Dune {
namespace Simd {
#if MAX_VECTOR_SIZE >= @VECTOR_SIZE@
template void UnitTest::checkIndex<Vec@LANES@@TYPE@>();
#endif // MAX_VECTOR_SIZE >= @VECTOR_SIZE@
}
}
......@@ -361,12 +361,12 @@ namespace VCL_NAMESPACE {
// Fallback operations
//
// The SFINAE prevents ambigous overloads: scalars can be converted to
// implicitly to vectors, so when specifying the RHS as a vector this would
// be a viable overload for division by scalar. But an operator for
// devision by scalar exists already. So accept any type as the second
// argument, but then reject inappropriate types by making this overload
// non-viable.
// The SFINAE prevents ambigous overloads: scalars can be converted
// implicitly to vectors, so when specifying the RHS formal argument as
// `Type other` this would be a viable overload for division by scalar. But
// an overload for devision by scalar exists already in some cases. So
// accept any type as the second argument, but then reject inappropriate
// types by making this overload non-viable.
#define DUNE_VECTORCLASS_OPASSIGN_V(Type, op) \
template<class Other, \
class = std::enable_if_t<Dune::Simd::lanes<Other>() == \
......@@ -379,48 +379,156 @@ namespace VCL_NAMESPACE {
} \
static_assert(true, "Unfudge editor indentation heuristics")
#define DUNE_VECTORCLASS_OPASSIGN_VS(Type, op) \
inline Type &operator op##=(Type &self, Type other) \
{ \
for(auto l : Dune::range(Dune::Simd::lanes(self))) \
Dune::Simd::lane(l, self) op##= Dune::Simd::lane(l, other); \
return self; \
} \
#define DUNE_VECTORCLASS_OPASSIGN_S(Type, op) \
inline Type & \
operator op##=(Type &self, Dune::Simd::Scalar<Type> other) \
{ \
for(auto l : Dune::range(Dune::Simd::lanes(self))) \
Dune::Simd::lane(l, self) op##= other; \
return self; \
} \
static_assert(true, "Unfudge editor indentation heuristics")
#define DUNE_VECTORCLASS_OPINFIX_SV(Type, op) \
inline Type operator op(Dune::Simd::Scalar<Type> a, Type b) \
{ \
auto tmp = Type{a}; \
return tmp op##= b; \
} \
static_assert(true, "Unfudge editor indentation heuristics")
#define DUNE_VECTORCLASS_OPINFIX_VV(Type, op) \
template<class B, \
class = std::enable_if_t<Dune::Simd::lanes<Type>() == \
Dune::Simd::lanes<B>()> > \
Type operator op(Type a, B b) { return a op##= b; } \
static_assert(true, "Unfudge editor indentation heuristics")
#define DUNE_VECTORCLASS_OPINFIX_VS(Type, op) \
inline Type operator op(Type a, Dune::Simd::Scalar<Type> b) \
{ \
return a op##= b; \
} \
static_assert(true, "Unfudge editor indentation heuristics")
#if MAX_VECTOR_SIZE >= 128
DUNE_VECTORCLASS_OPASSIGN_V (Vec4i, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec4i, %);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec2q, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec2q, %);
// Vec4i
DUNE_VECTORCLASS_OPASSIGN_V(Vec4i, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec4i, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4i, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4i, %);
DUNE_VECTORCLASS_OPASSIGN_S(Vec4i, %);
DUNE_VECTORCLASS_OPINFIX_SV(Vec4i, %);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4i, %);
DUNE_VECTORCLASS_OPINFIX_VS(Vec4i, %);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4i, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4i, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4i, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4i, >>);
// Vec2q
DUNE_VECTORCLASS_OPASSIGN_V(Vec2q, /);
DUNE_VECTORCLASS_OPASSIGN_S(Vec2q, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec2q, /);
DUNE_VECTORCLASS_OPINFIX_VS(Vec2q, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec2q, %);
DUNE_VECTORCLASS_OPASSIGN_S(Vec2q, %);
DUNE_VECTORCLASS_OPINFIX_VV(Vec2q, %);
DUNE_VECTORCLASS_OPINFIX_VS(Vec2q, %);
DUNE_VECTORCLASS_OPASSIGN_V(Vec2q, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec2q, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec2q, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec2q, >>);
#endif
#if MAX_VECTOR_SIZE >= 256
DUNE_VECTORCLASS_OPASSIGN_V (Vec8i, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec8i, %);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec4q, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec4q, %);
// Vec8i
DUNE_VECTORCLASS_OPASSIGN_V(Vec8i, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec8i, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8i, /);
DUNE_VECTORCLASS_OPINFIX_VS(Vec8i, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8i, %);
DUNE_VECTORCLASS_OPASSIGN_S(Vec8i, %);
DUNE_VECTORCLASS_OPINFIX_SV(Vec8i, %);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8i, %);
DUNE_VECTORCLASS_OPINFIX_VS(Vec8i, %);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8i, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8i, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8i, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8i, >>);
// Vec4q
DUNE_VECTORCLASS_OPASSIGN_V(Vec4q, /);
DUNE_VECTORCLASS_OPASSIGN_S(Vec4q, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec4q, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4q, /);
DUNE_VECTORCLASS_OPINFIX_VS(Vec4q, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4q, %);
DUNE_VECTORCLASS_OPASSIGN_S(Vec4q, %);
DUNE_VECTORCLASS_OPINFIX_SV(Vec4q, %);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4q, %);
DUNE_VECTORCLASS_OPINFIX_VS(Vec4q, %);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4q, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4q, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4q, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4q, >>);
#if INSTRSET < 7 // no native AVX
// these are necessary to resolve ambiguous overloads.
inline Vec8fb operator==(Vec8fb a, Vec8fb b) { return !(a ^ b); }
inline Vec4db operator==(Vec4db a, Vec4db b) { return !(a ^ b); }
#endif // INSTRSET < 7
#if INSTRSET < 8 // no native AVX2
// inline Vec8ib operator==(Vec8ib a, Vec8ib b) { return !(a ^ b); }
// inline Vec4qb operator==(Vec4qb a, Vec4qb b) { return !(a ^ b); }
// these seem to have been forgotten
// inline Vec8ib operator!(Vec8i a) { return a == 0; }
// inline Vec4qb operator!(Vec4q a) { return a == 0; }
#endif // INSTRSET < 7
#endif // MAX_VECTOR_SIZE >= 256
#if MAX_VECTOR_SIZE >= 512
DUNE_VECTORCLASS_OPASSIGN_V (Vec16i, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec16i, %);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec8q, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec8q, %);
// Vec16i
DUNE_VECTORCLASS_OPASSIGN_V(Vec16i, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec16i, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec16i, /);
DUNE_VECTORCLASS_OPINFIX_VS(Vec16i, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec16i, %);
DUNE_VECTORCLASS_OPASSIGN_S(Vec16i, %);
DUNE_VECTORCLASS_OPINFIX_SV(Vec16i, %);
DUNE_VECTORCLASS_OPINFIX_VV(Vec16i, %);
DUNE_VECTORCLASS_OPINFIX_VS(Vec16i, %);
DUNE_VECTORCLASS_OPASSIGN_V(Vec16i, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec16i, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec16i, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec16i, >>);
// Vec8q
DUNE_VECTORCLASS_OPASSIGN_V(Vec8q, /);
DUNE_VECTORCLASS_OPASSIGN_S(Vec8q, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec8q, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8q, /);
DUNE_VECTORCLASS_OPINFIX_VS(Vec8q, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8q, %);
DUNE_VECTORCLASS_OPASSIGN_S(Vec8q, %);
DUNE_VECTORCLASS_OPINFIX_SV(Vec8q, %);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8q, %);
DUNE_VECTORCLASS_OPINFIX_VS(Vec8q, %);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8q, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8q, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8q, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8q, >>);
#if INSTRSET >= 9 // native AVX512
inline Vec16fb operator&&(Vec16fb a, bool b) { return a && Vec16fb(b); }
......@@ -456,7 +564,9 @@ namespace VCL_NAMESPACE {
#endif // MAX_VECTOR_SIZE >= 512
#undef DUNE_VECTORCLASS_OPASSIGN_V
#undef DUNE_VECTORCLASS_OPASSIGN_VS
#undef DUNE_VECTORCLASS_OPASSIGN_S
#undef DUNE_VECTORCLASS_OPINFIX_VV
#undef DUNE_VECTORCLASS_OPINFIX_VS
#ifdef VCL_NAMESPACE
} // namespace VCL_NAMESPACE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment