aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2012-02-02 02:52:08 -0600
committerIan Hinder <ian.hinder@aei.mpg.de>2012-02-02 02:52:08 -0600
commitda7817de6900bf1089b4ef3268016e1f6a276340 (patch)
treeecc1250f61f99743de14e2427e81fde6638b8186 /Tools
parent6ea7ef3015e1ed2dbf56853a7092d098d1610395 (diff)
Allow calculations to occur either on the host or the device
Diffstat (limited to 'Tools')
-rw-r--r--Tools/CodeGen/CaKernel.m2
-rw-r--r--Tools/CodeGen/KrancThorn.m28
-rw-r--r--Tools/CodeGen/Schedule.m6
3 files changed, 22 insertions, 14 deletions
diff --git a/Tools/CodeGen/CaKernel.m b/Tools/CodeGen/CaKernel.m
index 7d12bf2..968d6dd 100644
--- a/Tools/CodeGen/CaKernel.m
+++ b/Tools/CodeGen/CaKernel.m
@@ -73,7 +73,7 @@ DefFn[
DefFn[CaKernelCCL[calcs_List] :=
Module[
{},
- Map[kernelCCLBlock, calcs]]];
+ Map[kernelCCLBlock, Select[calcs, CalculationOnDevice]]]];
DefFn[CaKernelSchedule[] :=
{}];
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index 76dd867..d580da2 100644
--- a/Tools/CodeGen/KrancThorn.m
+++ b/Tools/CodeGen/KrancThorn.m
@@ -29,7 +29,7 @@ BeginPackage["KrancThorn`", {"CodeGen`", "Thorn`",
"MapLookup`", "KrancGroups`", "Differencing`",
"CalculationFunction`", "Errors`", "Helpers`", "CactusBoundary`",
"KrancTensor`", "Param`", "Schedule`", "Interface`", "Kranc`", "Jacobian`",
- "ConservationCalculation`", "CaKernel`"}];
+ "ConservationCalculation`", "CaKernel`", "Calculation`"}];
CreateKrancThorn::usage = "Construct a Kranc thorn";
@@ -95,7 +95,8 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
evolvedODEGroupDefinitions, rhsODEGroupDefinitions, rhsODEGroups,
allParams, boundarySources, reflectionSymmetries,
realParamDefs, intParamDefs,
- pDefs, consCalcs, consCalcsIn, consGroups, cakernel},
+ pDefs, consCalcs, consCalcsIn, consGroups, cakernel,
+ hostCals, deviceCalcs, incFilenames},
(* Parse named arguments *)
@@ -210,6 +211,8 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
PartialDerivatives -> partialDerivs,
Implementation -> implementation}] &, calcs];
+ calcs = Map[If[!OptionValue[UseCaKernel], #, If[mapContains[#,ExecuteOn], #, Append[#,ExecuteOn->Device]]] &, calcs];
+
(* Construct the configuration file *)
InfoMessage[Terse, "Creating configuration file"];
configuration = CreateConfiguration[opts];
@@ -282,18 +285,23 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
InfoMessage[Terse, "Creating calculation source files"];
- If[!OptionValue[UseCaKernel],
- calcSources = Map[CreateSetterSource[{#}, False, {}, opts] &, calcs];
- calcFilenames = Map[lookup[#, Name] <> ext &, calcs],
- (* else *)
- calcSources = Map[CaKernelCode[#,opts] &, calcs];
- calcFilenames = Map["CaKernel__"<>lookup[#, Name] <> ".code" &, calcs]];
+ hostCalcs = Select[calcs, !CalculationOnDevice[#] &];
+ deviceCalcs = Select[calcs, CalculationOnDevice];
+
+ calcSources = Join[Map[CreateSetterSource[{#}, False, {}, opts] &, hostCalcs],
+ Map[CaKernelCode[#,opts] &, deviceCalcs]];
+
+ calcFilenames = Join[Map[lookup[#, Name] <> ext &, hostCalcs],
+ Map["CaKernel__"<>lookup[#, Name] <> ".code" &, deviceCalcs]];
+
+ incFilenames = Map[lookup[#, Name] <> ext &, hostCalcs];
(* Makefile *)
InfoMessage[Terse, "Creating make file"];
make = CreateMakefile[Join[{"Startup.cc", "RegisterSymmetries.cc"},
- If[!OptionValue[UseCaKernel], {"RegisterMoL.cc"}~Join~calcFilenames, {}],
- Map[lookup[#, Filename] &, boundarySources]]];
+ If[!OptionValue[UseCaKernel], {"RegisterMoL.cc"}, {}],
+ incFilenames,
+ Map[lookup[#, Filename] &, boundarySources]]];
(* Put all the above together and generate the Cactus thorn *)
thornspec = {Name -> thornName,
diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m
index 097a405..477b86e 100644
--- a/Tools/CodeGen/Schedule.m
+++ b/Tools/CodeGen/Schedule.m
@@ -18,7 +18,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
-BeginPackage["Schedule`", {"Thorn`", "KrancGroups`", "MapLookup`", "Errors`", "Helpers`", "Kranc`", "CaKernel`"}];
+BeginPackage["Schedule`", {"Thorn`", "KrancGroups`", "MapLookup`", "Errors`", "Helpers`", "Kranc`", "CaKernel`", "Calculation`"}];
CreateKrancScheduleFile;
@@ -109,7 +109,7 @@ scheduleCalc[calc_, groups_, thornName_, OptionsPattern[]] :=
(* TODO: Pass this as {keyword,value} pair instead of a string,
once Thorn.m understands this format *)
- tags = If[OptionValue[UseOpenCL], "Device=1", ""];
+ tags = If[OptionValue[UseOpenCL] || CalculationOnDevice[calc], "Device=1", ""];
prefixWithScope[group_] :=
If[StringMatchQ[ToString[group], __~~"::"~~__],
@@ -131,7 +131,7 @@ scheduleCalc[calc_, groups_, thornName_, OptionsPattern[]] :=
Return[Map[
Join[
{
- Name -> If[OptionValue[UseCaKernel], "CAKERNEL_Launch_",""]<>lookup[calc, Name],
+ Name -> If[OptionValue[UseCaKernel] && CalculationOnDevice[calc], "CAKERNEL_Launch_",""]<>lookup[calc, Name],
SchedulePoint -> # <> relStr,
SynchronizedGroups -> If[StringMatchQ[#, "*MoL_CalcRHS*", IgnoreCase -> True] || StringMatchQ[#, "*MoL_RHSBoundaries*", IgnoreCase -> True],
{},