aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2012-04-02 18:42:05 +0200
committerIan Hinder <ian.hinder@aei.mpg.de>2012-04-02 18:42:05 +0200
commit28dad7e6234066be57331427a78988d749986de3 (patch)
tree9a10761a3784b6c7925f9be2263c62cfc180e5aa /Tools
parent2026943d8a0250f277b279b812482831d6315888 (diff)
Implement CachedVariables key in calculations
This is used by CaKernel to determine which variables to cache (i.e. to use shared memory for).
Diffstat (limited to 'Tools')
-rw-r--r--Tools/CodeGen/CaKernel.m11
-rw-r--r--Tools/CodeGen/CalculationFunction.m2
-rw-r--r--Tools/CodeGen/Kranc.m2
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,