aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2010-03-02 18:35:58 -0600
committerIan Hinder <ian.hinder@aei.mpg.de>2010-03-02 18:35:58 -0600
commit11fc168e7e12be14956b4472e85838abf6d25128 (patch)
tree460d0c7deec57b852bde017d69e1275229ab21d0 /Tools
parent0b97fbe33c5d71d797d67c8c4fa64ade69d5b092 (diff)
Obtain UseLoopControl directly using OptionValue
Diffstat (limited to 'Tools')
-rw-r--r--Tools/CodeGen/CalculationFunction.m18
-rw-r--r--Tools/CodeGen/CodeGen.m6
-rw-r--r--Tools/CodeGen/KrancThorn.m28
-rw-r--r--Tools/CodeGen/Thorn.m10
4 files changed, 34 insertions, 28 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m
index 4fd8d64..cad6bbf 100644
--- a/Tools/CodeGen/CalculationFunction.m
+++ b/Tools/CodeGen/CalculationFunction.m
@@ -428,7 +428,9 @@ definePreDefinitions[pDefs_] :=
(* Calculation function generation *)
-CreateCalculationFunction[calc_, debug_, useLoopControl_, useCSE_, opts:OptionsPattern[]] :=
+Options[CreateCalculationFunction] = ThornOptions;
+
+CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] :=
Module[{gfs, allSymbols, knownSymbols,
shorts, eqs, syncGroups, parameters,
functionName, dsUsed, groups, pddefs, cleancalc, numeq, eqLoop, GrepSYNC, where,
@@ -521,7 +523,7 @@ CreateCalculationFunction[calc_, debug_, useLoopControl_, useCSE_, opts:OptionsP
{
"DECLARE_CCTK_ARGUMENTS;\n",
"DECLARE_CCTK_PARAMETERS;\n\n",
- If[!useLoopControl, DeclareGridLoopVariables[], {}],
+ If[!OptionValue[UseLoopControl], DeclareGridLoopVariables[], {}],
DeclareFDVariables[],
(* declareVariablesForCalculation[cleancalc], *)
(* declarePrecomputedDerivatives[dsUsed], *)
@@ -561,7 +563,7 @@ CreateCalculationFunction[calc_, debug_, useLoopControl_, useCSE_, opts:OptionsP
(* Have removed ability to include external header files here.
Can be put back when we need it. *)
- eqLoop = Map[equationLoop[#, cleancalc, dsUsed, gfs, shorts, subblockGFs, {}, groups, syncGroups, pddefs, where, addToStencilWidth, useLoopControl, useCSE, opts] &, eqs]},
+ eqLoop = Map[equationLoop[#, cleancalc, dsUsed, gfs, shorts, subblockGFs, {}, groups, syncGroups, pddefs, where, addToStencilWidth, useCSE, opts] &, eqs]},
(* search for SYNCs *)
If[numeq <= 1,
@@ -676,7 +678,7 @@ Options[equationLoop] = ThornOptions;
equationLoop[eqs_,
cleancalc_, dsUsed_,
gfs_, shorts_, subblockGFs_, incs_, groups_, syncGroups_,
- pddefs_, where_, addToStencilWidth_, useLoopControl_, useCSE_,
+ pddefs_, where_, addToStencilWidth_, useCSE_,
opts:OptionsPattern[]] :=
Module[{rhss, lhss, gfsInRHS, gfsInLHS, gfsOnlyInRHS, localGFs, localMap, eqs2,
derivSwitch, actualSyncGroups, code, functionName, calcCode,
@@ -759,7 +761,7 @@ equationLoop[eqs_,
Map[localName, gfsInLHS]]],
*)
- GenericGridLoop[functionName, useLoopControl,
+ GenericGridLoop[functionName,
{declareVariablesForCalculation[cleancalc],
declarePrecomputedDerivatives[dsUsed],
(* DeclareDerivatives[pddefs, eqs], *)
@@ -791,7 +793,7 @@ equationLoop[eqs_,
" CCTK_VInfo(CCTK_THORNSTRING, \"from: %d %d %d\", cctk_lssh[CCTK_LSSH_IDX(0,0)], cctk_lssh[CCTK_LSSH_IDX(0,1)], cctk_lssh[CCTK_LSSH_IDX(0,2)]);\n"},
Map[{" CCTK_VInfo(CCTK_THORNSTRING, \"", localName[#], ": %.17g\", (double)", localName[#], ");\n"} &,
gfsInRHS],
- {"}\n"}]],
+ {"}\n"}],
*)
CommentedBlock["Assign local copies of subblock grid functions",
@@ -840,10 +842,10 @@ equationLoop[eqs_,
" CCTK_VInfo(CCTK_THORNSTRING, \"from: %d %d %d\", cctk_lssh[CCTK_LSSH_IDX(0,0)], cctk_lssh[CCTK_LSSH_IDX(0,1)], cctk_lssh[CCTK_LSSH_IDX(0,2)]);\n"},
Map[{" CCTK_VInfo(CCTK_THORNSTRING, \"", localName[#], ": %.17g\", (double)", localName[#], ");\n"} &,
gfsInLHS],
- {"}\n"}]],
+ {"}\n"}],
*)
- If[debugInLoop, Map[InfoVariable[GridName[#]] &, gfsInLHS], ""]}]]
+ If[debugInLoop, Map[InfoVariable[GridName[#]] &, gfsInLHS], ""]}, opts]]
};
lhsGroupNames = containingGroups[gfsInLHS, groups];
diff --git a/Tools/CodeGen/CodeGen.m b/Tools/CodeGen/CodeGen.m
index 2945d2b..1fb2a05 100644
--- a/Tools/CodeGen/CodeGen.m
+++ b/Tools/CodeGen/CodeGen.m
@@ -636,8 +636,10 @@ GridLoop[block_] :=
];
*)
-GenericGridLoop[functionName_, useLoopControl_, block_] :=
- If[useLoopControl,
+Options[GenericGridLoop] = ThornOptions;
+
+GenericGridLoop[functionName_, block_, opts:OptionsPattern[]] :=
+ If[OptionValue[UseLoopControl],
GenericGridLoopUsingLoopControl[functionName, block],
GenericGridLoopTraditional[block]];
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index 7a82ef9..fdfcd8d 100644
--- a/Tools/CodeGen/KrancThorn.m
+++ b/Tools/CodeGen/KrancThorn.m
@@ -52,7 +52,7 @@ ThornOptions =
{ConditionalOnKeyword, ConditionalOnKeywords, CollectList, Interior,
InteriorNoSync, Boundary, BoundaryWithGhosts, Where, PreDefinitions,
-AllowedSymbols, UseLoopControl, Parameters};
+AllowedSymbols, Parameters};
EndPackage[];
@@ -117,7 +117,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
interface, evolvedGroupDefinitions, rhsGroupDefinitions, thornspec,
allParams, boundarySources, reflectionSymmetries,
realParamDefs, intParamDefs,
- pDefs, useLoopControl, useCSE},
+ pDefs, useCSE},
(* Parse named arguments *)
@@ -147,7 +147,6 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
extendedKeywordParams = OptionValue[ExtendedKeywordParameters];
partialDerivs = OptionValue[PartialDerivatives];
reflectionSymmetries = OptionValue[ReflectionSymmetries];
- useLoopControl = OptionValue[UseLoopControl];
useCSE = OptionValue[UseCSE];
coordGroup = {"grid::coordinates", {sym`x,sym`y,sym`z,sym`r}};
@@ -188,13 +187,13 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
(* Construct the configuration file *)
InfoMessage[Terse, "Creating configuration file"];
- configuration = createKrancConfiguration[useLoopControl];
+ configuration = createKrancConfiguration[opts];
(* Construct the interface file *)
InfoMessage[Terse, "Creating interface file"];
interface = createKrancInterface[nonevolvedGroups,
evolvedGroups, rhsGroups, groups,
- implementation, inheritedImplementations, includeFiles, useLoopControl, opts];
+ implementation, inheritedImplementations, includeFiles, opts];
(* Construct the param file *)
InfoMessage[Terse, "Creating param file"];
@@ -243,7 +242,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
Map[unqualifiedName, inheritedKeywordParams]];
InfoMessage[Terse, "Creating calculation source files"];
- calcSources = Map[CreateSetterSourceWrapper[#, allParams, partialDerivs, useLoopControl, useCSE, opts] &, calcs];
+ calcSources = Map[CreateSetterSourceWrapper[#, allParams, partialDerivs, useCSE, opts] &, calcs];
calcFilenames = Map[lookup[#, Name] <> ext &, calcs];
(* Makefile *)
@@ -341,16 +340,16 @@ nonevolvedTimelevels[group_] :=
Module[{tls = GroupTimelevels[group]},
If[ tls === False, 1, tls]];
-createKrancConfiguration[useLoopControl_] :=
+createKrancConfiguration[opts:OptionsPattern[]] :=
Module[{configuration},
- configuration = CreateConfiguration[useLoopControl];
+ configuration = CreateConfiguration[opts];
Return[configuration]];
Options[createKrancInterface] = ThornOptions;
createKrancInterface[nonevolvedGroups_, evolvedGroups_, rhsGroups_, groups_,
implementation_, inheritedImplementations_,
- includeFiles_, useLoopControl_, opts:OptionsPattern[]] :=
+ includeFiles_, opts:OptionsPattern[]] :=
Module[{registerEvolved, (*registerConstrained,*)
nonevolvedGroupStructures, evolvedGroupStructures, rhsGroupStructures,
@@ -408,7 +407,7 @@ createKrancInterface[nonevolvedGroups_, evolvedGroups_, rhsGroups_, groups_,
interface = CreateInterface[implementation, inheritedImplementations,
Join[includeFiles, {CactusBoundary`GetIncludeFiles[]},
- If[useLoopControl, {"loopcontrol.h"}, {}]],
+ If[OptionValue[UseLoopControl], {"loopcontrol.h"}, {}]],
groupStructures,
UsesFunctions ->
Join[{registerEvolved, (*registerConstrained,*) diffCoeff},
@@ -753,15 +752,16 @@ createKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedG
Return[schedule]];
-
-CreateSetterSourceWrapper[calc_, parameters_, derivs_, useLoopControl_, useCSE_, opts:OptionsPattern[]] :=
+Options[CreateSetterSourceWrapper] = ThornOptions;
+
+CreateSetterSourceWrapper[calc_, parameters_, derivs_, useCSE_, opts:OptionsPattern[]] :=
Module[{modCalc},
modCalc = Join[calc /. ((Equations -> {es___}) -> (Equations -> {{es}})),
{Parameters -> parameters},
{PartialDerivatives -> derivs}];
- source = CreateSetterSource[{modCalc}, False, useLoopControl, useCSE,
- If[useLoopControl, {"loopcontrol.h"}, {}], opts];
+ source = CreateSetterSource[{modCalc}, False, useCSE,
+ If[OptionValue[UseLoopControl], {"loopcontrol.h"}, {}], opts];
Return[source]];
(* FIXME: This is still not quite right. We only want to have those variables that
diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m
index 61a241d..147a056 100644
--- a/Tools/CodeGen/Thorn.m
+++ b/Tools/CodeGen/Thorn.m
@@ -229,10 +229,12 @@ CreateParam[spec_] :=
Configuration file
------------------------------------------------------------------------ *)
-CreateConfiguration[useLoopControl_] :=
+Options[CreateConfiguration] = ThornOptions;
+
+CreateConfiguration[opts:OptionsPattern[]] :=
{whoWhen["CCL"],
"REQUIRES GenericFD\n",
- If[useLoopControl, "REQUIRES LoopControl\n", {}]
+ If[OptionValue[UseLoopControl], "REQUIRES LoopControl\n", {}]
};
(* ------------------------------------------------------------------------
@@ -495,7 +497,7 @@ calculationMacros[] :=
CodeGen representation of a source file that defines a function for
each Calculation. *)
-CreateSetterSource[calcs_, debug_, useLoopControl_, useCSE_, include_,
+CreateSetterSource[calcs_, debug_, useCSE_, include_,
opts:OptionsPattern[]] :=
Module[{},
@@ -521,7 +523,7 @@ CreateSetterSource[calcs_, debug_, useLoopControl_, useCSE_, include_,
(* For each function structure passed, create the function and
insert it *)
- Map[CreateCalculationFunction[# , debug, useLoopControl, useCSE, opts]& ,
+ Map[CreateCalculationFunction[# , debug, useCSE, opts]& ,
calcs]}];