aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tools/CodeGen/KrancThorn.m4
-rw-r--r--Tools/CodeGen/Schedule.m29
-rw-r--r--Tools/CodeGen/TensorTools.m5
-rw-r--r--Tools/CodeGen/Thorn.m3
4 files changed, 23 insertions, 18 deletions
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index 16287d7..e086090 100644
--- a/Tools/CodeGen/KrancThorn.m
+++ b/Tools/CodeGen/KrancThorn.m
@@ -130,7 +130,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
CheckGroups[groupsOrig];
- groups = Join[groupsOrig, {coordGroup}];
+ groups = Union[Join[groupsOrig, {coordGroup}]];
includeFiles = Join[includeFiles, {"GenericFD.h", "Symmetry.h", "sbp_calc_coeffs.h"}];
inheritedImplementations = Join[inheritedImplementations, {"Grid",
@@ -202,7 +202,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
InfoMessage[Terse, "Creating schedule file"];
schedule = CreateKrancScheduleFile[calcs, groups, Join[evolvedGroups,evolvedODEGroups],
Join[rhsGroups,rhsODEGroups], Join[nonevolvedGroups,nonevolvedODEGroups], thornName,
- evolutionTimelevels];
+ evolutionTimelevels, opts];
boundarySources = CactusBoundary`GetSources[evolvedGroups, groups,
implementation, thornName];
diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m
index 4a57d7b..f83578f 100644
--- a/Tools/CodeGen/Schedule.m
+++ b/Tools/CodeGen/Schedule.m
@@ -54,15 +54,24 @@ groupsSetInCalc[calc_, groups_] :=
eqs = lookup[calc, Equations];
lhss = Map[First, eqs];
gfsInLHS = Union[Cases[lhss, _ ? (MemberQ[gfs,#] &), Infinity]];
-
lhsGroupNames = containingGroups[gfsInLHS, groups];
Return[lhsGroupNames]
];
+groupsReadInCalc[calc_, groups_] :=
+ Module[{gfs, eqs, lhss, gfsInLHS, lhsGroupNames},
+ gfs = allGroupVariables[groups];
+ eqs = lookup[calc, Equations];
+ rhss = Map[Last, eqs];
+ gfsInRHS = Union[Cases[rhss, _ ? (MemberQ[gfs,#] &), Infinity]];
+ rhsGroupNames = containingGroups[gfsInRHS, groups];
+ Return[rhsGroupNames]
+ ];
+
(* Each calculation can be scheduled at multiple points, so this
function returns a LIST of schedule structures for each calculation
*)
-scheduleCalc[calc_, groups_, thornName_] :=
+scheduleCalc[calc_, groups_, thornName_, useOpenCL_] :=
Module[{points, conditional, conditionals, keywordConditional,
keywordConditionals, triggered, keyword, value, keywordvaluepairs,
groupsToSync, tags,
@@ -97,19 +106,13 @@ scheduleCalc[calc_, groups_, thornName_] :=
(* TODO: Pass this as {keyword,value} pair instead of a string,
once Thorn.m understands this format *)
- (* TODO: This doesn't work -- I don't know how to access
- OptionValue[] in this file.
- tags = If[OptionValue[UseOpenCL], "OpenCL=1", ""];
- *)
- tags = "OpenCL=1";
+ tags = If[useOpenCL, "OpenCL=1", ""];
prefixWithScope[group_] :=
If[StringMatchQ[ToString[group], __~~"::"~~__],
ToString[group],
thornName <> "::" <> ToString[group]];
- (* TODO: Don't blindly require/provide all groups, check the
- equations instead *)
- groupsToRequire = prefixWithScope /@ Map[First, groups];
+ groupsToRequire = prefixWithScope /@ groupsReadInCalc[calc, groups];
groupsToProvide = prefixWithScope /@ groupsSetInCalc[calc, groups];
before = lookupDefault[calc, Before, None];
@@ -210,12 +213,14 @@ scheduleCalc[calc_, groups_, thornName_] :=
bcGroupSched["in "<>groupName <> " after " <> lookup[calc, Name]],
bcGroupSched["in MoL_PseudoEvolutionBoundaries after MoL_PostStep"]},{}]]]];
+Options[CreateKrancScheduleFile] = ThornOptions;
+
CreateKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedGroups_, thornName_,
- evolutionTimelevels_] :=
+ evolutionTimelevels_, opts:OptionsPattern[]] :=
Module[{scheduledCalcs, scheduledStartup, scheduleMoLRegister, globalStorageGroups, scheduledFunctions, schedule},
scheduledCalcs =
- Flatten[Map[scheduleCalc[#, groups, thornName] &, calcs], 1];
+ Flatten[Map[scheduleCalc[#, groups, thornName, OptionValue[UseOpenCL]] &, calcs], 1];
scheduledStartup =
{
Name -> thornName <> "_Startup",
diff --git a/Tools/CodeGen/TensorTools.m b/Tools/CodeGen/TensorTools.m
index 7b623f5..48a848a 100644
--- a/Tools/CodeGen/TensorTools.m
+++ b/Tools/CodeGen/TensorTools.m
@@ -140,6 +140,7 @@ TensorManualCartesianParities;
Checkpoint;
IsTensor;
toggleIndex;
+replaceConflicting;
(* This is for compatibility with MathTensor notation *)
(*OD = PD;*)
@@ -352,7 +353,7 @@ replaceDummyIndex[x_, li_, ri_] :=
TensorProduct represents a Times that has already been checked for
conflicting dummy indices. It can have any expressions in it. *)
-SetAttributes[TensorProduct, {Flat, OneIdentity}];
+SetAttributes[TensorProduct, {Flat, OneIdentity, Orderless}];
(* For some reason this causes infinite loops - might want to check this later *)
(*TensorProduct[t:(Tensor[_,__])] := t;*)
@@ -757,7 +758,7 @@ DefineConnection[cd_, pd_, gamma_] :=
(* Things we can do with covariant derivatives:
- (1) Liebnitz: CD[x_ y_,i_] -> CD[x,i] y + x CD[y,i]
+ (1) Leibnitz: CD[x_ y_,i_] -> CD[x,i] y + x CD[y,i]
(2) Linear: CD[x_ + y_,i_] -> CD[x,i] + CD[y,i]
(3) Linear: CD[i_Integer x_] -> i CD[x]
(4) High order derivatives: CD[x_, i_, is__] -> CD[CD[x,i],is]
diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m
index 8731c26..a82a23d 100644
--- a/Tools/CodeGen/Thorn.m
+++ b/Tools/CodeGen/Thorn.m
@@ -384,7 +384,6 @@ scheduleUnconditionalFunction[spec_] :=
(* Insert a SYNC line for each group we want to synchronize. *)
Map[{"SYNC: ", #, "\n"} &, lookupDefault[spec, SynchronizedGroups, {}]],
-
Map[{"TRIGGERS: ", #, "\n"} &, lookupDefault[spec, TriggerGroups, {}]],
(* TODO: Expect a set of keyword/value pairs instead of a string *)
@@ -399,7 +398,7 @@ scheduleUnconditionalFunction[spec_] :=
storage for *)
Map[groupStorage, lookupDefault[spec, StorageGroups, {}]]},
- Quote[lookup[spec, Comment]]]};
+ Quote[lookup[spec, Comment]]]};
(* Handle the aspect of scheduling the function conditionally *)
scheduleFunction[spec_] :=