Skip to content

Commit

Permalink
* frame graph : order
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubpa committed Aug 1, 2020
1 parent 8896ce3 commit 2d9b851
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const {
auto& subgraph_write = graph.GenSubgraph("Write Edges");
auto& subgraph_latest = graph.GenSubgraph("Latest Edges");

auto& subgraph_order = graph.GenSubgraph("Order Edges");

auto& subgraph_all = graph.GenSubgraph("All Edges");
auto& subgraph_any = graph.GenSubgraph("Any Edges");
auto& subgraph_none = graph.GenSubgraph("None Edges");
Expand All @@ -98,6 +100,8 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const {
subgraph_write.RegisterGraphEdgeAttr("color", "#F47378");
subgraph_latest.RegisterGraphEdgeAttr("color", "#6BD089");

subgraph_order.RegisterGraphEdgeAttr("color", "#00A2E8");

subgraph_all
.RegisterGraphEdgeAttr("style", "dashed")
.RegisterGraphEdgeAttr("color", "#C785C8")
Expand All @@ -115,6 +119,7 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const {

unordered_set<CmptType> cmptTypes;
unordered_map<CmptType, size_t> cmptType2idx;
unordered_map<size_t, size_t> sysFuncHashcode2idx;

auto queryCmptName = [](CmptType type) -> string {
auto cmptName = RTDCmptTraits::Instance().Nameof(type);
Expand All @@ -138,9 +143,10 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const {
subgraph_cmpt.AddNode(cmptIdx);
}

// TODO: filter
for (const auto& [hash, sysFunc] : schedule.sysFuncs) {
auto sysIdx = registry.RegisterNode(sysFunc->Name());
sysFuncHashcode2idx.emplace(hash, sysIdx);

subgraph_sys.AddNode(sysIdx);

const auto& locator = sysFunc->query.locator;
Expand Down Expand Up @@ -230,6 +236,13 @@ UGraphviz::Graph World::GenUpdateFrameGraph() const {
}
}

for (const auto& [from, to] : schedule.sysFuncOrder) {
auto fromIdx = sysFuncHashcode2idx.find(from)->second;
auto toIdx = sysFuncHashcode2idx.find(to)->second;
auto edgeIdx = registry.RegisterEdge(fromIdx, toIdx);
subgraph_order.AddEdge(edgeIdx);
}

return graph;
}

Expand Down
6 changes: 6 additions & 0 deletions src/test/02_order/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class DataSystem : public System {
};

int main() {
RTDCmptTraits::Instance().Register<
Data1,
Data2
>();

World w;
w.systemMngr.Register<DataSystem>();

Expand All @@ -32,6 +37,7 @@ int main() {
w.Update();

cout << w.DumpUpdateJobGraph() << endl;
cout << w.GenUpdateFrameGraph().Dump() << endl;

return 0;
}

0 comments on commit 2d9b851

Please sign in to comment.