aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen/CaKernel.m
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/CodeGen/CaKernel.m
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/CodeGen/CaKernel.m')
-rw-r--r--Tools/CodeGen/CaKernel.m11
1 files changed, 7 insertions, 4 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"]]];