aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2013-09-09 12:34:45 +0200
committerIan Hinder <ian.hinder@aei.mpg.de>2013-09-09 12:34:45 +0200
commit575f6fdeee767384348adfeccb515f812663418c (patch)
treea60b78d23a104e1085ed0277f3ea723c03bb20e6
parentdf70d64bd618338c4dcefbd9b3d31032828526f0 (diff)
Thorn.m: Move CreateSetterSource to CodeGenCalculation.m
-rw-r--r--Tools/CodeGen/CodeGenCalculation.m77
-rw-r--r--Tools/CodeGen/KrancThorn.m2
-rw-r--r--Tools/CodeGen/Thorn.m74
3 files changed, 77 insertions, 76 deletions
diff --git a/Tools/CodeGen/CodeGenCalculation.m b/Tools/CodeGen/CodeGenCalculation.m
index befc256..2c30bf6 100644
--- a/Tools/CodeGen/CodeGenCalculation.m
+++ b/Tools/CodeGen/CodeGenCalculation.m
@@ -19,13 +19,14 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
-BeginPackage["CalculationFunction`", {"CodeGenCactus`", "CodeGenC`", "CodeGen`",
+BeginPackage["CodeGenCalculation`", {"CodeGenCactus`", "CodeGenC`", "CodeGen`",
"CodeGenKranc`",
"MapLookup`", "KrancGroups`", "Differencing`", "Errors`",
"Helpers`", "Kranc`", "Optimize`", "Jacobian`", "Profile`", "Vectorisation`",
- "Calculation`", "DGFE`", "OpenCL`"}];
+ "Calculation`", "DGFE`", "OpenCL`", "CalculationBoundaries`"}];
CreateCalculationFunction::usage = "";
+CreateSetterSource::usage = "";
GridFunctionsInExpression;
Begin["`Private`"];
@@ -50,6 +51,78 @@ VerifyListContent[l_, type_, while_] :=
" objects, but found the following types of object: ",
ToString[types], " in ", l, while]]];
+(* ------------------------------------------------------------------------
+ Setter
+ ------------------------------------------------------------------------ *)
+
+(* calculation = {Name -> "ClassicADM_Setter",
+ optional Before -> {functions},
+ optional After -> {functions},
+ Shorthands -> {gInv11, ...},
+ GridFunctions -> {g11rhs, K11},
+ CollectList -> {hInv11, hInv22, ...},
+ optional DeclarationIncludes -> {include file list},
+ optional LoopPreIncludes -> {include file list},
+ Equations -> {{K11_rhs -> 2 A K11, ...}...}} *)
+
+
+(* Given a list of Calculation structures as defined above, create a
+ CodeGen representation of a source file that defines a function for
+ each Calculation. *)
+
+Options[CreateSetterSource] = ThornOptions;
+
+CreateSetterSource[calcs_, debug_, include_,
+ opts:OptionsPattern[]] :=
+ Module[{calc = First[calcs],bodyFunction},
+
+ If[!MatchQ[include, _List],
+ ThrowError["CreateSetterSource: Include should be a list but is in fact " <> ToString[include]]];
+
+ SetDataType[If[OptionValue[UseVectors],VectorisationType[], "CCTK_REAL"]];
+
+ {FileHeader["C"],
+
+ "#define KRANC_" <> ToUpperCase[CodeGenC`SOURCELANGUAGE] <> "\n\n",
+
+ If[CodeGenC`SOURCELANGUAGE == "C",
+ {IncludeSystemFile["assert.h"],
+ IncludeSystemFile["math.h"],
+ IncludeSystemFile["stdio.h"],
+ IncludeSystemFile["stdlib.h"],
+ IncludeSystemFile["string.h"]},
+ {"\n"}
+ ],
+
+ Map[IncludeFile, Join[{"cctk.h", "cctk_Arguments.h", "cctk_Parameters.h",
+ (*"precomputations.h",*) "GenericFD.h", "Differencing.h"},
+ include,
+ {"cctk_Loop.h", "loopcontrol.h"},
+ If[OptionValue[UseOpenCL], OpenCLIncludeFiles[], {}],
+ If[OptionValue[UseVectors], VectorisationIncludeFiles[], {}]]],
+ CalculationMacros[OptionValue[UseVectors]],
+
+ (* For each function structure passed, create the function and
+ insert it *)
+
+ CalculationBoundariesFunction[First[calcs]],
+
+ bodyFunction = DefineFunction[lookup[calc,Name]<>"_Body", "static void", "const cGH* restrict const cctkGH, const int dir, const int face, const CCTK_REAL normal[3], const CCTK_REAL tangentA[3], const CCTK_REAL tangentB[3], const int imin[3], const int imax[3], const int n_subblock_gfs, CCTK_REAL* restrict const subblock_gfs[]",
+ {
+ "DECLARE_CCTK_ARGUMENTS;\n",
+ "DECLARE_CCTK_PARAMETERS;\n\n",
+ #
+ }] &;
+
+ calc = Join[calc, {BodyFunction -> bodyFunction,
+ CallerFunction -> True,
+ LoopFunction -> (GenericGridLoop[lookup[calc,Name],#,opts] &),
+ GFAccessFunction -> ({#,"[","index","]"} &),
+ InitFDVariables -> InitialiseFDVariables[OptionValue[UseVectors]],
+ MacroPointer -> True}];
+
+ CreateCalculationFunction[calc, opts]}];
+
(* --------------------------------------------------------------------------
Calculations
-------------------------------------------------------------------------- *)
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index 3620a42..82b0e7a 100644
--- a/Tools/CodeGen/KrancThorn.m
+++ b/Tools/CodeGen/KrancThorn.m
@@ -31,7 +31,7 @@ BeginPackage["KrancThorn`", {"CodeGen`", "Thorn`",
"KrancTensor`", "Param`", "Schedule`", "Interface`", "Kranc`", "Jacobian`",
"ConservationCalculation`", "CaKernel`", "Calculation`", "ParamCheck`",
"OpenCL`", "CodeGenConfiguration`", "CodeGenMakefile`", "CodeGenSymmetries`", "MoL`",
- "CodeGenStartup`"}];
+ "CodeGenStartup`", "CodeGenCalculation`"}];
CreateKrancThorn::usage = "Construct a Kranc thorn";
diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m
index 009fdfd..9165aec 100644
--- a/Tools/CodeGen/Thorn.m
+++ b/Tools/CodeGen/Thorn.m
@@ -24,89 +24,17 @@
parts of a Cactus thorn and assemble them. *)
BeginPackage["Thorn`", "CodeGen`", "CodeGenC`", "CodeGenCactus`", "CodeGenKranc`", "CodeGenCalculation`",
- "CalculationBoundaries`", "MapLookup`", "KrancGroups`", "Helpers`",
+ "MapLookup`", "KrancGroups`", "Helpers`",
"Errors`", "Kranc`", "CaKernel`", "Vectorisation`", "DGFE`", "OpenCL`"];
(* These functions are externally visible, and comprise the public
interface to this package. *)
CreateThorn::usage = "Create a general Cactus thorn from
a thorn specification structure";
-CreateSetterSource::usage = "";
Begin["`Private`"];
-(* ------------------------------------------------------------------------
- Setter
- ------------------------------------------------------------------------ *)
-
-(* calculation = {Name -> "ClassicADM_Setter",
- optional Before -> {functions},
- optional After -> {functions},
- Shorthands -> {gInv11, ...},
- GridFunctions -> {g11rhs, K11},
- CollectList -> {hInv11, hInv22, ...},
- optional DeclarationIncludes -> {include file list},
- optional LoopPreIncludes -> {include file list},
- Equations -> {{K11_rhs -> 2 A K11, ...}...}} *)
-
-
-(* Given a list of Calculation structures as defined above, create a
- CodeGen representation of a source file that defines a function for
- each Calculation. *)
-
-Options[CreateSetterSource] = ThornOptions;
-
-CreateSetterSource[calcs_, debug_, include_,
- opts:OptionsPattern[]] :=
- Module[{calc = First[calcs],bodyFunction},
-
- If[!MatchQ[include, _List],
- ThrowError["CreateSetterSource: Include should be a list but is in fact " <> ToString[include]]];
-
- SetDataType[If[OptionValue[UseVectors],VectorisationType[], "CCTK_REAL"]];
-
- {FileHeader["C"],
-
- "#define KRANC_" <> ToUpperCase[CodeGenC`SOURCELANGUAGE] <> "\n\n",
-
- If[CodeGenC`SOURCELANGUAGE == "C",
- {IncludeSystemFile["assert.h"],
- IncludeSystemFile["math.h"],
- IncludeSystemFile["stdio.h"],
- IncludeSystemFile["stdlib.h"],
- IncludeSystemFile["string.h"]},
- {"\n"}
- ],
-
- Map[IncludeFile, Join[{"cctk.h", "cctk_Arguments.h", "cctk_Parameters.h",
- (*"precomputations.h",*) "GenericFD.h", "Differencing.h"},
- include,
- {"cctk_Loop.h", "loopcontrol.h"},
- If[OptionValue[UseOpenCL], OpenCLIncludeFiles[], {}],
- If[OptionValue[UseVectors], VectorisationIncludeFiles[], {}]]],
- CalculationMacros[OptionValue[UseVectors]],
-
- (* For each function structure passed, create the function and
- insert it *)
-
- CalculationBoundariesFunction[First[calcs]],
-
- bodyFunction = DefineFunction[lookup[calc,Name]<>"_Body", "static void", "const cGH* restrict const cctkGH, const int dir, const int face, const CCTK_REAL normal[3], const CCTK_REAL tangentA[3], const CCTK_REAL tangentB[3], const int imin[3], const int imax[3], const int n_subblock_gfs, CCTK_REAL* restrict const subblock_gfs[]",
- {
- "DECLARE_CCTK_ARGUMENTS;\n",
- "DECLARE_CCTK_PARAMETERS;\n\n",
- #
- }] &;
-
- calc = Join[calc, {BodyFunction -> bodyFunction,
- CallerFunction -> True,
- LoopFunction -> (GenericGridLoop[lookup[calc,Name],#,opts] &),
- GFAccessFunction -> ({#,"[","index","]"} &),
- InitFDVariables -> InitialiseFDVariables[OptionValue[UseVectors]],
- MacroPointer -> True}];
-
- CreateCalculationFunction[calc, opts]}];
(* ------------------------------------------------------------------------
Thorn creation