Skip to content

Commit

Permalink
generate READS statement for stress_energy_state if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaas80 committed May 27, 2020
1 parent cf3faac commit b046e29
Showing 1 changed file with 54 additions and 42 deletions.
96 changes: 54 additions & 42 deletions Tools/CodeGen/CodeGenSchedule.m
Expand Up @@ -79,48 +79,60 @@
(* Given a function scheduling specification as defined above, return
a CodeGen block to schedule the function for the schedule.ccl file *)
scheduleUnconditionalFunction[spec_] :=
{"schedule ", lookup[spec, Name], " ", lookup[spec,SchedulePoint], "\n",
SuffixedCBlock[
{If[lookup[spec, Language] != "None",
"LANG: " <> lookup[spec, Language] <> "\n",
""],

If[lookupDefault[spec, Options, ""] != "",
"OPTIONS: " <> lookup[spec, Options] <> "\n",
""],

(* 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 *)
If[lookupDefault[spec, Tags, ""] != "",
"TAGS: " <> lookup[spec, Tags] <> "\n",
""],

translateRegion[r_] := Switch[r,
Everywhere, "Everywhere",
Interior, "Interior",
InteriorNoSync, "Interior",
Boundary, "Boundary",
BoundaryNoSync, "Boundary",
BoundaryWithGhosts, "BoundaryWithGhosts",
_, "ERROR(" <> ToString[r] <> ")"];
Map[{"READS: ", #, "(",
translateRegion[lookupDefault[spec, RequiredRegion, "ERROR"]],
")\n"} &,
lookupDefault[spec, RequiredGroups, {}]],
Map[{"WRITES: ", #, "(",
translateRegion[lookupDefault[spec, ProvidedRegion, "ERROR"]],
")\n"} &,
lookupDefault[spec, ProvidedGroups, {}]],

(* Insert a storage block for each group we want to allocate
storage for *)
Map[groupStorage, lookupDefault[spec, StorageGroups, {}]]},

Quote[lookup[spec, Comment]]]};
Module[{translateRegion, ignoredGroups},
{"schedule ", lookup[spec, Name], " ", lookup[spec,SchedulePoint], "\n",
SuffixedCBlock[
{If[lookup[spec, Language] != "None",
"LANG: " <> lookup[spec, Language] <> "\n",
""],

If[lookupDefault[spec, Options, ""] != "",
"OPTIONS: " <> lookup[spec, Options] <> "\n",
""],

(* 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 *)
If[lookupDefault[spec, Tags, ""] != "",
"TAGS: " <> lookup[spec, Tags] <> "\n",
""],

translateRegion[r_] := Switch[r,
Everywhere, "Everywhere",
Interior, "Interior",
InteriorNoSync, "Interior",
Boundary, "Boundary",
BoundaryNoSync, "Boundary",
BoundaryWithGhosts, "BoundaryWithGhosts",
_, "ERROR(" <> ToString[r] <> ")"];

(* must match list in CodeGenCalculation.m *)
ignoreGroups = {"TmunuBase::eTtt", "TmunuBase::eTxx", "TmunuBase::eTxy",
"TmunuBase::eTxz", "TmunuBase::eTyy", "TmunuBase::eTyz",
"TmunuBase::eTzz", "TmunuBase::eTtx", "TmunuBase::eTty",
"TmunuBase::eTtz"};
If[ContainsAny[lookupDefault[spec, RequiredGroups, {}], ignoreGroups],
"READS: " <> "TmunuBase::stress_energy_state" <> "\n",
""],

Map[{"READS: ", #, "(",
translateRegion[lookupDefault[spec, RequiredRegion, "ERROR"]],
")\n"} &,
lookupDefault[spec, RequiredGroups, {}]],
Map[{"WRITES: ", #, "(",
translateRegion[lookupDefault[spec, ProvidedRegion, "ERROR"]],
")\n"} &,
lookupDefault[spec, ProvidedGroups, {}]],

(* Insert a storage block for each group we want to allocate
storage for *)
Map[groupStorage, lookupDefault[spec, StorageGroups, {}]]},

Quote[lookup[spec, Comment]]]}
];

(* Handle the aspect of scheduling the function conditionally *)
scheduleFunction[spec_,params_] :=
Expand Down

0 comments on commit b046e29

Please sign in to comment.