Permalink
Browse files

Calculation.m: Wrap split calculations in a schedule group

  • Loading branch information...
1 parent 7c1a250 commit 895d3802037ee151ca839b92f7567e0acb11dea2 @ianhinder committed Apr 23, 2012
Showing with 21 additions and 2 deletions.
  1. +21 −2 Tools/CodeGen/Calculation.m
@@ -152,7 +152,17 @@
SplitCalculation[calc_] :=
Module[
{splitBy = lookup[calc,SplitBy, {}],
- oldName = lookup[calc,Name]},
+ oldName = lookup[calc,Name],
+ oldSchedule = lookup[calc, Schedule, Automatic],
+ newGroup},
+
+ If[ListQ[oldSchedule] && Length[oldSchedule] > 1,
+ ThrowError["Cannot split a calculation which is scheduled in more than one place"]];
+
+ newGroup = {Name -> oldName,
+ Language -> "None", (* groups do not have a language *)
+ SchedulePoint -> oldSchedule,
+ Comment -> ""};
If[Intersection[Flatten[splitBy,1],OutputGridFunctions[calc]] === {},
{calc},
@@ -165,7 +175,16 @@
ToString[i[[1]]],
"_"<>StringReplace[ToString[var],{"["->"","]"->"",","->""}]];
splitVars = If[ListQ[var], var, {var}];
- partialCalculation[calc, nameSuffix, {}, splitVars]]],
+
+ newCalc = partialCalculation[calc, nameSuffix, {}, splitVars];
+
+ newCalc =
+ mapReplaceAdd[
+ mapReplaceAdd[
+ newCalc,
+ Schedule, {"in "<>oldName}],
+ ScheduleGroups, Append[lookup[calc, ScheduleGroups, {}],newGroup]]]],
+
splitBy]]]];
DefFn[

0 comments on commit 895d380

Please sign in to comment.