From 881c3f6e40aa50050a40cbf097f446faed56289d Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Fri, 26 Aug 2022 16:52:28 +0100 Subject: [PATCH] Minor optimization of PartContraction Remove rarely used debug code from initialization loop. --- src/V3Partition.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index b6ab138b0..b31a3967a 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -1270,6 +1270,18 @@ public: // METHODS void go() { + if (m_slowAsserts) { + // Check there are no redundant edges + for (V3GraphVertex* itp = m_mtasksp->verticesBeginp(); itp; + itp = itp->verticesNextp()) { + std::unordered_set neighbors; + for (V3GraphEdge* edgep = itp->outBeginp(); edgep; edgep = edgep->outNextp()) { + const bool first = neighbors.insert(edgep->top()).second; + UASSERT_OBJ(first, itp, "Redundant edge found in input to PartContraction()"); + } + } + } + unsigned maxMTasks = v3Global.opt.threadsMaxMTasks(); if (maxMTasks == 0) { // Unspecified so estimate if (v3Global.opt.threads() > 1) { @@ -1290,15 +1302,9 @@ public: // - Incrementally recompute critical paths near the merged mtask. for (V3GraphVertex* itp = m_mtasksp->verticesBeginp(); itp; itp = itp->verticesNextp()) { - itp->userp(nullptr); // Reset user value. Used by PartPropagateCp. - std::unordered_set neighbors; + itp->userp(nullptr); // Reset user value while we are here. Used by PartPropagateCp. for (V3GraphEdge* edgep = itp->outBeginp(); edgep; edgep = edgep->outNextp()) { m_sb.add(static_cast(edgep)); - if (m_slowAsserts) { - UASSERT_OBJ(neighbors.find(edgep->top()) == neighbors.end(), itp, - "Redundant edge found in input to PartContraction()"); - } - neighbors.insert(edgep->top()); } siblingPairFromRelatives(itp); siblingPairFromRelatives(itp);