diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-11-30 22:45:57 +0100 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-12-01 13:47:42 +0100 |
commit | 0101aa58b9485742a3b688ccfdc1863a9409779f (patch) | |
tree | 3a2c688c5098491f572752430f579a92645bdf22 /Tools/CodeGen/CalculationFunction.m | |
parent | 9984aa6d2919c400b08573064e0556741f84e4c6 (diff) |
Check group storage
Diffstat (limited to 'Tools/CodeGen/CalculationFunction.m')
-rw-r--r-- | Tools/CodeGen/CalculationFunction.m | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index d73adb6..4c4cd83 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -157,6 +157,23 @@ removeUnusedShorthands[calc_] := removeUnusedShorthands[newCalc], newCalc]]; +(* Return all the groups that are used in a given calculation *) +groupsInCalculation[calc_, imp_] := + Module[{groups,gfs,eqs,gfsUsed, groupNames}, + groups = lookup[calc, Groups]; + gfs = allGroupVariables[groups]; + eqs = lookup[calc, Equations]; + gfsUsed = Union[Cases[eqs, _ ? (MemberQ[gfs,#] &), Infinity]]; + groupNames = containingGroups[gfsUsed, groups]; + Map[qualifyGroupName[#, imp] &, groupNames]]; + +CheckGroupStorage[groupNames_, calcName_] := + Module[{}, + {"\nconst char *groups[] = {", + Riffle[Map[Quote,groupNames], ","], + "};\n", + "GenericFD_AssertGroupStorage(cctkGH, ", Quote[calcName],", ", Length[groupNames], ", groups);\n"}]; + (* -------------------------------------------------------------------------- Variables -------------------------------------------------------------------------- *) @@ -324,7 +341,7 @@ pdCanonicalOrdering[name_[inds___] -> x_] := Options[CreateCalculationFunction] = ThornOptions; -CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] := +CreateCalculationFunction[calc_, debug_, useCSE_, imp_, opts:OptionsPattern[]] := Module[{gfs, allSymbols, knownSymbols, shorts, eqs, parameters, functionName, dsUsed, groups, pddefs, cleancalc, eqLoop, where, @@ -413,6 +430,8 @@ CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] := ConditionalOnParameterTextual["cctk_iteration % " <> functionName <> "_calc_every != " <> functionName <> "_calc_offset", "return;\n"], + CheckGroupStorage[groupsInCalculation[cleancalc, imp], functionName], + If[haveCondTextuals, Map[ConditionalOnParameterTextual["!(" <> # <> ")", "return;\n"] &,condTextuals], {}], CommentedBlock["Include user-supplied include files", |