dune-common 2.9.0
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
loop.hh File Reference
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <cstdint>
#include <ostream>
#include <dune/common/math.hh>
#include <dune/common/simd/simd.hh>
#include <dune/common/typetraits.hh>

Go to the source code of this file.

Classes

class  Dune::LoopSIMD< T, S, A >
 
struct  Dune::Simd::Overloads::ScalarType< LoopSIMD< T, S, A > >
 
struct  Dune::Simd::Overloads::RebindType< U, LoopSIMD< T, S, A > >
 
struct  Dune::Simd::Overloads::LaneCount< LoopSIMD< T, S, A > >
 
struct  Dune::IsNumber< LoopSIMD< T, S, A > >
 

Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
namespace  Dune::MathOverloads
 namespace for customization of math functions with Dune-Semantics
 

Macros

#define DUNE_PRAGMA_OMP_SIMD
 
#define DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_UNARY_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_POSTFIX_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr)
 
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType)
 
#define DUNE_SIMD_LOOP_STD_UNARY_OP(expr)
 
#define DUNE_SIMD_LOOP_STD_BINARY_OP(expr)
 

Functions

 Dune::DUNE_SIMD_LOOP_BINARY_OP (+)
 
 Dune::DUNE_SIMD_LOOP_BINARY_OP (-)
 
DUNE_SIMD_LOOP_BINARY_OP * Dune::DUNE_SIMD_LOOP_BINARY_OP (/);DUNE_SIMD_LOOP_BINARY_OP(%
 
DUNE_SIMD_LOOP_BINARY_OP & Dune::DUNE_SIMD_LOOP_BINARY_OP (|);DUNE_SIMD_LOOP_BINARY_OP(^
 
 Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (<<)
 
 Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (> >)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<=)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (>=)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (!=)
 
DUNE_SIMD_LOOP_BOOLEAN_OP && Dune::DUNE_SIMD_LOOP_BOOLEAN_OP (||);template< class T, std::size_t S, std::size_t A > std::ostream &operator<<(std::ostream &os, const LoopSIMD< T, S, A > &v
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, LoopSIMD< T, S, A > &&v) -> decltype(std::move(Simd::lane(l%lanes< T >(), v[l/lanes< T >()])))
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, const LoopSIMD< T, S, A > &v) -> decltype(Simd::lane(l%lanes< T >(), v[l/lanes< T >()]))
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, LoopSIMD< T, S, A > &v) -> decltype(Simd::lane(l%lanes< T >(), v[l/lanes< T >()]))
 
template<class T , std::size_t S, std::size_t AM, std::size_t AD>
auto Dune::Simd::Overloads::cond (ADLTag< 5 >, Simd::Mask< LoopSIMD< T, S, AM > > mask, LoopSIMD< T, S, AD > ifTrue, LoopSIMD< T, S, AD > ifFalse)
 
template<class M , class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::cond (ADLTag< 5, std::is_same< bool, Simd::Scalar< M > >::value &&Simd::lanes< M >()==Simd::lanes< LoopSIMD< T, S, A > >()>, M mask, LoopSIMD< T, S, A > ifTrue, LoopSIMD< T, S, A > ifFalse)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::allTrue (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::anyFalse (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::allFalse (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cos)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sin)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tan)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acos)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asin)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atan)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cosh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sinh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tanh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acosh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asinh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atanh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log10)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp2)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (expm1)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (ilogb, int)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log1p)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log2)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (logb)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sqrt)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cbrt)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erf)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erfc)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tgamma)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (lgamma)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (ceil)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (floor)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (trunc)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (round)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (lround, long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (llround, long long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (rint)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (lrint, long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (llrint, long long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (nearbyint)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (fabs)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (abs)
 
 Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (real)
 
 Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (imag)
 
 Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (max)
 
 Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (min)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isNaN (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isInf (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isFinite (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 

Macro Definition Documentation

◆ DUNE_PRAGMA_OMP_SIMD

#define DUNE_PRAGMA_OMP_SIMD

◆ DUNE_SIMD_LOOP_ASSIGNMENT_OP

#define DUNE_SIMD_LOOP_ASSIGNMENT_OP (   SYMBOL)
Value:
auto operator SYMBOL(const Simd::Scalar<T> s) { \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
(*this)[i] SYMBOL s; \
} \
return *this; \
} \
\
auto operator SYMBOL(const LoopSIMD<T,S,A> &v) { \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
(*this)[i] SYMBOL v[i]; \
} \
return *this; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_BINARY_OP

#define DUNE_SIMD_LOOP_BINARY_OP (   SYMBOL)
Value:
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
LoopSIMD<T,S,A> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL s; \
} \
return out; \
} \
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
LoopSIMD<T,S,A> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = s SYMBOL v[i]; \
} \
return out; \
} \
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
const LoopSIMD<T,S,A> &w) { \
LoopSIMD<T,S,A> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL w[i]; \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_BITSHIFT_OP

#define DUNE_SIMD_LOOP_BITSHIFT_OP (   SYMBOL)
Value:
template<class T, std::size_t S, std::size_t A, class U> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
LoopSIMD<T,S,A> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL s; \
} \
return out; \
} \
template<class T, std::size_t S, std::size_t A, class U, std::size_t AU> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
const LoopSIMD<U,S,AU> &w) { \
LoopSIMD<T,S,A> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL w[i]; \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_BOOLEAN_OP

#define DUNE_SIMD_LOOP_BOOLEAN_OP (   SYMBOL)
Value:
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
Simd::Mask<LoopSIMD<T,S,A>> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL s; \
} \
return out; \
} \
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const Simd::Mask<T> s, const LoopSIMD<T,S,A> &v) { \
Simd::Mask<LoopSIMD<T,S,A>> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = s SYMBOL v[i]; \
} \
return out; \
} \
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
const LoopSIMD<T,S,A> &w) { \
Simd::Mask<LoopSIMD<T,S,A>> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL w[i]; \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_CMATH_UNARY_OP

#define DUNE_SIMD_LOOP_CMATH_UNARY_OP (   expr)
Value:
template<class T, std::size_t S, std::size_t A, typename Sfinae = \
typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
auto expr(const LoopSIMD<T,S,A> &v) { \
using std::expr; \
LoopSIMD<T,S,A> out; \
for(std::size_t i=0; i<S; i++) { \
out[i] = expr(v[i]); \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN

#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (   expr,
  returnType 
)
Value:
template<class T, std::size_t S, std::size_t A, typename Sfinae = \
typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
auto expr(const LoopSIMD<T,S,A> &v) { \
using std::expr; \
LoopSIMD<returnType,S> out; \
for(std::size_t i=0; i<S; i++) { \
out[i] = expr(v[i]); \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_COMPARISON_OP

#define DUNE_SIMD_LOOP_COMPARISON_OP (   SYMBOL)
Value:
template<class T, std::size_t S, std::size_t A, class U> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
Simd::Mask<LoopSIMD<T,S,A>> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL s; \
} \
return out; \
} \
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
Simd::Mask<LoopSIMD<T,S,A>> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = s SYMBOL v[i]; \
} \
return out; \
} \
template<class T, std::size_t S, std::size_t A> \
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
const LoopSIMD<T,S,A> &w) { \
Simd::Mask<LoopSIMD<T,S,A>> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = v[i] SYMBOL w[i]; \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_POSTFIX_OP

#define DUNE_SIMD_LOOP_POSTFIX_OP (   SYMBOL)
Value:
auto operator SYMBOL(int){ \
LoopSIMD<T,S,A> out = *this; \
SYMBOL(*this); \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_PREFIX_OP

#define DUNE_SIMD_LOOP_PREFIX_OP (   SYMBOL)
Value:
auto operator SYMBOL() { \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
SYMBOL(*this)[i]; \
} \
return *this; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_STD_BINARY_OP

#define DUNE_SIMD_LOOP_STD_BINARY_OP (   expr)
Value:
template<class T, std::size_t S, std::size_t A> \
auto expr(const LoopSIMD<T,S,A> &v, const LoopSIMD<T,S,A> &w) { \
using std::expr; \
LoopSIMD<T,S,A> out; \
for(std::size_t i=0; i<S; i++) { \
out[i] = expr(v[i],w[i]); \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_STD_UNARY_OP

#define DUNE_SIMD_LOOP_STD_UNARY_OP (   expr)
Value:
template<class T, std::size_t S, std::size_t A> \
auto expr(const LoopSIMD<T,S,A> &v) { \
using std::expr; \
LoopSIMD<T,S,A> out; \
for(std::size_t i=0; i<S; i++) { \
out[i] = expr(v[i]); \
} \
return out; \
} \
\
template<class T, std::size_t S, std::size_t A> \
auto expr(const LoopSIMD<std::complex<T>,S,A> &v) { \
using std::expr; \
LoopSIMD<T,S,A> out; \
for(std::size_t i=0; i<S; i++) { \
out[i] = expr(v[i]); \
} \
return out; \
} \
static_assert(true, "expecting ;")

◆ DUNE_SIMD_LOOP_UNARY_OP

#define DUNE_SIMD_LOOP_UNARY_OP (   SYMBOL)
Value:
auto operator SYMBOL() const { \
LoopSIMD<T,S,A> out; \
DUNE_PRAGMA_OMP_SIMD \
for(std::size_t i=0; i<S; i++){ \
out[i] = SYMBOL((*this)[i]); \
} \
return out; \
} \
static_assert(true, "expecting ;")