Skip to content

Commit

Permalink
Fix the logic for multiple writers of gfs, as well as functions that …
Browse files Browse the repository at this point in the history
…read and write a gf.
  • Loading branch information
stevenrbrandt committed Mar 11, 2015
1 parent e52b66a commit 7f5314e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Tools/CodeGen/CodeGenSchedule.m
Expand Up @@ -234,28 +234,35 @@
g[_] := True;
Select[b,g]]

buildAfterRules[sf_] := Module[{pg,sp,co,gr,rq},
buildAfterRules[sf_] := Module[{pg,sp,co,gr},
co = mylookup[sf,Comment];
sp = mylookup[sf,SchedulePoint];
rq = Flatten[mylookup[sf,RequiredGroups]];
pg = Flatten[mylookup[sf,ProvidedGroups]];
is = Intersection[rq,pg];
If[Length[is] > 0,
Print["Warning: grid function(s) "<>StringJoin[Riffle[is,", "]]<>" are both read and written by "<>co[[1]]];
pg=removeFrom[pg,rq];
];
If[Length[pg] == 0,Return[Null]];
Rule[sp[[1]],Table[Rule[gr,Dep[co[[1]]]],{gr,pg}]]
];

applyAfterRules[sf_,rules_] := Module[{co,myrules,rq,pg,ap,aps,sfn},
multiWriterWarning[a_,b_List] :=
If[Length[b]>1,
Print["Warning: multiple writers for "<>a<>". Writers include "<>StringJoin[Riffle[Map[First,b],", "]]]];

applyAfterRules[sf_,rules_] := Module[{co,myrules,rq,pg,ap,aps,sfn,is},
co = mylookup[sf,Comment];
sp = mylookup[sf,SchedulePoint];
myrules = sp[[1]] /. rules;
If[MatchQ[myrules,_String],Return[sf]];
rq = Flatten[mylookup[sf,RequiredGroups]];
pg = Flatten[mylookup[sf,ProvidedGroups]];
ap = Map[(# /. Dep[dep_] :> dep)&,Select[rq /. myrules,MatchQ[#,Dep[_]]&]];
is = Intersection[rq,pg];
If[Length[is] > 0,
Print["Warning: grid function(s) "<>StringJoin[Riffle[is,", "]]<>" are both read and written by "<>co[[1]]];
rq=removeFrom[rq,pg];
];
mr = mergeRules[myrules];
(* mr /. Rule[a_,b_] :> multiWriterWarning[a,b]; *)
(* ap = Map[(# /. Dep[dep_] :> dep)&,Select[rq /. myrules,MatchQ[#,Dep[_]]&]]; *)
ap = DeleteDuplicates[Map[(# /. Dep[dep_] :> dep)&,Select[Flatten[rq /. mergeRules[myrules]],MatchQ[#,Dep[_]]&]]];
If[Length[ap]===0,Return[sf]];
aps = StringJoin[" after ",Riffle[ap,", "]];
sfn=sf /. (SchedulePoint->schedpt_) :> (SchedulePoint->StringJoin[schedpt,aps]);
Expand Down

0 comments on commit 7f5314e

Please sign in to comment.