diff options
author | Barry Wardell <barry.wardell@gmail.com> | 2012-02-09 17:41:23 +0000 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2012-02-09 17:43:13 +0000 |
commit | a537129f7d3660d1710cc98ffc836645ffa0e5e7 (patch) | |
tree | d5ef15e19e00bc05678b675fd7d76eaea88d6e92 /Tools/CodeGen | |
parent | a497c627ec200f89807b2295b5553b9595f3bc26 (diff) |
CalculationFunction: Gain a speedup in Krancing by only computing the stencil size once.
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r-- | Tools/CodeGen/CalculationFunction.m | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index 9c7e9f7..abd6405 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -378,7 +378,7 @@ DefFn[ shorts, eqs, parameters, parameterRules, odeGroups, functionName, dsUsed, groups, pddefs, cleancalc, eqLoop, where, addToStencilWidth, pDefs, haveCondTextuals, condTextuals, calc, - kernelCall, DGFEDefs, DGFECall,debug,imp,gridName}, + kernelCall, DGFEDefs, DGFECall, debug, imp, gridName, stencilSize}, debug = OptionValue[Debug]; imp = lookup[calcp, Implementation]; @@ -412,15 +412,6 @@ DefFn[ VerifyCalculation[cleancalc]; - Module[ - {stencilSize = StencilSize[pddefs, eqs, functionName, OptionValue[ZeroDimensions], - lookup[{opts}, IntParameters, {}]]}, - If[!VectorQ[stencilSize], - stencilSize = MapThread[Max,Map[Last,stencilSize[[2]]]]]; - - If[where === Automatic, - where = If[MatchQ[stencilSize, {0,0,0}] =!= True, Interior, Everywhere]]]; - gfs = allGroupVariables[groups]; InfoMessage[InfoFull, " " <> ToString[Length@shorts] <> " shorthands"]; @@ -450,6 +441,15 @@ DefFn[ Scan[InfoMessage[InfoFull, " " <> ToString@First[#]<>" = ..."] &, eqs]; + (* Compute necessary stencil size *) + stencilSize = StencilSize[pddefs, eqs, functionName, OptionValue[ZeroDimensions], + lookup[{opts}, IntParameters, {}]]; + If[!VectorQ[stencilSize], + stencilSize = MapThread[Max,Map[Last,stencilSize[[2]]]]]; + + If[where === Automatic, + where = If[MatchQ[stencilSize, {0,0,0}] =!= True, Interior, Everywhere]]; + (* Check all the function names *) functionsPresent = functionsInCalculation[cleancalc]; (* Not currently used *) @@ -771,14 +771,8 @@ DefFn[ CheckStencil[pddefs, eqs, functionName, OptionValue[ZeroDimensions], lookup[{opts}, IntParameters, {}]], - Module[ - {stencilSize = StencilSize[pddefs, eqs, functionName, OptionValue[ZeroDimensions], - lookup[{opts}, IntParameters, {}]]}, - If[!VectorQ[stencilSize], - stencilSize = MapThread[Max,Map[Last,stencilSize[[2]]]]]; - - If[where === Everywhere && MatchQ[stencilSize, {0,0,0}] =!= True, - ThrowError["Calculation "<>functionName<>" uses derivative operators but is computed Everywhere. Specify Where -> Interior for calculations that use derivative operators."]]]; + If[where === Everywhere && MatchQ[stencilSize, {0,0,0}] =!= True, + ThrowError["Calculation "<>functionName<>" uses derivative operators but is computed Everywhere. Specify Where -> Interior for calculations that use derivative operators."]]; "\n", If[haveCondTextuals, Map[ConditionalOnParameterTextual["!(" <> # <> ")", "return;\n"] &,condTextuals], {}], |