diff --git a/Common/include/parallelization/special_vectorization.hpp b/Common/include/parallelization/special_vectorization.hpp index 4decb2163e7c..1697ec1fc321 100644 --- a/Common/include/parallelization/special_vectorization.hpp +++ b/Common/include/parallelization/special_vectorization.hpp @@ -138,24 +138,24 @@ MAKE_BINARY_FUN(min, min_p) /*--- Functions of one (array) argument. ---*/ -#define MAKE_UNARY_FUN(NAME,IMPL) \ -FORCEINLINE ARRAY_T NAME(const ARRAY_T& x) { \ - ARRAY_T res; FOREACH res[k] = IMPL(x[k]); return res; \ +#define MAKE_UNARY_FUN(NAME,IMPL) \ +FORCEINLINE ARRAY_T NAME(const ARRAY_T& x) { \ + ARRAY_T res; FOREACH { res[k] = IMPL(x[k]); } return res; \ } #undef MAKE_UNARY_FUN /*--- Functions of two arguments, with arrays and scalars. ---*/ -#define MAKE_BINARY_FUN(NAME,IMPL) \ -FORCEINLINE ARRAY_T NAME(const ARRAY_T& a, const ARRAY_T& b) { \ - ARRAY_T res; FOREACH res[k] = IMPL(a[k], b[k]); return res; \ -} \ -FORCEINLINE ARRAY_T NAME(const ARRAY_T& a, SCALAR_T b) { \ - ARRAY_T res; FOREACH res[k] = IMPL(a[k], b); return res; \ -} \ -FORCEINLINE ARRAY_T NAME(SCALAR_T b, const ARRAY_T& a) { \ - ARRAY_T res; FOREACH res[k] = IMPL(b, a[k]); return res; \ +#define MAKE_BINARY_FUN(NAME,IMPL) \ +FORCEINLINE ARRAY_T NAME(const ARRAY_T& a, const ARRAY_T& b) { \ + ARRAY_T res; FOREACH { res[k] = IMPL(a[k], b[k]); } return res; \ +} \ +FORCEINLINE ARRAY_T NAME(const ARRAY_T& a, SCALAR_T b) { \ + ARRAY_T res; FOREACH { res[k] = IMPL(a[k], b); } return res; \ +} \ +FORCEINLINE ARRAY_T NAME(SCALAR_T b, const ARRAY_T& a) { \ + ARRAY_T res; FOREACH { res[k] = IMPL(b, a[k]); } return res; \ } MAKE_BINARY_FUN(pow, ::pow) diff --git a/Common/include/parallelization/vectorization.hpp b/Common/include/parallelization/vectorization.hpp index cccb520b12cd..364ba790b36c 100644 --- a/Common/include/parallelization/vectorization.hpp +++ b/Common/include/parallelization/vectorization.hpp @@ -82,24 +82,24 @@ class Array : public CVecExpr, Scalar_t> { alignas(Size*sizeof(Scalar)) Scalar x_[N]; public: -#define ARRAY_BOILERPLATE \ - /*!--- Access elements ---*/ \ - FORCEINLINE Scalar& operator[] (size_t k) { return x_[k]; } \ - FORCEINLINE const Scalar& operator[] (size_t k) const { return x_[k]; } \ - /*!--- Constructors ---*/ \ - FORCEINLINE Array() = default; \ - FORCEINLINE Array(Scalar x) { bcast(x); } \ - FORCEINLINE Array(std::initializer_list vals) { \ - auto it = vals.begin(); FOREACH { x_[k] = *it; ++it; } \ - } \ - FORCEINLINE Array(Scalar x0, Scalar dx) { FOREACH x_[k] = x0 + k*dx; } \ - FORCEINLINE Array(const Scalar* ptr) { load(ptr); } \ - template \ - FORCEINLINE Array(const Scalar* beg, const T& off) { gather(beg,off); } \ - /*!--- Reduction operations ---*/ \ - FORCEINLINE Scalar sum() const { Scalar s(0); FOREACH s+=x_[k]; return s; } \ - FORCEINLINE Scalar dot(const Array& other) const { \ - Scalar s(0); FOREACH s += x_[k] * other[k]; return s; \ +#define ARRAY_BOILERPLATE \ + /*!--- Access elements ---*/ \ + FORCEINLINE Scalar& operator[] (size_t k) { return x_[k]; } \ + FORCEINLINE const Scalar& operator[] (size_t k) const { return x_[k]; } \ + /*!--- Constructors ---*/ \ + FORCEINLINE Array() = default; \ + FORCEINLINE Array(Scalar x) { bcast(x); } \ + FORCEINLINE Array(std::initializer_list vals) { \ + auto it = vals.begin(); FOREACH { x_[k] = *it; ++it; } \ + } \ + FORCEINLINE Array(Scalar x0, Scalar dx) { FOREACH x_[k] = x0 + k*dx; } \ + FORCEINLINE Array(const Scalar* ptr) { load(ptr); } \ + template \ + FORCEINLINE Array(const Scalar* beg, const T& off) { gather(beg,off); } \ + /*!--- Reduction operations ---*/ \ + FORCEINLINE Scalar sum() const { Scalar s(0); FOREACH { s+=x_[k]; } return s; } \ + FORCEINLINE Scalar dot(const Array& other) const { \ + Scalar s(0); FOREACH { s += x_[k] * other[k]; } return s; \ } #if defined(CODI_REVERSE_TYPE) || defined(CODI_FORWARD_TYPE) @@ -132,11 +132,11 @@ class Array : public CVecExpr, Scalar_t> { /*--- Compound assignment operators. ---*/ -#define MAKE_COMPOUND(OP) \ - FORCEINLINE Array& operator OP (Scalar x) { FOREACH x_[k] OP x; return *this; } \ - template \ - FORCEINLINE Array& operator OP (const CVecExpr& expr) { \ - FOREACH x_[k] OP expr.derived()[k]; return *this; \ +#define MAKE_COMPOUND(OP) \ + FORCEINLINE Array& operator OP (Scalar x) { FOREACH { x_[k] OP x; } return *this; } \ + template \ + FORCEINLINE Array& operator OP (const CVecExpr& expr) { \ + FOREACH { x_[k] OP expr.derived()[k]; } return *this; \ } MAKE_COMPOUND(=) MAKE_COMPOUND(+=)