Skip to content

Commit f4e5e40

Browse files
committed
Merge branch 'master' into or_update_sta_latest_0629
2 parents 1379ffc + 8b73031 commit f4e5e40

224 files changed

Lines changed: 11490 additions & 841 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ build:asan --copt=-O1
108108
build:asan --copt=-g
109109
build:asan --copt=-fno-omit-frame-pointer
110110
build:asan --linkopt=-fsanitize=address
111+
# TCMalloc is incompatible with ASan: __asan_init's interceptor setup calls
112+
# dlsym -> malloc before TCMalloc is initialized, segfaulting at startup.
113+
# Override the per-target malloc attribute to use the system allocator, which
114+
# ASan intercepts cleanly.
115+
build:asan --custom_malloc=@bazel_tools//tools/cpp:malloc
111116

112117
# Flags with enough debug symbols to get useful outputs with Linux `perf`
113118
build:profile --strip=never

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# source control.
77

88
Andrew Kennings
9+
Antmicro
910
Federal University of Rio Grande do Sul (UFRGS)
1011
Google LLC
1112
Iowa State University

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ option(USE_SYSTEM_ABC "Use system shared ABC library" OFF)
4242
# Allow disabling tests
4343
option(ENABLE_TESTS "Enable OpenROAD tests" ON)
4444

45+
# Opt-in GPU acceleration via Kokkos. The actual compute backend (CUDA, HIP,
46+
# SYCL, or host-only OpenMP/Threads) is determined by the installed Kokkos
47+
# package; OpenROAD inspects Kokkos_ENABLE_* and turns on the matching CMake
48+
# language and dependencies automatically. See the per-module CMakeLists for
49+
# how individual subsystems wire their GPU sources.
50+
option(ENABLE_GPU "Enable GPU acceleration via Kokkos" OFF)
51+
4552
# Allow enabling address sanitizer
4653
option(ASAN "Enable Address Sanitizer" OFF)
4754

@@ -88,6 +95,13 @@ if(NOT CMAKE_BUILD_TYPE)
8895
set(CMAKE_BUILD_TYPE RELEASE)
8996
endif()
9097

98+
# GPU backend wiring (opt-in). All Kokkos / CUDA / HIP / SYCL detection,
99+
# compiler probing, and language enablement live in cmake/KokkosBackend.cmake
100+
# and are loaded only when the user opts in via ENABLE_GPU=ON.
101+
if(ENABLE_GPU)
102+
include(KokkosBackend)
103+
endif()
104+
91105
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
92106
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.3.0")
93107
message(FATAL_ERROR "Insufficient gcc version. Found ${CMAKE_CXX_COMPILER_VERSION}, but require >= 8.3.0.")

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bazel_dep(name = "eigen", version = "3.4.0.bcr.3")
7878
bazel_dep(name = "fmt", version = "11.2.0.bcr.1")
7979
bazel_dep(name = "git", version = "2.54.0")
8080
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
81-
bazel_dep(name = "openmp", version = "21.1.5.bcr.1")
81+
bazel_dep(name = "openmp", version = "21.1.5.bcr.2")
8282
bazel_dep(name = "or-tools", version = "9.15")
8383
bazel_dep(name = "spdlog", version = "1.15.1")
8484
bazel_dep(name = "sv-lang", version = "10.0.1-20260316-f04e8156")

MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/tcl_encode_or.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ def _tcl_encode_or_impl(ctx):
2323
outputs = [output_file],
2424
inputs = ctx.files.srcs,
2525
arguments = [args],
26-
tools = [ctx.executable._encode_script],
26+
tools = depset(
27+
direct = [ctx.executable._encode_script],
28+
transitive = [ctx.toolchains["@rules_python//python:toolchain_type"].py3_runtime.files] if ctx.toolchains["@rules_python//python:toolchain_type"].py3_runtime and ctx.toolchains["@rules_python//python:toolchain_type"].py3_runtime.files else [],
29+
),
2730
executable = ctx.toolchains["@rules_python//python:toolchain_type"].py3_runtime.interpreter,
2831
)
2932
return [DefaultInfo(files = depset([output_file]))]

cmake/KokkosBackend.cmake

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) 2026, The OpenROAD Authors
3+
4+
# Kokkos GPU backend wiring for OpenROAD. Included from the root
5+
# CMakeLists.txt only when ENABLE_GPU=ON; not loaded otherwise.
6+
#
7+
# Discovers the user's Kokkos install, inherits its compute backend, turns
8+
# on the matching CMake language so downstream targets can mark kernel
9+
# sources with set_source_files_properties(... LANGUAGE CUDA|HIP), and
10+
# applies the small set of nvcc / fmt / host-compiler workarounds that the
11+
# CUDA backend currently needs in modern Linux toolchains. Per-module
12+
# CMakeLists (e.g. src/gpl) key off ENABLE_GPU and Kokkos_ENABLE_*; they
13+
# do not need to call find_package(Kokkos) or enable_language() themselves.
14+
15+
find_package(Kokkos QUIET)
16+
if(NOT Kokkos_FOUND)
17+
message(FATAL_ERROR
18+
"OpenROAD: ENABLE_GPU=ON requires the Kokkos package to be "
19+
"installed and discoverable by CMake, but Kokkos was not found.\n"
20+
" - If Kokkos is already installed: pass "
21+
"-DKokkos_ROOT=/path/to/kokkos (or extend CMAKE_PREFIX_PATH).\n"
22+
" - If not: build and install Kokkos from "
23+
"https://github.com/kokkos/kokkos with the desired backend "
24+
"(CUDA / HIP / SYCL / OpenMP) and a target architecture that "
25+
"matches the host GPU.\n"
26+
" - A future etc/DependencyInstaller.sh -gpu option will "
27+
"automate this step.")
28+
endif()
29+
30+
# KokkosFFT — required by the gpl GPU FFT backend (src/gpl/src/gpu/dct.cpp).
31+
# A separate package from Kokkos core.
32+
find_package(KokkosFFT QUIET)
33+
if(NOT KokkosFFT_FOUND)
34+
message(FATAL_ERROR
35+
"ENABLE_GPU=ON requires KokkosFFT, which was not found.\n"
36+
" - Install KokkosFFT (https://github.com/kokkos/kokkos-fft) against\n"
37+
" your Kokkos build, then re-configure with -DKokkosFFT_ROOT=<prefix>.\n"
38+
" - A future etc/DependencyInstaller.sh -gpu will install Kokkos and\n"
39+
" KokkosFFT together.")
40+
endif()
41+
42+
message(STATUS "OpenROAD: GPU acceleration enabled (Kokkos ${Kokkos_VERSION})")
43+
44+
if(Kokkos_ENABLE_CUDA)
45+
# Auto-discover nvcc when the user has CUDA installed at a standard
46+
# location but their environment does not expose it on PATH (common
47+
# with IDE-launched configures: the bundled CMake does not inherit
48+
# the shell PATH). enable_language(CUDA) below would otherwise abort
49+
# with "No CMAKE_CUDA_COMPILER could be found" even though Kokkos's
50+
# find_package already located the toolkit.
51+
if(NOT DEFINED CMAKE_CUDA_COMPILER AND NOT DEFINED ENV{CUDACXX})
52+
find_program(_OPENROAD_NVCC nvcc
53+
HINTS ENV CUDA_HOME ENV CUDA_PATH ENV CUDA_ROOT
54+
/usr/local/cuda/bin
55+
/usr/local/cuda-13.0/bin
56+
/usr/local/cuda-12.8/bin /usr/local/cuda-12.0/bin
57+
/opt/cuda/bin
58+
)
59+
if(_OPENROAD_NVCC)
60+
set(CMAKE_CUDA_COMPILER "${_OPENROAD_NVCC}" CACHE FILEPATH "")
61+
message(STATUS "OpenROAD: auto-discovered nvcc at ${_OPENROAD_NVCC}")
62+
endif()
63+
endif()
64+
# nvcc < 13 cannot parse glibc 2.38+'s _Float128 type that ships with
65+
# gcc 13+'s C++ standard library headers (math.h template specialization
66+
# for __iseqsig_type<_Float128>). When a known-broken pairing is detected,
67+
# pin a compatible older g++ as the CUDA host compiler (the system C++
68+
# compiler stays unchanged for non-CUDA TUs). Override is always
69+
# available via -DCMAKE_CUDA_HOST_COMPILER or CUDAHOSTCXX.
70+
if(NOT DEFINED CMAKE_CUDA_HOST_COMPILER AND NOT DEFINED ENV{CUDAHOSTCXX}
71+
AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
72+
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0"
73+
AND _OPENROAD_NVCC)
74+
execute_process(
75+
COMMAND "${_OPENROAD_NVCC}" --version
76+
OUTPUT_VARIABLE _OPENROAD_NVCC_VERSION_OUTPUT
77+
ERROR_QUIET
78+
OUTPUT_STRIP_TRAILING_WHITESPACE)
79+
if(_OPENROAD_NVCC_VERSION_OUTPUT MATCHES "release ([0-9]+)")
80+
set(_OPENROAD_NVCC_MAJOR "${CMAKE_MATCH_1}")
81+
if(_OPENROAD_NVCC_MAJOR LESS 13)
82+
foreach(_OPENROAD_GXX_VER 12 11)
83+
find_program(_OPENROAD_CUDAHOST g++-${_OPENROAD_GXX_VER}
84+
HINTS /usr/bin /usr/local/bin)
85+
if(_OPENROAD_CUDAHOST)
86+
set(CMAKE_CUDA_HOST_COMPILER "${_OPENROAD_CUDAHOST}"
87+
CACHE FILEPATH "")
88+
message(STATUS
89+
"OpenROAD: pinning CUDA host compiler to "
90+
"${_OPENROAD_CUDAHOST} (nvcc ${_OPENROAD_NVCC_MAJOR}.x + "
91+
"glibc/gcc 13+ _Float128 compat)")
92+
break()
93+
endif()
94+
unset(_OPENROAD_CUDAHOST CACHE)
95+
endforeach()
96+
if(NOT DEFINED CMAKE_CUDA_HOST_COMPILER)
97+
message(FATAL_ERROR
98+
"OpenROAD: nvcc ${_OPENROAD_NVCC_MAJOR}.x cannot parse "
99+
"_Float128 declarations in glibc 2.38+ system headers used "
100+
"by gcc ${CMAKE_CXX_COMPILER_VERSION}, and no compatible "
101+
"g++-12 / g++-11 was found in /usr/bin or /usr/local/bin. "
102+
"Install one (e.g. apt install g++-12) or set "
103+
"-DCMAKE_CUDA_HOST_COMPILER=/path/to/older-g++ explicitly.")
104+
endif()
105+
endif()
106+
endif()
107+
endif()
108+
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES OR "${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "")
109+
if(DEFINED Kokkos_CUDA_ARCHITECTURES
110+
AND NOT "${Kokkos_CUDA_ARCHITECTURES}" STREQUAL "")
111+
set(CMAKE_CUDA_ARCHITECTURES "${Kokkos_CUDA_ARCHITECTURES}")
112+
else()
113+
message(FATAL_ERROR
114+
"OpenROAD: ENABLE_GPU=ON with Kokkos CUDA backend, but the "
115+
"Kokkos package does not advertise Kokkos_CUDA_ARCHITECTURES "
116+
"and CMAKE_CUDA_ARCHITECTURES was not provided. Set "
117+
"-DCMAKE_CUDA_ARCHITECTURES=<arch> explicitly (e.g. 89 for "
118+
"RTX 4070, 120 for RTX 5090) or rebuild Kokkos with the "
119+
"target architecture baked in.")
120+
endif()
121+
endif()
122+
enable_language(CUDA)
123+
find_package(CUDAToolkit REQUIRED)
124+
message(STATUS "OpenROAD: CUDA backend (arch=${CMAKE_CUDA_ARCHITECTURES})")
125+
# A GPU driver (the kernel module exposing libcuda.so.1) is needed only to
126+
# *run* CUDA code, never to build it -- nvcc cross-compiles device code on a
127+
# host with no GPU. Note its absence so the resulting libcuda.so.1 load
128+
# errors on this host (e.g. ctest, or running openroad) read as expected
129+
# rather than as a misconfiguration. This is informational only: a GPU build
130+
# on a driverless host is a supported cross-compile workflow, not an error.
131+
if(NOT EXISTS "/proc/driver/nvidia")
132+
message(STATUS
133+
"OpenROAD: no NVIDIA driver on this host -- GPU code is being "
134+
"cross-compiled. Run the GPU binaries and tests on a GPU machine.")
135+
endif()
136+
# nvcc 12.8 cannot parse fmt 11's nontype-template-parameter user-defined
137+
# literals (fmt/bundled/format.h: operator""_a with fixed_string). The
138+
# legacy literal fallback is still available; opt into it for CUDA TUs
139+
# only. Project-wide CXX compilation is unaffected.
140+
add_compile_definitions(
141+
$<$<COMPILE_LANGUAGE:CUDA>:FMT_USE_NONTYPE_TEMPLATE_ARGS=0>)
142+
# On aarch64, Boost's unordered_flat_map detects __ARM_NEON and includes
143+
# <arm_neon.h> for SIMD-accelerated hashing. nvcc cannot parse gcc's
144+
# arm_neon.h (it contains gcc-specific intrinsics), so disable the NEON
145+
# path for CUDA TUs. The CPU TUs (compiled by g++) are unaffected.
146+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64")
147+
add_compile_definitions(
148+
$<$<COMPILE_LANGUAGE:CUDA>:BOOST_UNORDERED_DISABLE_NEON>)
149+
endif()
150+
elseif(Kokkos_ENABLE_HIP)
151+
enable_language(HIP)
152+
message(STATUS "OpenROAD: HIP backend")
153+
elseif(Kokkos_ENABLE_SYCL)
154+
message(STATUS "OpenROAD: SYCL backend (driven by Kokkos host compiler)")
155+
else()
156+
message(STATUS
157+
"OpenROAD: host-only Kokkos backend (Serial / OpenMP / Threads)")
158+
endif()

etc/DependencyInstaller.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,35 @@ _install_bazel() {
883883
_execute "Installing bazelisk..." mv bazelisk "${bazel_prefix}/bin/bazelisk"
884884
)
885885
if _command_exists "apt-get"; then
886+
# Ubuntu 26.04 ships the libxml2 runtime with soname
887+
# libxml2.so.16, but the prebuilt LLVM toolchain (lld) pulled in
888+
# by the Bazel build is linked against the old libxml2.so.2.
889+
# Pull in libxml2-dev there (and add a compatibility symlink
890+
# below); older Ubuntu still provides .so.2 via libxml2.
891+
local ubuntu_version=""
892+
if [[ -f /etc/os-release ]]; then
893+
ubuntu_version=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g')
894+
fi
895+
local libxml2_pkg="libxml2"
896+
if [[ -n "${ubuntu_version}" ]] && _version_compare "${ubuntu_version}" -ge "26.04"; then
897+
libxml2_pkg="libxml2-dev"
898+
fi
886899
_execute "Installing bazel required libraries..." \
887900
apt-get -y install --no-install-recommends \
888-
libc6-dev libxml2 libtinfo6 zlib1g libstdc++6
901+
libc6-dev "${libxml2_pkg}" libtinfo6 zlib1g libstdc++6
902+
# lld only uses libxml2 for Windows COFF manifests, never during a
903+
# Linux link, so the .so.16 -> .so.2 compatibility symlink is safe.
904+
# Gated to 26.04+ only.
905+
if [[ -n "${ubuntu_version}" ]] && _version_compare "${ubuntu_version}" -ge "26.04"; then
906+
local libdir="/usr/lib/$(uname -m)-linux-gnu"
907+
local libxml2_so
908+
libxml2_so=$(ls "${libdir}"/libxml2.so.* 2>/dev/null \
909+
| grep -v 'libxml2.so.2$' | head -n1)
910+
if [[ ! -e "${libdir}/libxml2.so.2" && -n "${libxml2_so}" ]]; then
911+
_execute "Adding libxml2.so.2 compatibility symlink for prebuilt LLVM lld..." \
912+
ln -sf "$(basename "${libxml2_so}")" "${libdir}/libxml2.so.2"
913+
fi
914+
fi
889915
elif _command_exists "yum"; then
890916
_execute "Installing bazel required libraries..." \
891917
yum install -y \

src/dpl/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ detailed_placement
7373
[-report_file_name filename]
7474
[-use_negotiation]
7575
[-abacus]
76+
[-site_search_window sites]
77+
[-row_search_window rows]
78+
[-drc_penalty penalty]
7679
```
7780

7881
#### Options
@@ -86,6 +89,9 @@ detailed_placement
8689
| `-report_file_name` | File name for saving the report to (e.g. `report.json`.) |
8790
| `-use_negotiation` | Use the NegotiationLegalizer instead of the default diamond search engine. |
8891
| `-abacus` | Enable the Abacus pre-pass within the NegotiationLegalizer. Only effective when `-use_negotiation` is set. |
92+
| `-site_search_window` | NegotiationLegalizer: maximum number of sites a cell may be moved left or right of its initial position. Default `20`, `0` allowed (no horizontal movement). |
93+
| `-row_search_window` | NegotiationLegalizer: maximum number of rows a cell may be moved up or down from its initial position. Default `5`, `0` allowed (no row changes). |
94+
| `-drc_penalty` | NegotiationLegalizer: priority to DRC violations, ramped up each iteration to push DRC cleanup later in the run. Lower values tolerate DRC violations early on while overlaps are resolved. Default `5`, `0` allowed (disables the escalating per-candidate penalty, DRC-violating cells still accrue history cost separately). |
8995

9096
### Set Placement Padding
9197

src/dpl/include/dpl/Opendp.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,18 @@ class Opendp
105105

106106
// legalize/report
107107
// max_displacment is in sites. use zero for defaults.
108+
// site_search_window/row_search_window/drc_penalty use a negative value to
109+
// mean "unset" (use the negotiation legalizer's own default); 0 is a valid
110+
// explicit value for all three.
108111
void detailedPlacement(int max_displacement_x,
109112
int max_displacement_y,
110113
const std::string& report_file_name = std::string(""),
111114
bool incremental = false,
112115
bool use_negotiation = false,
113-
bool run_abacus = false);
116+
bool run_abacus = false,
117+
int site_search_window = -1,
118+
int row_search_window = -1,
119+
double drc_penalty = -1.0);
114120
void reportLegalizationStats() const;
115121

116122
void setPaddingGlobal(int left, int right);
@@ -120,6 +126,8 @@ class Opendp
120126
void setJumpMoves(int jump_moves);
121127
void setIterativePlacement(bool iterative);
122128
void setDeepIterativePlacement(bool deep_iterative);
129+
void setNegotiationDebugInterval(int iterative_jump);
130+
void setNegotiationDebugStart(int iterative_start);
123131

124132
// Global padding.
125133
int padGlobalLeft() const;
@@ -398,6 +406,8 @@ class Opendp
398406
int move_count_ = 1;
399407
bool iterative_debug_ = false;
400408
bool deep_iterative_debug_ = false;
409+
int negotiation_debug_interval_ = 1;
410+
int negotiation_debug_start_ = 0;
401411
bool incremental_ = false;
402412
bool use_negotiation_ = false;
403413

0 commit comments

Comments
 (0)