diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-03-02 09:40:36 -0600 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-03-02 09:40:36 -0600 |
commit | 7a0f65c45121d1fa7141b847acf246a68b9d8be8 (patch) | |
tree | 67b8f2d7cac8e72a33acc5f9a9b3442badf769dc | |
parent | 90044389629f516e431f6a266b817771ae6b2d7b (diff) |
Start passing all CreateThorn options to lower level functions
-rw-r--r-- | Tools/CodeGen/CalculationFunction.m | 10 | ||||
-rw-r--r-- | Tools/CodeGen/KrancThorn.m | 37 | ||||
-rw-r--r-- | Tools/CodeGen/Thorn.m | 8 |
3 files changed, 41 insertions, 14 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index 5efc32c..6f20c35 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -428,7 +428,7 @@ definePreDefinitions[pDefs_] := (* Calculation function generation *) -CreateCalculationFunction[calc_, debug_, useLoopControl_, useCSE_] := +CreateCalculationFunction[calc_, debug_, useLoopControl_, useCSE_, opts:OptionsPattern[]] := Module[{gfs, allSymbols, knownSymbols, shorts, eqs, syncGroups, parameters, functionName, dsUsed, groups, pddefs, cleancalc, numeq, eqLoop, GrepSYNC, where, @@ -561,7 +561,7 @@ CreateCalculationFunction[calc_, debug_, useLoopControl_, useCSE_] := (* 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] &, eqs]}, + eqLoop = Map[equationLoop[#, cleancalc, dsUsed, gfs, shorts, subblockGFs, {}, groups, syncGroups, pddefs, where, addToStencilWidth, useLoopControl, useCSE, opts] &, eqs]}, (* search for SYNCs *) If[numeq <= 1, @@ -662,7 +662,6 @@ splitPDDefsWithShorthands[pddefs_, shorthands_] := defsWithoutShorts = Select[pddefs, ! defContainsShorthand[#, shorthands] &]; Return[{defsWithoutShorts, defsWithShorts}]]; - pdCanonicalOrdering[name_[inds___] -> x_] := Module[{is}, is = {inds}; @@ -672,10 +671,13 @@ pdCanonicalOrdering[name_[inds___] -> x_] := name[f_,3,2] -> name[f,2,3]}], {}]]; +Options[equationLoop] = ThornOptions; + equationLoop[eqs_, cleancalc_, dsUsed_, gfs_, shorts_, subblockGFs_, incs_, groups_, syncGroups_, - pddefs_, where_, addToStencilWidth_, useLoopControl_, useCSE_] := + pddefs_, where_, addToStencilWidth_, useLoopControl_, useCSE_, + opts:OptionsPattern[]] := Module[{rhss, lhss, gfsInRHS, gfsInLHS, gfsOnlyInRHS, localGFs, localMap, eqs2, derivSwitch, actualSyncGroups, code, functionName, calcCode, syncCode, loopFunction}, diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m index 38c7c9a..aa21242 100644 --- a/Tools/CodeGen/KrancThorn.m +++ b/Tools/CodeGen/KrancThorn.m @@ -32,7 +32,7 @@ BeginPackage["sym`"]; ExtendedRealParameters,ExtendedIntParameters,ExtendedKeywordParameters, Parameters, EvolutionTimelevels, DefaultEvolutionTimelevels, - UseCSE, + UseCSE, ThornOptions, PartialDerivatives, InheritedImplementations, ConditionalOnKeyword, ConditionalOnKeywords, ReflectionSymmetries, ZeroDimensions, CollectList, Interior, InteriorNoSync, Boundary, BoundaryWithGhosts, Where, PreDefinitions, AllowedSymbols, UseLoopControl}; @@ -102,7 +102,32 @@ Module[{allowed = {Calculations, replaceDots[x_] := x /. (dot[y_] :> Symbol[ToString[y] <> "rhs"]); -CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts___] := +ThornOptions = + {Calculations -> {}, + DeclaredGroups -> {}, + Implementation -> None, + InheritedImplementations -> {}, + EvolutionTimelevels -> 3, + DefaultEvolutionTimelevels -> None, + RealParameters -> {}, + IntParameters -> {}, + KeywordParameters -> {}, + InheritedRealParameters -> {}, + InheritedIntParameters -> {}, + InheritedKeywordParameters -> {}, + ExtendedRealParameters -> {}, + ExtendedIntParameters -> {}, + ExtendedKeywordParameters -> {}, + PartialDerivatives -> {}, + ReflectionSymmetries -> {}, + ZeroDimensions -> {}, + UseLoopControl -> False, + UseCSE -> False, + ProhibitAssignmentToGridfunctionsRead -> False}; + +Options[CreateKrancThorn] = ThornOptions; + +CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[]] := Module[{calcs, declaredGroups, implementation, inheritedImplementations, includeFiles, evolutionTimelevels, defaultEvolutionTimelevels, @@ -247,7 +272,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts___] := Map[unqualifiedName, inheritedIntParams], Map[unqualifiedName, inheritedKeywordParams]]; InfoMessage[Terse, "Creating calculation source files"]; - calcSources = Map[CreateSetterSourceWrapper[#, allParams, partialDerivs, useLoopControl, useCSE] &, calcs]; + calcSources = Map[CreateSetterSourceWrapper[#, allParams, partialDerivs, useLoopControl, useCSE, opts] &, calcs]; calcFilenames = Map[lookup[#, Name] <> ext &, calcs]; @@ -810,14 +835,14 @@ createKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedG ]; -CreateSetterSourceWrapper[calc_, parameters_, derivs_, useLoopControl_, useCSE_] := +CreateSetterSourceWrapper[calc_, parameters_, derivs_, useLoopControl_, useCSE_, opts:OptionsPattern[]] := Module[{modCalc}, modCalc = Join[calc /. ((Equations -> {es___}) -> (Equations -> {{es}})), {Parameters -> parameters}, {PartialDerivatives -> derivs}]; - source = CreateSetterSource[{modCalc}, False, useLoopControl, useCSE, Include -> - If[useLoopControl, {"loopcontrol.h"}, {}]]; + source = CreateSetterSource[{modCalc}, False, useLoopControl, useCSE, + If[useLoopControl, {"loopcontrol.h"}, {}], opts]; Return[source] ]; diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index b4a021d..61a241d 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -495,9 +495,9 @@ calculationMacros[] := CodeGen representation of a source file that defines a function for each Calculation. *) -CreateSetterSource[calcs_, debug_, useLoopControl_, useCSE_, opts___] := - Module[{include}, - include = lookupDefault[{opts}, Include, {}]; +CreateSetterSource[calcs_, debug_, useLoopControl_, useCSE_, include_, + opts:OptionsPattern[]] := + Module[{}, If[!MatchQ[include, _List], Throw["CreateSetterSource: Include should be a list but is in fact " <> ToString[include]]]; @@ -521,7 +521,7 @@ CreateSetterSource[calcs_, debug_, useLoopControl_, useCSE_, opts___] := (* For each function structure passed, create the function and insert it *) - Map[CreateCalculationFunction[# , debug, useLoopControl, useCSE]& , + Map[CreateCalculationFunction[# , debug, useLoopControl, useCSE, opts]& , calcs]}]; |