diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2009-04-27 11:29:45 -0500 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2009-04-27 21:52:21 +0200 |
commit | 5a954d37db3b107945cb8e386ef97b61926009a7 (patch) | |
tree | e1832eadb54240e27a2815c091ab68d57ed3f1bb | |
parent | 269ff945b9bbed7724db0d960c671a6e5f15b801 (diff) |
Add (currently unused) macros and definitions for dealing with vectors of grid points. This may allow generating vectorised code in the future.
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h | 36 | ||||
-rw-r--r-- | Tools/CodeGen/CalculationFunction.m | 3 |
2 files changed, 38 insertions, 1 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h index 6dd1067..a34f6d0 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h @@ -765,4 +765,40 @@ void GenericFD_LoopOverBoundary(cGH *cctkGH, Kranc_Calculation calc); void GenericFD_LoopOverBoundaryWithGhosts(cGH *cctkGH, Kranc_Calculation calc); void GenericFD_LoopOverInterior(cGH *cctkGH, Kranc_Calculation calc); + + +/* Vectorisation of memory accesses */ + +#include <stdlib.h> +#include <cctk.h> + +#if defined(__SSE2__) && defined(CCTK_REAL_PRECISION_8) + +#include <emmintrin.h> + +/* A vector type corresponding to CCTK_REAL */ +typedef __m128d CCTK_REAL_VEC; + +/* Really only SSE is required, but there doesn't seem to be a + preprocessing flag to check for this */ +#elif defined(__SSE2__) && defined(CCTK_REAL_PRECISION_4) + +#include <emmintrin.h> + +/* A vector type corresponding to CCTK_REAL */ +typedef __m128 CCTK_REAL_VEC; + +#else + +/* There is no vector type corresponding to CCTK_REAL */ +typedef CCTK_REAL CCTK_REAL_VEC; + +#endif + +/* The number of vector elements in a CCTK_REAL_VEC */ +static +size_t const CCTK_REAL_VEC_SIZE = sizeof(CCTK_REAL_VEC) / sizeof(CCTK_REAL); + + + #endif diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index c5fb2f8..71a45fa 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -84,6 +84,7 @@ simpCollect[collectList_, eqrhs_, localvar_, debug_] := (* Take a grid function name and return a name suitable for use in a local computation *) localName[x_] := ToExpression[ToString[x] <> "L"]; +localNameVectorised[x_] := ToExpression[ToString[x] <> "V"]; (* Given a map (i.e. a list of rules { a -> A, b -> B, ... } return the inverse map { A -> a, B -> b, ...} *) @@ -131,7 +132,7 @@ assignVariableFromExpression[dest_, expr_] := Module[{tSym, cleanExpr, code}, cleanExpr = ReplacePowers[expr] /. sym`t -> tSym; - If[SOURCELANGUAGE == "C", + If[SOURCELANGUAGE == "C", code = ToString[dest == cleanExpr, CForm, PageWidth -> 80] <> ";\n", code = ToString@dest <> ".eq." <> ToString[cleanExpr, FortranForm, PageWidth -> 80] <> "\n" ]; |