Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Common/include/parallelization/special_vectorization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
46 changes: 23 additions & 23 deletions Common/include/parallelization/vectorization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,24 @@ class Array : public CVecExpr<Array<Scalar_t,N>, 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<Scalar> 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<class T> \
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<Scalar> 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<class T> \
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)
Expand Down Expand Up @@ -132,11 +132,11 @@ class Array : public CVecExpr<Array<Scalar_t,N>, Scalar_t> {

/*--- Compound assignment operators. ---*/

#define MAKE_COMPOUND(OP) \
FORCEINLINE Array& operator OP (Scalar x) { FOREACH x_[k] OP x; return *this; } \
template<class U> \
FORCEINLINE Array& operator OP (const CVecExpr<U,Scalar>& 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<class U> \
FORCEINLINE Array& operator OP (const CVecExpr<U,Scalar>& expr) { \
FOREACH { x_[k] OP expr.derived()[k]; } return *this; \
}
MAKE_COMPOUND(=)
MAKE_COMPOUND(+=)
Expand Down