Commit 02933e6b authored by Jö Fahlke's avatar Jö Fahlke

Disentangle the overloads for vectors and scalars.

parent 7c044dfc
Pipeline #9593 failed with stage
in 0 seconds
......@@ -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,80 +379,111 @@ 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_V_V(Type, op) \
#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 n, B d) { return n op##= d; } \
Type operator op(Type a, B b) { return a op##= b; } \
static_assert(true, "Unfudge editor indentation heuristics")
#define DUNE_VECTORCLASS_OPINFIX_V_VS(Type, op) \
inline Type operator op(Type n, Type d) { return n op##= d; } \
#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
// Vec4i
DUNE_VECTORCLASS_OPASSIGN_V (Vec4i, /);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec4i, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4i, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec4i, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4i, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec4i, %);
DUNE_VECTORCLASS_OPINFIX_V_VS(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_V_V(Vec4i, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4i, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4i, <<);
DUNE_VECTORCLASS_OPASSIGN_V (Vec4i, >>);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec4i, >>);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4i, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4i, >>);
// Vec2q
DUNE_VECTORCLASS_OPASSIGN_VS(Vec2q, /);
DUNE_VECTORCLASS_OPINFIX_V_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_VS(Vec2q, %);
DUNE_VECTORCLASS_OPINFIX_V_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_V_V(Vec2q, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec2q, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec2q, <<);
DUNE_VECTORCLASS_OPASSIGN_V (Vec2q, >>);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec2q, >>);
DUNE_VECTORCLASS_OPASSIGN_V(Vec2q, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec2q, >>);
#endif
#if MAX_VECTOR_SIZE >= 256
// Vec8i
DUNE_VECTORCLASS_OPASSIGN_V (Vec8i, /);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec8i, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8i, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec8i, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8i, /);
DUNE_VECTORCLASS_OPINFIX_VS(Vec8i, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec8i, %);
DUNE_VECTORCLASS_OPINFIX_V_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_V_V(Vec8i, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8i, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8i, <<);
DUNE_VECTORCLASS_OPASSIGN_V (Vec8i, >>);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec8i, >>);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8i, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8i, >>);
// Vec4q
DUNE_VECTORCLASS_OPASSIGN_VS(Vec4q, /);
DUNE_VECTORCLASS_OPINFIX_V_VS(Vec4q, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec4q, %);
DUNE_VECTORCLASS_OPINFIX_V_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_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_V_V(Vec4q, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4q, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec4q, >>);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec4q, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec4q, >>);
#if INSTRSET < 7 // no native AVX
// these are necessary to resolve ambiguous overloads.
......@@ -463,30 +494,41 @@ namespace VCL_NAMESPACE {
#if MAX_VECTOR_SIZE >= 512
// Vec16i
DUNE_VECTORCLASS_OPASSIGN_V (Vec16i, /);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec16i, /);
DUNE_VECTORCLASS_OPASSIGN_V(Vec16i, /);
DUNE_VECTORCLASS_OPINFIX_SV(Vec16i, /);
DUNE_VECTORCLASS_OPINFIX_VV(Vec16i, /);
DUNE_VECTORCLASS_OPINFIX_VS(Vec16i, /);
DUNE_VECTORCLASS_OPASSIGN_VS(Vec16i, %);
DUNE_VECTORCLASS_OPINFIX_V_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_V_V(Vec16i, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec16i, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec16i, <<);
DUNE_VECTORCLASS_OPASSIGN_V (Vec16i, >>);
DUNE_VECTORCLASS_OPINFIX_V_V(Vec16i, >>);
DUNE_VECTORCLASS_OPASSIGN_V(Vec16i, >>);
DUNE_VECTORCLASS_OPINFIX_VV(Vec16i, >>);
// Vec8q
DUNE_VECTORCLASS_OPASSIGN_VS(Vec8q, /);
DUNE_VECTORCLASS_OPINFIX_V_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_VS(Vec8q, %);
DUNE_VECTORCLASS_OPINFIX_V_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_V_V(Vec8q, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8q, <<);
DUNE_VECTORCLASS_OPINFIX_VV(Vec8q, <<);
DUNE_VECTORCLASS_OPASSIGN_V(Vec8q, >>);
DUNE_VECTORCLASS_OPINFIX_V_V(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); }
......@@ -522,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