From 28dad7e6234066be57331427a78988d749986de3 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Mon, 2 Apr 2012 18:42:05 +0200 Subject: Implement CachedVariables key in calculations This is used by CaKernel to determine which variables to cache (i.e. to use shared memory for). --- Tools/CodeGen/CaKernel.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Tools/CodeGen/CaKernel.m') 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"]]]; -- cgit v1.2.3