aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorRoland Haas <roland.haas@physics.gatech.edu>2010-02-18 16:16:22 -0500
committerRoland Haas <roland.haas@physics.gatech.edu>2010-03-23 17:08:35 -0400
commit0a68432002bcf94c8f1fbc79329b3e0f7b9491e9 (patch)
tree78949726b7adbe97bea427d80e72d0dfed82f8e4 /Tools
parente9e71f30e078b27dd48f53192fd8b157840c26f9 (diff)
allow arbitray expressions for conditions
Diffstat (limited to 'Tools')
-rw-r--r--Tools/CodeGen/CalculationFunction.m12
-rw-r--r--Tools/CodeGen/KrancThorn.m2
2 files changed, 12 insertions, 2 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m
index 295fd5e..a4fcb46 100644
--- a/Tools/CodeGen/CalculationFunction.m
+++ b/Tools/CodeGen/CalculationFunction.m
@@ -338,7 +338,7 @@ CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] :=
Module[{gfs, allSymbols, knownSymbols,
shorts, eqs, parameters,
functionName, dsUsed, groups, pddefs, cleancalc, eqLoop, where,
- addToStencilWidth, pDefs},
+ addToStencilWidth, pDefs, haveCondTextuals, condTextuals},
cleancalc = removeUnusedShorthands[calc];
shorts = lookupDefault[cleancalc, Shorthands, {}];
@@ -350,6 +350,7 @@ CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] :=
where = lookupDefault[cleancalc, Where, Everywhere];
addToStencilWidth = lookupDefault[cleancalc, AddToStencilWidth, 0];
pDefs = lookup[cleancalc, PreDefinitions];
+ haveCondTextuals = mapContains[cleancalc, ConditionalOnTextuals];
VerifyCalculation[cleancalc];
@@ -389,6 +390,13 @@ CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] :=
ThrowError["The following shorthands are already declared as grid functions:",
Intersection[shorts, gfs]]];
+ (* check that the passed in textual condition makes sense *)
+ If[haveCondTextuals,
+ condTextuals = lookup[cleancalc, ConditionalOnTextuals];
+ If[! MatchQ[condTextuals, {_String ...}],
+ ThrowError["ConditionalOnTextuals entry in calculation expected to be of the form {string, ...}, but was ", condTextuals, "Calculation is ", calc]];
+ ];
+
(* Check that there are no unknown symbols in the calculation *)
allSymbols = calculationSymbols[cleancalc];
knownSymbols = Join[lookupDefault[cleancalc, AllowedSymbols, {}], gfs, shorts, parameters,
@@ -415,6 +423,8 @@ CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] :=
ConditionalOnParameterTextual["cctk_iteration % " <> functionName <> "_calc_every != " <>
functionName <> "_calc_offset", "return;\n"],
+ If[haveCondTextuals, Map[ConditionalOnParameterTextual["!(" <> # <> ")", "return;\n"] &,condTextuals], {}],
+
CommentedBlock["Include user-supplied include files",
Map[IncludeFile, lookupDefault[cleancalc, DeclarationIncludes, {}]]],
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index 275cf8c..c1f8b25 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, Parameters};
+AllowedSymbols, Parameters, ConditionalOnTextuals};
EndPackage[];