Skip to content

Commit

Permalink
Push more node index computation up
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
  • Loading branch information
kbieganski committed Oct 9, 2024
1 parent 28f1628 commit cc32fa1
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 214 deletions.
155 changes: 75 additions & 80 deletions src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:;
}
Expand All @@ -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:;
}
Expand Down Expand Up @@ -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:;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:;
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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:;
}
Expand All @@ -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:;
}
Expand Down Expand Up @@ -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:;
}
Expand Down Expand Up @@ -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:;
}
Expand Down
Loading

0 comments on commit cc32fa1

Please sign in to comment.