aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2012-02-16 21:05:39 -0500
committerErik Schnetter <schnetter@gmail.com>2012-02-16 21:05:39 -0500
commitb95b275c6e37f0ee902eca7d413f49486682dc1c (patch)
tree3f055cafe3abd204b5aaea27a346d66275619f6b /Tools/CodeGen
parentf5f9dbaf3ceb65dcc5c9fdc90ec529fd3901af2f (diff)
Update OpenCL to new flesh. Support derivatives in DGFE.
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r--Tools/CodeGen/CalculationFunction.m51
-rw-r--r--Tools/CodeGen/Schedule.m2
-rw-r--r--Tools/CodeGen/Thorn.m4
3 files changed, 41 insertions, 16 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m
index f31c815..2a880bf 100644
--- a/Tools/CodeGen/CalculationFunction.m
+++ b/Tools/CodeGen/CalculationFunction.m
@@ -380,7 +380,7 @@ DefFn[
shorts, eqs, parameters, parameterRules, odeGroups,
functionName, dsUsed, groups, pddefs, cleancalc, eqLoop, where,
addToStencilWidth, pDefs, haveCondTextuals, condTextuals, calc,
- kernelCall, DGFEDefs, DGFECall},
+ kernelCall, DGFEDefs, DGFEInit, DGFECall},
functionName = ToString@lookup[calcp, Name];
bodyFunctionName = functionName <> "_Body";
@@ -471,21 +471,21 @@ DefFn[
kernelCall = Switch[where,
Everywhere,
- "GenericFD_LoopOverEverything(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverEverything(cctkGH, " <> bodyFunctionName <> ");\n",
Interior,
- "GenericFD_LoopOverInterior(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverInterior(cctkGH, " <> bodyFunctionName <> ");\n",
InteriorNoSync,
- "GenericFD_LoopOverInterior(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverInterior(cctkGH, " <> bodyFunctionName <> ");\n",
Boundary,
- "GenericFD_LoopOverBoundary(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverBoundary(cctkGH, " <> bodyFunctionName <> ");\n",
BoundaryWithGhosts,
- "GenericFD_LoopOverBoundaryWithGhosts(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverBoundaryWithGhosts(cctkGH, " <> bodyFunctionName <> ");\n",
_,
ThrowError["Unknown 'Where' entry in calculation " <>
functionName <> ": " <> ToString[where]]];
DGFEDefs =
- If[OptionValue[UseDGFE] && lookupDefault[cleancalc, UseDGFE, False],
+ If[OptionValue[UseDGFE],
Module[
{name, lhss, gfsInLHS, vars},
InfoMessage[InfoFull, "Generating DGFE boilerplate"];
@@ -662,11 +662,38 @@ DefFn[
"}",
"",
"",
+ "",
+ "/* A solver, DGFE's equivalent of cctkGH */",
+ "static "<>name<>"_solver *solver = NULL;",
+ "",
+ "",
+ "",
+ "/* Call the pointwise DGFE derivative operator */",
+ "#undef PDstandardNth1",
+ "#undef PDstandardNth2",
+ "#undef PDstandardNth3",
+ "#define PDstandardNth1(u) (solver->diff<hrscc::policy::x>(&(u)[-index], i,j,k))",
+ "#define PDstandardNth2(u) (solver->diff<hrscc::policy::y>(&(u)[-index], i,j,k))",
+ "#define PDstandardNth3(u) (solver->diff<hrscc::policy::z>(&(u)[-index], i,j,k))",
+ "",
+ "",
""
} // Flatten // Map[# <> "\n" &, #] &],
{}
];
+ DGFEInit =
+ If[OptionValue[UseDGFE],
+ Module[
+ {name},
+ name = lookup[cleancalc, Name];
+ {
+ "",
+ "if (not solver) solver = new "<>name<>"_method(cctkGH);"
+ } // Flatten // Map[# <> "\n" &, #] &],
+ {}
+ ];
+
DGFECall =
If[OptionValue[UseDGFE] && lookupDefault[cleancalc, UseDGFE, False],
Module[
@@ -674,12 +701,8 @@ DefFn[
name = lookup[cleancalc, Name];
{
"",
- "{",
- " static "<>name<>"_solver *solver = NULL;",
- " if (not solver) solver = new "<>name<>"_method(cctkGH);",
- " solver->compute_rhs();",
- " // delete solver;",
- "}"
+ "/* Add the flux terms to the RHS */",
+ "solver->compute_rhs();"
} // Flatten // Map[# <> "\n" &, #] &],
{}
];
@@ -781,6 +804,8 @@ DefFn[
If[haveCondTextuals, Map[ConditionalOnParameterTextual["!(" <> # <> ")", "return;\n"] &,condTextuals], {}],
+ DGFEInit,
+
kernelCall,
DGFECall,
diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m
index f83578f..9871ab2 100644
--- a/Tools/CodeGen/Schedule.m
+++ b/Tools/CodeGen/Schedule.m
@@ -106,7 +106,7 @@ scheduleCalc[calc_, groups_, thornName_, useOpenCL_] :=
(* TODO: Pass this as {keyword,value} pair instead of a string,
once Thorn.m understands this format *)
- tags = If[useOpenCL, "OpenCL=1", ""];
+ tags = If[useOpenCL, "Device=1", ""];
prefixWithScope[group_] :=
If[StringMatchQ[ToString[group], __~~"::"~~__],
diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m
index 47d7d7c..6dc547c 100644
--- a/Tools/CodeGen/Thorn.m
+++ b/Tools/CodeGen/Thorn.m
@@ -392,8 +392,8 @@ scheduleUnconditionalFunction[spec_] :=
"TAGS: " <> lookup[spec, Tags] <> "\n",
""],
- Map[{"REQUIRES: ", #, "\n"} &, lookupDefault[spec, RequiredGroups, {}]],
- Map[{"PROVIDES: ", #, "\n"} &, lookupDefault[spec, ProvidedGroups, {}]],
+ Map[{"READS: ", #, "\n"} &, lookupDefault[spec, RequiredGroups, {}]],
+ Map[{"WRITES: ", #, "\n"} &, lookupDefault[spec, ProvidedGroups, {}]],
(* Insert a storage block for each group we want to allocate
storage for *)