diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2010-12-06 08:06:35 -0600 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2010-12-06 08:06:35 -0600 |
commit | a41bfbe853bf083bdc27f46a88e2a09252d0925d (patch) | |
tree | 9b09cfa3578e04ea8a853079c95c9babbdcce257 /Auxiliary/Cactus/KrancNumericalTools/GenericFD | |
parent | d6c4d4c2131107ef3a4004692823e2041394acd6 (diff) |
Rewrite vectorisation infrastructure:
Use "k" prefix more consistently in arithmetic macros.
Improve vector code generation patterns.
Move all vectorisation run-time out of Kranc and into a new thorn LSUThorns/Vectors, so that non-Kranc thorns can also use it.
Diffstat (limited to 'Auxiliary/Cactus/KrancNumericalTools/GenericFD')
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/interface.ccl | 1 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h | 8 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h | 7 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-SSE2-direct.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-SSE2-direct.hh) | 0 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-SSE2.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-SSE2.hh) | 15 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-VSX-direct.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-VSX-direct.hh) | 0 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-VSX.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-VSX.hh) | 4 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-default.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-default.hh) | 0 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-define.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-define.hh) | 0 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-outdated.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-outdated.hh) | 0 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-pseudo.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-pseudo.hh) | 0 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-undefine.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-undefine.hh) | 0 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors.hh (renamed from Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors.hh) | 0 |
13 files changed, 27 insertions, 8 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/interface.ccl b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/interface.ccl index efbdaa6..ccc3785 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/interface.ccl +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/interface.ccl @@ -7,7 +7,6 @@ implements: GenericFD INCLUDE HEADER: GenericFD.h in GenericFD.h -INCLUDE HEADER: Vectors.hh in Vectors.hh INCLUDE HEADER: sbp_calc_coeffs.h in sbp_calc_coeffs.h USES INCLUDE: Boundary.h diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h index 568c70f..7d8a13d 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h @@ -28,10 +28,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "cctk.h" + #ifdef __cplusplus extern "C" { #endif +#ifdef __cplusplus +# ifdef CCTK_CXX_RESTRICT +# define restrict CCTK_CXX_RESTRICT +# endif +#endif + #ifndef NOPRECOMPUTE #define PRECOMPUTE #endif diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h index ee6a3b7..2f00da9 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h @@ -31,13 +31,15 @@ #define Tanh(x) (tanh(x)) #ifdef KRANC_C -# define Sign(x) ((x)<0?-1:+1) +# define Sign(x) (copysign(1.0,(x))) # define ToReal(x) ((CCTK_REAL)(x)) #else # define Sign(x) (sgn(x)) # define ToReal(x) (real((x),kind(khalf))) #endif +#if 0 + /* TODO: use fma(x,y,z) to implement fmadd and friends? Note that fma may be unsupported, or may be slow. */ @@ -46,6 +48,7 @@ /* #define fnmadd(x,y,z) (-(z)-(x)*(y)) */ /* #define fnmsub(x,y,z) (+(z)-(x)*(y)) */ +#define fpos(x) (+(x)) #define fneg(x) (-(x)) #define fmul(x,y) ((x)*(y)) #define fdiv(x,y) ((x)/(y)) @@ -65,6 +68,8 @@ #define kpow(x,y) (pow(x,y)) #define ksqrt(x) (sqrt(x)) +#endif + #ifdef KRANC_C # define E M_E # define Pi M_PI diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-SSE2-direct.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-SSE2-direct.hh index 12cd6e8..12cd6e8 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-SSE2-direct.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-SSE2-direct.hh diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-SSE2.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-SSE2.hh index 4a4eea6..b74fac0 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-SSE2.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-SSE2.hh @@ -6,16 +6,23 @@ // Vector type corresponding to CCTK_REAL struct CCTK_REAL_VEC { - // The underlying scalar and vector types + // Underlying scalar and vector types typedef double S; typedef __m128d V; + + // Payload V v; + // Empty constructur + inline CCTK_REAL_VEC() { } + // Convert from and to the underlying vector type inline CCTK_REAL_VEC(V const v_): v(v_) { } inline operator V const() const { return v; } - inline CCTK_REAL_VEC() { } + // Convert from the underlying scalar type + inline CCTK_REAL_VEC(S const& a): v(_mm_set1_pd(a)) { } + inline CCTK_REAL_VEC(int const& a): v(_mm_set1_pd(S(a))) { } // Copy constructor inline CCTK_REAL_VEC(CCTK_REAL_VEC const& x): v(x) { } @@ -175,8 +182,8 @@ DEFINE_FUNCTION_VR_V(pow,vec_set(pow(vec_elt0(x),a),pow(vec_elt1(x),a))) #undef Sign #define Sign(x) (42) -#undef ToReal -#define ToReal(x) vec_set1(x) +// #undef ToReal +// #define ToReal(x) vec_set1(x) #if defined(__PGI) && defined (__amd64__) // Special case for PGI 9.0.4 to avoid an internal compiler error diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-VSX-direct.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-VSX-direct.hh index 7e06017..7e06017 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-VSX-direct.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-VSX-direct.hh diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-VSX.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-VSX.hh index f591647..3fc97f6 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-VSX.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-VSX.hh @@ -208,5 +208,5 @@ DEFINE_FUNCTION_V_V(sqrt,vec_set(sqrt(vec_elt0(x)),sqrt(vec_elt1(x)))) #undef Sign #define Sign(x) (42) -#undef ToReal -#define ToReal(x) (vec_set1(x)) +// #undef ToReal +// #define ToReal(x) (vec_set1(x)) diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-default.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-default.hh index f928ed8..f928ed8 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-default.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-default.hh diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-define.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-define.hh index f5c0b22..f5c0b22 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-define.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-define.hh diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-outdated.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-outdated.hh index df83b3a..df83b3a 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-outdated.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-outdated.hh diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-pseudo.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-pseudo.hh index f439c9b..f439c9b 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-pseudo.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-pseudo.hh diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-undefine.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-undefine.hh index 0d950c7..0d950c7 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors-undefine.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors-undefine.hh diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors.hh b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors.hh index d32afb2..d32afb2 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/Vectors.hh +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/old/Vectors.hh |