-
Notifications
You must be signed in to change notification settings - Fork 239
[rocroller] Build Basic-Block Dependence DAGs #4785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
d5c6b3f
7782f17
5c3924f
38fe5be
4d30184
e21943f
0dd47e2
b6df996
36aeca0
f2b4cf1
9b0c590
13800bd
36a999e
6b9dbd0
d741c3a
d40e06f
4f55c99
910bb44
22a735e
91d79fa
383333d
78c9a9e
966c558
f872cdc
d3f184d
f38c6f0
6e6902d
e789bb6
76bebb8
76cea6b
ca52c33
35cdd49
7e9a01b
c1eaf26
c80ba10
76f2905
2542551
cbdb67a
955a4dd
a01111e
ee71f36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,4 +75,127 @@ namespace rocRoller::KernelGraph::NodeScheduling | |
| return subGraph; | ||
| } | ||
|
|
||
| ControlGraph::ControlGraph constructDataDependenceDAG(KernelGraph const& graph) | ||
| { | ||
| ControlGraph::ControlGraph dependenceDAG; | ||
|
|
||
| // Insert all control graph nodes into the data dependence DAG | ||
| for(auto node : graph.control.getNodes()) | ||
| { | ||
| dependenceDAG.setElement(node, graph.control.getElement(node)); | ||
| } | ||
|
|
||
| // Create tracer and get all the trace records from it. | ||
| auto tracer = ControlFlowRWTracer(graph); | ||
| auto records = tracer.coordinatesReadWrite(); | ||
|
|
||
| std::map<int, int> latestWriteToCoord; | ||
| std::map<int, std::unordered_set<int>> latestReadsToCoord; | ||
|
|
||
| // This assumes that the trace is ordered and records for the | ||
| // same control operation are consecutive. | ||
|
||
| auto it = records.begin(); | ||
| while(it != records.end()) | ||
| { | ||
| int currentControl = it->control; | ||
| while(it != records.end() && it->control == currentControl) | ||
| { | ||
| auto coord = it->coordinate; | ||
|
|
||
| // adds WW(output dep) and WR(flow dep) edges | ||
| if(latestWriteToCoord.contains(coord)) | ||
| { | ||
| AssertFatal(latestWriteToCoord[coord] != currentControl, | ||
| ShowValue(it->control), | ||
| ShowValue(it->coordinate), | ||
| ShowValue(it->rw)); | ||
|
|
||
| auto sourceNodeBodyParent | ||
| = bodyParents(getTopSetCoordinate(graph, latestWriteToCoord[coord]), graph) | ||
| .take(1) | ||
| .only(); | ||
| AssertFatal(sourceNodeBodyParent.has_value(), | ||
| "Source node has no body parent", | ||
| ShowValue(latestWriteToCoord[coord])); | ||
|
|
||
| auto destNodeBodyParent | ||
| = bodyParents(getTopSetCoordinate(graph, currentControl), graph) | ||
| .take(1) | ||
| .only(); | ||
| AssertFatal(destNodeBodyParent.has_value(), | ||
| "Dest node has no body parent", | ||
| ShowValue(currentControl)); | ||
pjots marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if(sourceNodeBodyParent.value() == destNodeBodyParent.value()) | ||
| { | ||
| auto order = graph.control.compareNodes( | ||
| UseCacheIfAvailable, latestWriteToCoord[coord], currentControl); | ||
| AssertFatal(order == ControlGraph::NodeOrdering::LeftFirst | ||
| || order == ControlGraph::NodeOrdering::RightInBodyOfLeft, | ||
pjots marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ShowValue(latestWriteToCoord[coord]), | ||
| ShowValue(currentControl), | ||
| ShowValue(order)); | ||
|
|
||
| dependenceDAG.addElement(ControlGraph::Sequence(), | ||
| {latestWriteToCoord[coord]}, | ||
| {currentControl}); | ||
pjots marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| if(it->rw == ControlFlowRWTracer::WRITE || it->rw == ControlFlowRWTracer::READWRITE) | ||
| { | ||
| // adds RW(anti dep) edges | ||
| for(auto const read : latestReadsToCoord[coord]) | ||
| { | ||
| if(read == currentControl) | ||
| continue; | ||
|
|
||
| auto sourceNodeBodyParent | ||
| = bodyParents(getTopSetCoordinate(graph, read), graph).take(1).only(); | ||
| AssertFatal(sourceNodeBodyParent.has_value(), | ||
| "Source node has no body parent", | ||
| ShowValue(read)); | ||
|
|
||
| auto destNodeBodyParent | ||
| = bodyParents(getTopSetCoordinate(graph, currentControl), graph) | ||
| .take(1) | ||
| .only(); | ||
| AssertFatal(destNodeBodyParent.has_value(), | ||
| "Dest node has no body parent", | ||
| ShowValue(currentControl)); | ||
|
|
||
| if(sourceNodeBodyParent.value() == destNodeBodyParent.value()) | ||
| { | ||
| auto order = graph.control.compareNodes( | ||
| UseCacheIfAvailable, read, currentControl); | ||
| AssertFatal(order == ControlGraph::NodeOrdering::LeftFirst | ||
| || order | ||
| == ControlGraph::NodeOrdering::RightInBodyOfLeft, | ||
| ShowValue(read), | ||
| ShowValue(currentControl), | ||
| ShowValue(order)); | ||
|
|
||
| dependenceDAG.addElement( | ||
| ControlGraph::Sequence(), {read}, {currentControl}); | ||
pjots marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| // Since the current control node writes into this coord, | ||
| // the latest reads info needs to be reset. | ||
| latestReadsToCoord[coord].clear(); | ||
|
|
||
| // update the latest write to coord | ||
| latestWriteToCoord[coord] = currentControl; | ||
| } | ||
|
|
||
| if(it->rw == ControlFlowRWTracer::READ || it->rw == ControlFlowRWTracer::READWRITE) | ||
| { | ||
| latestReadsToCoord[coord].insert(currentControl); | ||
| } | ||
|
|
||
| it++; | ||
| } | ||
| } | ||
| return dependenceDAG; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.