1 #ifndef DUNE_COMMON_SIMD_VC_HH
2 #define DUNE_COMMON_SIMD_VC_HH
10 #include <type_traits>
156 template<
class V,
class SFINAE =
void>
159 template<
typename T,
typename A>
162 template<
typename T, std::
size_t n,
typename V, std::
size_t m>
163 struct IsMask<Vc::SimdMaskArray<T, n, V, m> > : std::true_type {};
166 template<
class V,
class SFINAE =
void>
169 template<
typename T,
typename A>
170 struct IsVector<Vc::Vector<T, A> > : std::true_type {};
172 template<
typename T, std::
size_t n,
typename V, std::
size_t m>
173 struct IsVector<Vc::SimdArray<T, n, V, m> > : std::true_type {};
199 static_assert(std::is_same<V, std::decay_t<V> >::value,
"Class Proxy "
200 "may only be instantiated with unqualified types");
205 static_assert(std::is_arithmetic<value_type>::value,
206 "Only artihmetic types are supported");
212 : vec_(vec), idx_(idx)
222 #define DUNE_SIMD_VC_ASSIGNMENT(OP) \
224 class = decltype(std::declval<value_type&>() OP \
225 autoCopy(std::declval<T>()) )> \
226 Proxy operator OP(T &&o) && \
228 vec_[idx_] OP autoCopy(std::forward<T>(o)); \
229 return { idx_, vec_ }; \
242 #undef DUNE_SIMD_VC_ASSIGNMENT
246 class = std::enable_if_t<!std::is_same<T, bool>::value> >
249 class = std::enable_if_t<!std::is_same<T, bool>::value> >
254 class = std::enable_if_t<!std::is_same<T, bool>::value> >
257 class = std::enable_if_t<!std::is_same<T, bool>::value> >
267 a.vec_[a.idx_] = std::move(b.vec_[b.idx_]);
268 b.vec_[b.idx_] = std::move(tmp);
274 a = std::move(b.vec_[b.idx_]);
275 b.vec_[b.idx_] = std::move(tmp);
281 a.vec_[a.idx_] = std::move(b);
344 #define DUNE_SIMD_VC_BINARY(OP) \
345 template<class T, class Abi> \
346 friend auto operator OP(const Vc::Vector<T, Abi> &l, Proxy&& r) \
347 -> decltype(l OP std::declval<value_type>()) \
349 return l OP value_type(r); \
351 template<class T, class Abi> \
352 auto operator OP(const Vc::Vector<T, Abi> &r) && \
353 -> decltype(std::declval<value_type>() OP r) \
355 return value_type(*this) OP r; \
357 template<class T, std::size_t n, class Vec, std::size_t m> \
359 operator OP(const Vc::SimdArray<T, n, Vec, m> &l, Proxy&& r) \
360 -> decltype(l OP std::declval<value_type>()) \
362 return l OP value_type(r); \
364 template<class T, std::size_t n, class Vec, std::size_t m> \
365 auto operator OP(const Vc::SimdArray<T, n, Vec, m> &r) && \
366 -> decltype(std::declval<value_type>() OP r) \
368 return value_type(*this) OP r; \
387 #undef DUNE_SIMD_VC_BINARY
391 template<
class T,
class Abi,
392 class = std::enable_if_t<std::is_convertible<
value_type,
394 operator Vc::Vector<T, Abi>() &&
398 template<
class T, std::size_t n,
class Vec, std::size_t m,
399 class = std::enable_if_t<std::is_convertible<
value_type,
401 operator Vc::SimdArray<T, n, Vec, m>() &&
406 #define DUNE_SIMD_VC_ASSIGN(OP) \
407 template<class T, class Abi> \
408 friend auto operator OP(Vc::Vector<T, Abi> &l, Proxy&& r) \
409 -> decltype(l OP std::declval<value_type>()) \
411 return l OP value_type(r); \
429 #undef DUNE_SIMD_VC_ASSIGN
434 namespace Overloads {
446 struct ScalarType<V, std::enable_if_t<VcImpl::IsVector<V>::value> >
448 using type =
typename V::value_type;
461 std::enable_if_t<VcImpl::IsVector<V>::value> >
474 struct RebindType<bool, V, std::enable_if_t<VcImpl::IsVector<V>::value &&
475 !VcImpl::IsMask<V>::value>>
477 using type =
typename V::mask_type;
489 std::enable_if_t<VcImpl::IsMask<M>::value>>
491 using type =
typename M::Vector;
501 template<
class S,
class M>
504 VcImpl::IsMask<M>::value &&
505 VcImpl::IsVectorizable<S>::value &&
506 !std::is_same<S, Scalar<typename M::Vector> >::value
509 using type = Vc::SimdArray<S, Simd::lanes<M>()>;
519 template<
class S,
class V>
521 std::enable_if_t<VcImpl::IsVector<V>::value &&
522 !VcImpl::IsMask<V>::value &&
523 VcImpl::IsVectorizable<S>::value &&
524 !std::is_same<S, Scalar<V> >::value> >
526 using type = Vc::SimdArray<S, Simd::lanes<V>()>;
537 template<
class S,
class V>
539 std::enable_if_t<VcImpl::IsVector<V>::value &&
540 !VcImpl::IsVectorizable<S>::value &&
541 !std::is_same<S, bool>::value &&
542 !std::is_same<S, Scalar<V> >::value> >
552 struct LaneCount<V, std::enable_if_t<VcImpl::IsVector<V>::value> >
567 std::size_t l,
const V &v)
581 class = std::enable_if_t<!std::is_reference<V>::value> >
583 std::size_t l, V &&v)
585 return std::forward<V>(v)[l];
592 const Mask<V> &
mask,
const V &ifTrue,
const V &ifFalse)
594 return Vc::iif(
mask, ifTrue, ifFalse);
603 const V &
mask,
const V &ifTrue,
const V &ifFalse)
605 return (
mask && ifTrue) || (!
mask && ifFalse);
612 const V &v1,
const V &v2)
620 const M &m1,
const M &m2)
629 const V &v1,
const V &v2)
637 const M &m1,
const M &m2)
646 return Vc::any_of(
mask);
653 return Vc::all_of(
mask);
662 return Vc::none_of(
mask);
678 return Vc::any_of(
mask);
694 return !Vc::any_of(!
mask);
698 template<
class S1,
class V2>
701 const S1 &s1,
const V2 &v2)
707 template<
class V1,
class S2>
709 std::is_same<
Mask<S2>,
bool>::value>,
710 const V1 &v1,
const S2 &s2)
716 template<
class S1,
class V2>
719 const S1 &s1,
const V2 &v2)
725 template<
class V1,
class S2>
727 std::is_same<
Mask<S2>,
bool>::value>,
728 const V1 &v1,
const S2 &s2)
743 template <
typename T, std::
size_t N>
745 :
public std::integral_constant<bool, IsNumber<T>::value> {
748 template <
typename T,
typename Abi>
750 :
public std::integral_constant<bool, IsNumber<T>::value> {
Basic definitions for SIMD Implementations.
Default implementations for SIMD Implementations.
Compatibility header for including <Vc/Vc>
Traits for type conversions and type information.
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: indices.hh:28
V cond(M &&mask, const V &ifTrue, const V &ifFalse)
Like the ?: operator.
Definition: simd/interface.hh:384
auto mask(const V &v)
Convert to mask, analogue of bool(s) for scalars.
Definition: simd/interface.hh:487
Rebind< bool, V > Mask
Mask type type of some SIMD type.
Definition: simd/interface.hh:287
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition: simd/interface.hh:233
bool allFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::allFalse()
Definition: defaults.hh:122
bool allTrue(ADLTag< 0 >, const Mask &mask)
implements Simd::allTrue()
Definition: defaults.hh:102
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition: defaults.hh:151
auto maskAnd(ADLTag< 0 >, const V1 &v1, const V2 &v2)
implements Simd::maskAnd()
Definition: defaults.hh:175
auto maskOr(ADLTag< 0 >, const V1 &v1, const V2 &v2)
implements Simd::maskOr()
Definition: defaults.hh:168
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition: defaults.hh:87
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:79
Dune namespace.
Definition: alignedallocator.hh:11
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition: debugalign.hh:530
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition: debugalign.hh:507
const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
Definition: debugalign.hh:522
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition: base.hh:180
should have a member type type
Definition: standard.hh:58
should have a member type type
Definition: standard.hh:65
should be derived from a Dune::index_constant
Definition: standard.hh:72
specialized to true for Vc mask types
Definition: simd/vc.hh:157
specialized to true for Vc vector and mask types
Definition: simd/vc.hh:167
Definition: simd/vc.hh:175
A reference-like proxy for elements of random-access vectors.
Definition: simd/vc.hh:198
DUNE_SIMD_VC_BINARY & DUNE_SIMD_VC_BINARY(^);DUNE_SIMD_VC_BINARY(|
DUNE_SIMD_VC_ASSIGN & DUNE_SIMD_VC_ASSIGN(^=);DUNE_SIMD_VC_ASSIGN(|=
DUNE_SIMD_VC_ASSIGNMENT(+=)
DUNE_SIMD_VC_ASSIGNMENT(=)
Proxy operator--()
Definition: simd/vc.hh:250
friend void swap(const Proxy &a, value_type &b)
Definition: simd/vc.hh:277
value_type operator++(int)
Definition: simd/vc.hh:255
DUNE_SIMD_VC_ASSIGNMENT(-=)
DUNE_SIMD_VC_ASSIGN * DUNE_SIMD_VC_ASSIGN(/=);DUNE_SIMD_VC_ASSIGN(%=
friend void swap(value_type &a, const Proxy &b)
Definition: simd/vc.hh:270
value_type operator--(int)
Definition: simd/vc.hh:258
Proxy(std::size_t idx, V &vec)
Definition: simd/vc.hh:211
DUNE_SIMD_VC_ASSIGNMENT & DUNE_SIMD_VC_ASSIGNMENT(^=);DUNE_SIMD_VC_ASSIGNMENT(|=
friend void swap(const Proxy &a, const Proxy &b)
Definition: simd/vc.hh:263
DUNE_SIMD_VC_ASSIGNMENT(<<=)
DUNE_SIMD_VC_BINARY * DUNE_SIMD_VC_BINARY(/);DUNE_SIMD_VC_BINARY(%
DUNE_SIMD_VC_ASSIGNMENT * DUNE_SIMD_VC_ASSIGNMENT(/=);DUNE_SIMD_VC_ASSIGNMENT(%=
Proxy(const Proxy &)=delete
typename V::value_type value_type
Definition: simd/vc.hh:202
Proxy operator++()
Definition: simd/vc.hh:247
DUNE_SIMD_VC_ASSIGNMENT(>>=)
typename V::value_type type
Definition: simd/vc.hh:448
V type
Definition: simd/vc.hh:463
typename V::mask_type type
Definition: simd/vc.hh:477
typename M::Vector type
Definition: simd/vc.hh:491
Vc::SimdArray< S, Simd::lanes< M >()> type
Definition: simd/vc.hh:509
Vc::SimdArray< S, Simd::lanes< V >()> type
Definition: simd/vc.hh:526
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: typetraits.hh:194
Type free of internal references that T can be converted to.
Definition: typetraits.hh:501