From cc32fa1f6a8bbbc66c50c7d5bc2d4807cc4ce10e Mon Sep 17 00:00:00 2001 From: Krzysztof Bieganski Date: Wed, 9 Oct 2024 13:17:56 +0200 Subject: [PATCH] Push more node index computation up Signed-off-by: Krzysztof Bieganski --- src/drt/src/dr/FlexDR_maze.cpp | 155 ++++++++++++++++---------------- src/drt/src/dr/FlexGridGraph.h | 158 +++++---------------------------- 2 files changed, 99 insertions(+), 214 deletions(-) diff --git a/src/drt/src/dr/FlexDR_maze.cpp b/src/drt/src/dr/FlexDR_maze.cpp index 7ffffe145f7..30d521324c2 100644 --- a/src/drt/src/dr/FlexDR_maze.cpp +++ b/src/drt/src/dr/FlexDR_maze.cpp @@ -79,44 +79,38 @@ void FlexDRWorker::modViaForbiddenThrough(const FlexMazeIdx& bi, if (isHorz) { for (int xIdx = bi.x(); xIdx < ei.x(); xIdx++) { if (isLowerViaForbidden) { + frMIdx idx = gridGraph_.getIdx(xIdx, bi.y(), bi.z() - 1); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia( - xIdx, bi.y(), bi.z() - 1); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia( - xIdx, bi.y(), bi.z() - 1); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia( - xIdx, bi.y(), bi.z() - 1); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia( - xIdx, bi.y(), bi.z() - 1); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } } if (isUpperViaForbidden) { + frMIdx idx = gridGraph_.getIdx(xIdx, bi.y(), bi.z()); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia( - xIdx, bi.y(), bi.z()); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia( - xIdx, bi.y(), bi.z()); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia( - xIdx, bi.y(), bi.z()); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia( - xIdx, bi.y(), bi.z()); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } @@ -125,44 +119,38 @@ void FlexDRWorker::modViaForbiddenThrough(const FlexMazeIdx& bi, } else { for (int yIdx = bi.y(); yIdx < ei.y(); yIdx++) { if (isLowerViaForbidden) { + frMIdx idx = gridGraph_.getIdx(bi.x(), yIdx, bi.z() - 1); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia( - bi.x(), yIdx, bi.z() - 1); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia( - bi.x(), yIdx, bi.z() - 1); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia( - bi.x(), yIdx, bi.z() - 1); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia( - bi.x(), yIdx, bi.z() - 1); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } } if (isUpperViaForbidden) { + frMIdx idx = gridGraph_.getIdx(bi.x(), yIdx, bi.z()); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia( - bi.x(), yIdx, bi.z()); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia( - bi.x(), yIdx, bi.z()); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia( - bi.x(), yIdx, bi.z()); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia( - bi.x(), yIdx, bi.z()); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } @@ -219,18 +207,19 @@ void FlexDRWorker::modCornerToCornerSpacing_helper(const Rect& box, gridGraph_.getIdxBox(p1, p2, box, FlexGridGraph::isEnclosed); for (int i = p1.x(); i <= p2.x(); i++) { for (int j = p1.y(); j <= p2.y(); j++) { + frMIdx idx = gridGraph_.getIdx(i, j, z); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostPlanar(i, j, z); + gridGraph_.subRouteShapeCostPlanar(idx); break; case addRouteShape: - gridGraph_.addRouteShapeCostPlanar(i, j, z); + gridGraph_.addRouteShapeCostPlanar(idx); break; case subFixedShape: - gridGraph_.subFixedShapeCostPlanar(i, j, z); + gridGraph_.subFixedShapeCostPlanar(idx); break; case addFixedShape: - gridGraph_.addFixedShapeCostPlanar(i, j, z); + gridGraph_.addFixedShapeCostPlanar(idx); break; default:; } @@ -373,33 +362,37 @@ void FlexDRWorker::modMinSpacingCostPlanarHelper(const Rect& box, if (distSquare < bloatDistSquare) { switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostPlanar(i, j, z, ndr); // safe access + gridGraph_.subRouteShapeCostPlanar(gridGraph_.getIdx(i, j, z), + ndr); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostPlanar(i, j, z, ndr); // safe access + gridGraph_.addRouteShapeCostPlanar(gridGraph_.getIdx(i, j, z), + ndr); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostPlanar(i, j, z, ndr); // safe access + gridGraph_.subFixedShapeCostPlanar(gridGraph_.getIdx(i, j, z), + ndr); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostPlanar(i, j, z, ndr); // safe access + gridGraph_.addFixedShapeCostPlanar(gridGraph_.getIdx(i, j, z), + ndr); // safe access break; case resetFixedShape: if (resetHorz) { gridGraph_.setFixedShapeCostPlanarHorz( - i, j, z, 0, ndr); // safe access + gridGraph_.getIdx(i, j, z), 0, ndr); // safe access } if (resetVert) { gridGraph_.setFixedShapeCostPlanarVert( - i, j, z, 0, ndr); // safe access + gridGraph_.getIdx(i, j, z), 0, ndr); // safe access } break; - case setFixedShape: - gridGraph_.setFixedShapeCostPlanarHorz( - i, j, z, 1, ndr); // safe access - gridGraph_.setFixedShapeCostPlanarVert( - i, j, z, 1, ndr); // safe access + case setFixedShape: { + frMIdx idx = gridGraph_.getIdx(i, j, z); + gridGraph_.setFixedShapeCostPlanarHorz(idx, 1, ndr); // safe access + gridGraph_.setFixedShapeCostPlanarVert(idx, 1, ndr); // safe access break; + } case resetBlocked: if (ndr) { return; @@ -619,22 +612,22 @@ void FlexDRWorker::modMinimumcutCostVia(const Rect& box, } switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia(i, j, zIdx); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia(i, j, zIdx); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia(i, j, zIdx); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia(i, j, zIdx); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; case resetFixedShape: - gridGraph_.setFixedShapeCostVia(i, j, z, 0); // safe access + gridGraph_.setFixedShapeCostVia(gridGraph_.getIdx(i, j, z), 0); // safe access break; case setFixedShape: - gridGraph_.setFixedShapeCostVia(i, j, z, 1); // safe access + gridGraph_.setFixedShapeCostVia(gridGraph_.getIdx(i, j, z), 1); // safe access default:; } } @@ -916,37 +909,37 @@ void FlexDRWorker::modEolSpacingCost_helper(const Rect& testbox, for (int i = mIdx1.x(); i <= mIdx2.x(); i++) { for (int j = mIdx1.y(); j <= mIdx2.y(); j++) { if (eolType == 0) { + frMIdx idx = gridGraph_.getIdx(i, j, z); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostPlanar(i, j, z); // safe access + gridGraph_.subRouteShapeCostPlanar(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostPlanar(i, j, z); // safe access + gridGraph_.addRouteShapeCostPlanar(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostPlanar(i, j, z); // safe access + gridGraph_.subFixedShapeCostPlanar(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostPlanar(i, j, z); // safe access + gridGraph_.addFixedShapeCostPlanar(idx); // safe access break; case resetFixedShape: if (resetHorz) { - gridGraph_.setFixedShapeCostPlanarHorz( - i, j, z, 0); // safe access + gridGraph_.setFixedShapeCostPlanarHorz(idx, 0); // safe access } if (resetVert) { - gridGraph_.setFixedShapeCostPlanarVert( - i, j, z, 0); // safe access + gridGraph_.setFixedShapeCostPlanarVert(idx, 0); // safe access } break; case setFixedShape: - gridGraph_.setFixedShapeCostPlanarHorz(i, j, z, 1); // safe access - gridGraph_.setFixedShapeCostPlanarVert(i, j, z, 1); // safe access + gridGraph_.setFixedShapeCostPlanarHorz(idx, 1); // safe access + gridGraph_.setFixedShapeCostPlanarVert(idx, 1); // safe access break; default:; } } else if (eolType == 1) { - if (gridGraph_.isSVia(i, j, z - 1)) { + frMIdx idx = gridGraph_.getIdx(i, j, z - 1); + if (gridGraph_.isSVia(idx)) { gridGraph_.getPoint(pt, i, j); auto sViaDef = apSVia_[FlexMazeIdx(i, j, z - 1)]->getAccessViaDef(); sVia.setViaDef(sViaDef); @@ -958,16 +951,16 @@ void FlexDRWorker::modEolSpacingCost_helper(const Rect& testbox, } switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia(i, j, z - 1); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia(i, j, z - 1); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia(i, j, z - 1); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia(i, j, z - 1); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } @@ -984,16 +977,16 @@ void FlexDRWorker::modEolSpacingCost_helper(const Rect& testbox, } switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia(i, j, z); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia(i, j, z); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia(i, j, z); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia(i, j, z); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } @@ -1302,18 +1295,19 @@ void FlexDRWorker::modAdjCutSpacingCost_fixedObj(const frDesign* design, } if (hasViol) { + frMIdx idx = gridGraph_.getIdx(i, j, z); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia(i, j, z); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia(i, j, z); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia(i, j, z); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia(i, j, z); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } @@ -1458,18 +1452,19 @@ void FlexDRWorker::modInterLayerCutSpacingCost(const Rect& box, } if (hasViol) { + frMIdx idx = gridGraph_.getIdx(i, j, z2); switch (type) { case subRouteShape: - gridGraph_.subRouteShapeCostVia(i, j, z2); // safe access + gridGraph_.subRouteShapeCostVia(idx); // safe access break; case addRouteShape: - gridGraph_.addRouteShapeCostVia(i, j, z2); // safe access + gridGraph_.addRouteShapeCostVia(idx); // safe access break; case subFixedShape: - gridGraph_.subFixedShapeCostVia(i, j, z2); // safe access + gridGraph_.subFixedShapeCostVia(idx); // safe access break; case addFixedShape: - gridGraph_.addFixedShapeCostVia(i, j, z2); // safe access + gridGraph_.addFixedShapeCostVia(idx); // safe access break; default:; } diff --git a/src/drt/src/dr/FlexGridGraph.h b/src/drt/src/dr/FlexGridGraph.h index 8e3f45734ca..41ac756b16c 100644 --- a/src/drt/src/dr/FlexGridGraph.h +++ b/src/drt/src/dr/FlexGridGraph.h @@ -511,52 +511,6 @@ class FlexGridGraph } } } - void addRouteShapeCostPlanar(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.routeShapeCostPlanarNDR = addToByte(node.routeShapeCostPlanarNDR, 1); - } else { - node.routeShapeCostPlanar = addToByte(node.routeShapeCostPlanar, 1); - } - } - void addRouteShapeCostVia(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.routeShapeCostViaNDR = addToByte(node.routeShapeCostViaNDR, 1); - } else { - node.routeShapeCostVia = addToByte(node.routeShapeCostVia, 1); - } - } - void subRouteShapeCostPlanar(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.routeShapeCostPlanarNDR - = subFromByte(node.routeShapeCostPlanarNDR, 1); - } else { - node.routeShapeCostPlanar = subFromByte(node.routeShapeCostPlanar, 1); - } - } - void subRouteShapeCostVia(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.routeShapeCostViaNDR = subFromByte(node.routeShapeCostViaNDR, 1); - } else { - node.routeShapeCostVia = subFromByte(node.routeShapeCostVia, 1); - } - } - void resetRouteShapeCostVia(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - auto idx = getIdx(x, y, z); - if (ndr) { - nodes_[idx].routeShapeCostViaNDR = 0; - } else { - nodes_[idx].routeShapeCostVia = 0; - } - } void addRouteShapeCostPlanar(frMIdx idx, bool ndr = false) { auto& node = nodes_[idx]; @@ -697,105 +651,41 @@ class FlexGridGraph } return (currCost == 0); } - void addFixedShapeCostPlanar(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) + void addFixedShapeCostPlanar(frMIdx idx, bool ndr = false) { - if (isValid(x, y, z)) { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.fixedShapeCostPlanarHorzNDR - = addToByte(node.fixedShapeCostPlanarHorzNDR, 1); - node.fixedShapeCostPlanarVertNDR - = addToByte(node.fixedShapeCostPlanarVertNDR, 1); - } else { - node.fixedShapeCostPlanarHorz - = addToByte(node.fixedShapeCostPlanarHorz, 1); - node.fixedShapeCostPlanarVert - = addToByte(node.fixedShapeCostPlanarVert, 1); - } + auto& node = nodes_[idx]; + if (ndr) { + node.fixedShapeCostPlanarHorzNDR + = addToByte(node.fixedShapeCostPlanarHorzNDR, 1); + node.fixedShapeCostPlanarVertNDR + = addToByte(node.fixedShapeCostPlanarVertNDR, 1); + } else { + node.fixedShapeCostPlanarHorz + = addToByte(node.fixedShapeCostPlanarHorz, 1); + node.fixedShapeCostPlanarVert + = addToByte(node.fixedShapeCostPlanarVert, 1); } } - void setFixedShapeCostPlanarVert(frMIdx x, - frMIdx y, - frMIdx z, + void setFixedShapeCostPlanarVert(frMIdx idx, frUInt4 c, bool ndr = false) { - if (isValid(x, y, z)) { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.fixedShapeCostPlanarVertNDR = c; - } else { - node.fixedShapeCostPlanarVert = c; - } + auto& node = nodes_[idx]; + if (ndr) { + node.fixedShapeCostPlanarVertNDR = c; + } else { + node.fixedShapeCostPlanarVert = c; } } - void setFixedShapeCostPlanarHorz(frMIdx x, - frMIdx y, - frMIdx z, + void setFixedShapeCostPlanarHorz(frMIdx idx, frUInt4 c, bool ndr = false) { - if (isValid(x, y, z)) { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.fixedShapeCostPlanarHorzNDR = c; - } else { - node.fixedShapeCostPlanarHorz = c; - } - } - } - void addFixedShapeCostVia(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - if (isValid(x, y, z)) { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.fixedShapeCostViaNDR = addToByte(node.fixedShapeCostViaNDR, 1); - } else { - node.fixedShapeCostVia = addToByte(node.fixedShapeCostVia, 1); - } - } - } - void setFixedShapeCostVia(frMIdx x, - frMIdx y, - frMIdx z, - frUInt4 c, - bool ndr = false) - { - if (isValid(x, y, z)) { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.fixedShapeCostViaNDR = c; - } else { - node.fixedShapeCostVia = c; - } - } - } - void subFixedShapeCostPlanar(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - if (isValid(x, y, z)) { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.fixedShapeCostPlanarHorzNDR - = subFromByte(node.fixedShapeCostPlanarHorzNDR, 1); - node.fixedShapeCostPlanarVertNDR - = subFromByte(node.fixedShapeCostPlanarVertNDR, 1); - } else { - node.fixedShapeCostPlanarHorz - = subFromByte(node.fixedShapeCostPlanarHorz, 1); - node.fixedShapeCostPlanarVert - = subFromByte(node.fixedShapeCostPlanarVert, 1); - } - } - } - void subFixedShapeCostVia(frMIdx x, frMIdx y, frMIdx z, bool ndr = false) - { - if (isValid(x, y, z)) { - auto& node = nodes_[getIdx(x, y, z)]; - if (ndr) { - node.fixedShapeCostViaNDR = subFromByte(node.fixedShapeCostViaNDR, 1); - } else { - node.fixedShapeCostVia = subFromByte(node.fixedShapeCostVia, 1); - } + auto& node = nodes_[idx]; + if (ndr) { + node.fixedShapeCostPlanarHorzNDR = c; + } else { + node.fixedShapeCostPlanarHorz = c; } } void addFixedShapeCostVia(frMIdx idx, bool ndr = false)