Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .github/workflows/buildifier.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_python//python:defs.bzl", "py_library")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("//bazel:notification.bzl", "notification_rule")
load("//bazel:python_wrap_cc.bzl", "PYTHON_EXTENSION_LINKOPTS", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
Expand Down Expand Up @@ -430,3 +431,40 @@ pkg_tar(
include_runfiles = True,
package_file_name = "openroad.tar",
)

sh_test(
name = "fmt_bzl_test",
size = "small",
srcs = ["//bazel:bzl_fmt_test.sh"],
args = ["$(rootpath @buildifier_prebuilt//:buildifier)"],
data = [
"BUILD.bazel",
"MODULE.bazel",
"@buildifier_prebuilt//:buildifier",
] + glob(
["**/*.bzl"],
allow_empty = True,
),
)

sh_test(
name = "lint_bzl_test",
size = "small",
srcs = ["//bazel:bzl_lint_test.sh"],
args = ["$(rootpath @buildifier_prebuilt//:buildifier)"],
data = [
"BUILD.bazel",
"MODULE.bazel",
"@buildifier_prebuilt//:buildifier",
] + glob(
["**/*.bzl"],
allow_empty = True,
),
)

sh_binary(
name = "tidy_bzl",
srcs = ["//bazel:bzl_tidy.sh"],
args = ["$(rootpath @buildifier_prebuilt//:buildifier)"],
data = ["@buildifier_prebuilt//:buildifier"],
)
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,5 @@ single_version_override(
patches = ["//bazel:boost_context_disable_parse_headers.patch"],
version = BOOST_VERSION,
)

bazel_dep(name = "buildifier_prebuilt", version = "8.2.1", dev_dependency = True)
2 changes: 2 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports_files([
"bzl_fmt_test.sh",
"bzl_lint_test.sh",
"bzl_tidy.sh",
])
10 changes: 10 additions & 0 deletions bazel/bzl_fmt_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e
# Capture absolute path BEFORE changing directories
BUILDIFIER_BIN=$(realpath "$1")

if [ -n "$BUILD_WORKSPACE_DIRECTORY" ]; then
cd "$BUILD_WORKSPACE_DIRECTORY"
fi

"$BUILDIFIER_BIN" -r -mode=check -lint=off .
9 changes: 9 additions & 0 deletions bazel/bzl_lint_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e
BUILDIFIER_BIN=$(realpath "$1")

if [ -n "$BUILD_WORKSPACE_DIRECTORY" ]; then
cd "$BUILD_WORKSPACE_DIRECTORY"
fi

"$BUILDIFIER_BIN" -r -mode=check -lint=warn .
12 changes: 12 additions & 0 deletions bazel/bzl_tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e
BUILDIFIER_BIN=$(realpath "$1")

if [ -z "$BUILD_WORKSPACE_DIRECTORY" ]; then
echo "Error: This script must be run via 'bazelisk run'"
exit 1
fi

cd "$BUILD_WORKSPACE_DIRECTORY"
"$BUILDIFIER_BIN" -r -mode=fix -lint=fix .
echo "Buildifier tidy complete!"
1 change: 1 addition & 0 deletions bazel/fix_lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazelisk run //:tidy_bzl
5 changes: 3 additions & 2 deletions src/grt/src/cugr/include/CUGR.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct Constants

double pin_patch_threshold = 20.0;
int pin_patch_padding = 1;
double wire_patch_threshold = 2.0;
double weight_wire_patch = 2.0;
double wire_patch_inflation_rate = 1.2;

bool write_heatmap = false;
Expand Down Expand Up @@ -94,6 +94,7 @@ class CUGR
}
void addDirtyNet(odb::dbNet* net);
void updateNet(odb::dbNet* net);
void removeRouteUsage(odb::dbNet* net); // <--- ADDED THIS DECLARATION
void startIncremental();
void endIncremental();

Expand Down Expand Up @@ -136,4 +137,4 @@ class CUGR
bool incremental_mode_ = false;
};

} // namespace grt
} // namespace grt
35 changes: 33 additions & 2 deletions src/grt/src/cugr/src/CUGR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,22 @@ void CUGR::updateNet(odb::dbNet* db_net)
updated_nets_.insert(db_net);
}

void CUGR::removeRouteUsage(odb::dbNet* db_net)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: out-of-line definition of 'removeRouteUsage' does not match any declaration in 'grt::CUGR' [clang-diagnostic-error]

void CUGR::removeRouteUsage(odb::dbNet* db_net)
           ^

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's this function used? I believe the first lines of the rerouteNets function already covers this process.

{
auto it = db_net_map_.find(db_net);
if (it != db_net_map_.end()) {
GRNet* gr_net = it->second;
if (gr_net->getRoutingTree()) {
grid_graph_->removeTreeUsage(gr_net->getRoutingTree());
}
} else {
logger_->warn(GRT,
601,
"Net {} not found in CUGR for rip-up.",
db_net->getConstName());
}
}

void CUGR::startIncremental()
{
incremental_mode_ = true;
Expand All @@ -664,11 +680,26 @@ void CUGR::startIncremental()

void CUGR::rerouteNets(std::vector<int>& net_indices)
{
// Combined loop for rip-up and slack querying for performance optimization
for (const int idx : net_indices) {
if (gr_nets_[idx]->getRoutingTree()) {
grid_graph_->removeTreeUsage(gr_nets_[idx]->getRoutingTree());
GRNet* gr_net = gr_nets_[idx].get();
if (gr_net->getRoutingTree()) {
grid_graph_->removeTreeUsage(gr_net->getRoutingTree());
}

if (sta_ != nullptr) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this sta_ check (here and below).

odb::dbNet* db_net = gr_net->getDbNet();
float slack = getNetSlack(db_net);
gr_net->setSlack(slack);
}
}

// 3. Sort: Most negative slack (critical) nets go FIRST
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems a bit out of place - where are steps 1. and 2.? Please remove it (and the comment below), the functions are self documented.

if (sta_ != nullptr) {
sortNetIndices(net_indices);
}
Comment on lines 684 to +700
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better performance, the loop for ripping up nets and the loop for querying slacks can be merged into a single loop. This avoids iterating over net_indices twice, which can be a significant saving if the number of nets to reroute is large. This aligns with the principle of optimizing loop structures to reduce redundant iterations, similar to how a single-pass approach can be more efficient than a two-pass approach.

  for (const int idx : net_indices) {
    GRNet* gr_net = gr_nets_[idx];
    if (gr_net->getRoutingTree()) {
      grid_graph_->removeTreeUsage(gr_net->getRoutingTree());
    }

    if (sta_ != nullptr) {
      odb::dbNet* db_net = gr_net->getDbNet();
      float slack = getNetSlack(db_net);
      gr_net->setSlack(slack);
    }
  }

  // 3. Sort if timing is available
  if (sta_ != nullptr) {
    // Sort: Most negative slack (critical) nets go FIRST
    sortNetIndices(net_indices);
  }
References
  1. When analyzing code within a loop, consider the entire loop structure. Operations at the beginning of the loop can affect the logic within the loop body, potentially making similar calls inside the loop redundant. Also, a single-pass method can be more efficient than a two-pass approach by avoiding processing all items multiple times.


// 4. Run the routing stages in prioritized order
patternRoute(net_indices);
patternRouteWithDetours(net_indices);
mazeRoute(net_indices);
Expand Down