mirror of
https://github.com/verilator/verilator.git
synced 2026-08-30 01:38:21 +02:00
Improve MTask coarsening in multi-threaded scheduling (#8120)
This is a large refactor of the MTask graph and coarsening algorithm, in prep for fixing the bug described in #7913, it can also improve the resulting multi-threaded schedule. Two major changes: OrderMTaskGraph now maintains the critical paths of the MTasks through mutation. There are 2 ways to mutate the graph, which are done via methods on the graph itself: adding an edge (used during construction, and will be used later during fixing data hazards), or merging an MTask into another (used during contraction). All critical path measures are automatically updated and propagated on any mutation, so no external algorithm needs to maintain them explicitly. The merge candidate scoreboard used during contraction is simplified to remove deferral of updated scores. This simplifies the code and results in a greedily more optimal schedule. (The previous tranched rescore was an optimization to work around the previous std::set based scoreboard, however since the algorithm now uses an efficient PairingHeap, verilation time is not impacted by the more accurate scoring, while yielding better results). Combining these two into a single patch as the code is highly interdependent and any one change without the other would be just a noisy transit point with unclear performance implications. Together it should be a clear improvement. Also added a stronger validation step run with '--debug-partition', which checks all invariants throughout the algorithms.
This commit is contained in:
@@ -79,31 +79,6 @@ void V3GraphVertex::rerouteEdges(V3Graph* graphp) {
|
||||
unlinkEdges(graphp);
|
||||
}
|
||||
|
||||
template <GraphWay::en N_Way>
|
||||
V3GraphEdge* V3GraphVertex::findConnectingEdgep(V3GraphVertex* waywardp) {
|
||||
// O(edges) linear search. Searches search both nodes' edge lists in
|
||||
// parallel. The lists probably aren't _both_ huge, so this is
|
||||
// unlikely to blow up even on fairly nasty graphs.
|
||||
constexpr GraphWay way{N_Way};
|
||||
constexpr GraphWay inv = way.invert();
|
||||
auto& aEdges = this->edges<way>();
|
||||
auto aIt = aEdges.begin();
|
||||
auto aEnd = aEdges.end();
|
||||
auto& bEdges = waywardp->edges<inv>();
|
||||
auto bIt = bEdges.begin();
|
||||
auto bEnd = bEdges.end();
|
||||
while (aIt != aEnd && bIt != bEnd) {
|
||||
V3GraphEdge& aedge = *aIt++;
|
||||
if (aedge.furtherp<way>() == waywardp) return &aedge;
|
||||
V3GraphEdge& bedge = *bIt++;
|
||||
if (bedge.furtherp<inv>() == this) return &bedge;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template V3GraphEdge* V3GraphVertex::findConnectingEdgep<GraphWay::FORWARD>(V3GraphVertex*);
|
||||
template V3GraphEdge* V3GraphVertex::findConnectingEdgep<GraphWay::REVERSE>(V3GraphVertex*);
|
||||
|
||||
// cppcheck-has-bug-suppress constParameter
|
||||
void V3GraphVertex::v3errorEnd(const std::ostringstream& str) const // LCOV_EXCL_START
|
||||
VL_RELEASE(V3Error::s().m_mutex) {
|
||||
|
||||
Reference in New Issue
Block a user