aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2012-01-24 19:28:38 -0600
committerIan Hinder <ian.hinder@aei.mpg.de>2012-01-24 19:28:38 -0600
commit092cac89c2d19432a6b8830330a4c7ff607215c6 (patch)
treeeaa06608089a9c5d8740a322576d3539ab5cd41b /Tools/CodeGen
parentba24b2ce3f54fb8c9e86f2ce1dba6dd991d856f6 (diff)
CaKernel.m: Simplify macros in code file and implement rudimentary equation-generation
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r--Tools/CodeGen/CaKernel.m33
1 files changed, 15 insertions, 18 deletions
diff --git a/Tools/CodeGen/CaKernel.m b/Tools/CodeGen/CaKernel.m
index 2c82a80..f33cf60 100644
--- a/Tools/CodeGen/CaKernel.m
+++ b/Tools/CodeGen/CaKernel.m
@@ -75,26 +75,23 @@ DefFn[CaKernelCode[calc_List] :=
Module[
{kernel = "CAKERNEL_"<>GetCalculationName[calc]},
codeBlock[
- kernel<>"_Declare",
+ kernel,
- {kernel<>"_Declare_Cached_Variables_s"<>"\n",
- kernel<>"_Declare_Flow_Variables_s"<>"\n",
+ codeBlock[
+ kernel<>"_Computations",
+ Map[makeEquation[calc, #] &, GetEquations[calc]]]]]];
- codeBlock[
- kernel<>"_Limit_Threads_To_LSH",
-
- {kernel<>"_Fetch_Data_To_Cache_s"<>"\n",
-
- codeBlock[
- kernel<>"_Computations",
-
- {kernel<>"_Iterate_Local_Tile_s"<>"\n",
- kernel<>"_Fetch_Front_Tile_To_Cache_s"<>"\n",
-
- codeBlock[
- kernel<>"_Limit_Threads_To_Compute",
-
- "// Kernel code"]}]}]}]]];
+DefFn[
+ makeEquation[calc_List, eq_Rule] :=
+ Module[
+ {gfs, eq2},
+ gfs = AllGridFunctions[calc];
+ Print["eq = ", eq];
+ Print["gfs = ", gfs];
+ eq2 = eq /. Map[# -> ToString[#,CForm]<>"(0,0,0)" &, gfs];
+
+ StringReplace[FlattenBlock[{"// ", ToString[eq,InputForm], "\n",
+ ToString[eq2[[1]], CForm], " = ", ToString[eq2[[2]],CForm], "\n\n"}],"\""->""]]];
DefFn[CaKernelEpilogue[] :=
"