diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2012-04-29 16:13:15 +0200 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2012-04-29 16:13:15 +0200 |
commit | 99e9b2fea093bd3bedd22a07e7da8b014a94d297 (patch) | |
tree | 30d9bb44293665544d5d80b13be16ba8b9f1e85e /Tools/CodeGen/Schedule.m | |
parent | 6990cd0531dedfb241d136988d4530cc2b1dbe9d (diff) |
Schedule.m: Add variablesSetInCalc and variablesReadInCalc
Diffstat (limited to 'Tools/CodeGen/Schedule.m')
-rw-r--r-- | Tools/CodeGen/Schedule.m | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Tools/CodeGen/Schedule.m b/Tools/CodeGen/Schedule.m index b9985bb..1e51ff9 100644 --- a/Tools/CodeGen/Schedule.m +++ b/Tools/CodeGen/Schedule.m @@ -71,6 +71,27 @@ groupsReadInCalc[calc_, groups_] := Return[rhsGroupNames] ]; +variablesSetInCalc[calc_, groups_] := + Module[{gfs, eqs, lhss, gfsInLHS}, + gfs = allGroupVariables[groups]; + eqs = lookup[calc, Equations]; + lhss = Map[First, eqs]; + gfsInLHS = Union[Cases[lhss, _ ? (MemberQ[gfs,#] &), Infinity]]; + Return[gfsInLHS] + ]; + +variablesReadInCalc[calc_, groups_] := + Module[{gfs, eqs, lhss, gfsInLHS}, + gfs = allGroupVariables[groups]; + eqs = lookup[calc, Equations]; + rhss = Map[Last, eqs]; + gfsInRHS = Union[Cases[rhss, _ ? (MemberQ[gfs,#] &), Infinity]]; + (* TODO: eliminate variables from this list that have been set in + this calculation before they were used *) + Return[gfsInRHS] + ]; + + (* Each calculation can be scheduled at multiple points, so this function returns a LIST of schedule structures for each calculation *) |