Skip to content

Commit

Permalink
Change format of internal data structure for group storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Nov 21, 2012
1 parent 2d7502d commit 7a654b1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
13 changes: 6 additions & 7 deletions Tools/CodeGen/Schedule.m
Expand Up @@ -28,11 +28,10 @@
Scheduling
-------------------------------------------------------------------------- *)

storageStructure[groupName_, timelevels_, param_String] :=
storageStructure[groupName_, timelevels_] :=
{
Group -> groupName,
Timelevels -> timelevels,
TimelevelsParameter -> param
Timelevels -> timelevels
};

groupsSetInCalc[calc_, groups_] :=
Expand Down Expand Up @@ -274,15 +273,15 @@
{tl},
tl = NonevolvedTimelevels[groupFromName[#, groups]];
If[tl===1,
storageStructure[#, tl, "other_timelevels"],
storageStructure[#, evolutionTimelevels, "timelevels"]]] &,
storageStructure[#, {"other_timelevels", tl}],
storageStructure[#, {"timelevels", evolutionTimelevels}]]] &,
(* over *)
nonevolvedGroups],

Map[storageStructure[#, evolutionTimelevels, "timelevels"] &,
Map[storageStructure[#, {"timelevels", evolutionTimelevels}] &,
evolvedGroups],

Map[storageStructure[#, evolutionTimelevels, "rhs_timelevels"] &,
Map[storageStructure[#, {"rhs_timelevels", evolutionTimelevels}] &,
rhsGroups]];

(* Schedule groups defined in calculations *)
Expand Down
26 changes: 20 additions & 6 deletions Tools/CodeGen/Thorn.m
Expand Up @@ -364,12 +364,26 @@
structure for inclusion in the schedule.ccl file to allocate
storage for this group. *)
groupStorage[spec_] :=
If[mapContains[spec, TimelevelsParameter],
Flatten[Table[{"if (", lookup[spec, TimelevelsParameter], " == ", i, ")\n",
"{\n",
" STORAGE: ", lookup[spec, Group], "[", i, "]\n",
"}\n"}, {i, 1, lookup[spec, Timelevels]}], 1],
{"STORAGE: ", lookup[spec, Group], "[", lookup[spec, Timelevels], "]\n"}]
Module[
{tls = lookup[spec,Timelevels],
group = lookup[spec, Group]},
Which[
IntegerQ[tls],
{"STORAGE: ", group, "[", tls, "]\n"},

ListQ[tls],
If[!MatchQ[tls, {_String, _Integer}],
Error["Unrecognized Timelevels value "<>ToString[tls]]];
Module[
{param,max},
{param,max} = tls;
Flatten[
Table[{"if (", param, " == ", i, ")\n",
"{\n",
" STORAGE: ", group, "[", i, "]\n",
"}\n"}, {i, 1, max}], 1]],

True, Error["Unrecognized Timelevels value "<>ToString[tls]]]];


(* Given a function scheduling specification as defined above, return
Expand Down

0 comments on commit 7a654b1

Please sign in to comment.