diff options
-rw-r--r-- | Tools/CodeGen/CaKernel.m | 11 | ||||
-rw-r--r-- | Tools/CodeGen/CalculationFunction.m | 2 | ||||
-rw-r--r-- | Tools/CodeGen/Kranc.m | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/Tools/CodeGen/CaKernel.m b/Tools/CodeGen/CaKernel.m index 3668580..08494e8 100644 --- a/Tools/CodeGen/CaKernel.m +++ b/Tools/CodeGen/CaKernel.m @@ -31,8 +31,8 @@ CaKernelInterfaceCLL; Begin["`Private`"]; DefFn[ - variableBlock[var_, intent_String] := - CCLBlock["CCTK_CUDA_KERNEL_VARIABLE", "", {"cached" -> "no", "intent" -> intent}, {var,"\n"}, ToString[var]]]; + variableBlock[var_, intent_String, cached_] := + CCLBlock["CCTK_CUDA_KERNEL_VARIABLE", "", {"cached" -> If[cached,"yes","no"], "intent" -> intent}, {var,"\n"}, ToString[var]]]; DefFn[ parameterBlock[par_] := @@ -41,7 +41,7 @@ DefFn[ DefFn[ variableBlocks[calc_] := Module[ - {in,out,all,inOnly,outOnly,inOut,params}, + {in,out,all,inOnly,outOnly,inOut,params, cachedVars}, params = GetCalculationParameters[calc]; in = Join[InputGridFunctions[calc]]; @@ -52,11 +52,14 @@ DefFn[ outOnly = Complement[out, in]; inOut = Intersection[in,out]; + cachedVars = lookupDefault[calc, CachedVariables, {}]; + Riffle[ Map[variableBlock[#, Which[MemberQ[inOnly, #], "in", MemberQ[outOnly, #], "out", MemberQ[inOut, #], "inout", - True,ThrowError["Unable to determine use of variable "<>ToString[#]]]] &, all]~Join~ + True,ThrowError["Unable to determine use of variable "<>ToString[#]]], + MemberQ[cachedVars,#]] &, all]~Join~ Map[parameterBlock, params], "\n"]]]; diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index 136f15d..5b8109c 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -144,7 +144,7 @@ VerifyCalculation[calc_] := PartialDerivatives, PreDefinitions, Schedule,Equations, Shorthands, ConditionalOnKeyword, Before, After, ConditionalOnTextuals, Where, ConditionalOnKeywords, - CollectList, AllowedSymbols, ApplyBCs, Conditional}; + CollectList, AllowedSymbols, ApplyBCs, Conditional, CachedVariables}; usedKeys = Map[First, calc]; unknownKeys = Complement[usedKeys, allowedKeys]; diff --git a/Tools/CodeGen/Kranc.m b/Tools/CodeGen/Kranc.m index 08f9a84..29bee44 100644 --- a/Tools/CodeGen/Kranc.m +++ b/Tools/CodeGen/Kranc.m @@ -43,7 +43,7 @@ Boundary, Interior, InteriorNoSync, Where, AddToStencilWidth, Everywhere, normal1, normal2, normal3, INV, SQR, CUB, QAD, dot, pow, exp, dt, dx, dy, dz, idx, idy, idz, t, MinMod, VanLeer, BodyFunction, CallerFunction, LoopFunction, GFAccessFunction, InitFDVariables, -MacroPointer} +MacroPointer, CachedVariables} {ConditionalOnKeyword, ConditionalOnKeywords, CollectList, Interior, InteriorNoSync, Boundary, BoundaryWithGhosts, Where, PreDefinitions, |