From d03ecd965d3bbd22e3d0597c61653cde06a098bf Mon Sep 17 00:00:00 2001 From: Kareem Farid Date: Tue, 5 Sep 2023 13:51:08 +0000 Subject: [PATCH] Update OpenROAD + Handle Breaking Changes (#1949) + update utils.py `fetch_submodules_from_tarballs` to handle relative submodule url ~ `openroad_app` -> `0a6d0fd` ~ add extractor for operating conditions Co-authored-by: Donn --- .github/workflows/openlane_ci.yml | 4 ++ Makefile | 4 +- dependencies/python/compile_time.txt | 3 +- dependencies/python/run_time.txt | 4 +- dependencies/tool_metadata.yml | 2 +- dependencies/verify_versions.py | 2 +- docker/Makefile | 3 +- docker/run_base/.dockerignore | 1 + docker/run_base/Dockerfile | 1 + docker/utils.py | 5 +- requirements.txt | 3 +- scripts/openroad/common/io.tcl | 20 +++++++- scripts/openroad/irdrop.tcl | 2 +- .../utils/get_default_operating_conditions.py | 51 +++++++++++++++++++ 14 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 docker/run_base/.dockerignore create mode 100644 scripts/utils/get_default_operating_conditions.py diff --git a/.github/workflows/openlane_ci.yml b/.github/workflows/openlane_ci.yml index 77dd1e651..6e4fb3e41 100644 --- a/.github/workflows/openlane_ci.yml +++ b/.github/workflows/openlane_ci.yml @@ -24,6 +24,10 @@ jobs: - name: Set up environment variables uses: ./.github/actions/set_env_variables + - name: Set up GITHUB_TOKEN + run: | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + - name: Get Volare Build/Push Dependencies run: | # Magic Build Dependencies diff --git a/Makefile b/Makefile index 325b015db..8021b9c3b 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ mount: .PHONY: pdk pdk: venv/created - PYTHONPATH= ./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir volare>=0.12.3 + PYTHONPATH= ./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir 'volare>=0.12.3' ./venv/bin/volare enable --pdk $(PDK_FAMILY) .PHONY: survey @@ -147,7 +147,7 @@ start-build-env: venv/created bash -c "bash --rcfile <(cat ~/.bashrc ./venv/bin/activate)" venv: venv/created -venv/created: ./requirements.txt ./requirements_dev.txt ./requirements_lint.txt ./dependencies/python/precompile_time.txt ./dependencies/python/run_time.txt +venv/created: ./requirements.txt ./requirements_dev.txt ./requirements_lint.txt ./dependencies/python/precompile_time.txt rm -rf ./venv $(PYTHON_BIN) -m venv ./venv PYTHONPATH= ./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir pip diff --git a/dependencies/python/compile_time.txt b/dependencies/python/compile_time.txt index c013f739c..b6868d450 100644 --- a/dependencies/python/compile_time.txt +++ b/dependencies/python/compile_time.txt @@ -1,2 +1 @@ -cmake -pyinstaller \ No newline at end of file +cmake \ No newline at end of file diff --git a/dependencies/python/run_time.txt b/dependencies/python/run_time.txt index 53c0723a9..b120ad757 100644 --- a/dependencies/python/run_time.txt +++ b/dependencies/python/run_time.txt @@ -1,4 +1,4 @@ click>=8.0.0,<9 pyyaml>=6,<7 -install>=1.3.5,<2 -XlsxWriter>=3.0.2,<4 \ No newline at end of file +XlsxWriter>=3.0.2,<4 +git+https://github.com/efabless/libparse-python@0.1.5 \ No newline at end of file diff --git a/dependencies/tool_metadata.yml b/dependencies/tool_metadata.yml index 3267abcd6..b100be1fb 100644 --- a/dependencies/tool_metadata.yml +++ b/dependencies/tool_metadata.yml @@ -65,7 +65,7 @@ in_install: false - name: openroad_app repo: https://github.com/The-OpenROAD-Project/OpenROAD - commit: 0cfb9a45bfb256c9af1a0500d4c97da0f145f54f + commit: 0a6d0fd469bc674417036342994520ee2e0a2727 in_install: false - name: git repo: https://github.com/git/git diff --git a/dependencies/verify_versions.py b/dependencies/verify_versions.py index 4b61400f2..45b0cd9e8 100644 --- a/dependencies/verify_versions.py +++ b/dependencies/verify_versions.py @@ -55,7 +55,6 @@ def verify_versions( manifest_names_by_SOURCES_name = { "open_pdks": "open_pdks", "skywater": "sky130", - "magic": "magic", } pdk_manifest_names = set(manifest_names_by_SOURCES_name.values()) @@ -131,6 +130,7 @@ def verify_versions( ) for name, commit in tool_versions: + print(name, commit) manifest_commit = manifest_dict[name]["commit"] if commit != manifest_commit: diff --git a/docker/Makefile b/docker/Makefile index 7658477e3..b2c596769 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -46,6 +46,7 @@ pull-build-base: $(PYTHON_BIN) ./utils.py pull-if-doesnt-exist --repository $(TOOL_REPOSITORY) --os $(OS_NAME) --architecture $(BUILD_ARCH) build-base @echo "-----------" +# Used by pull-if-doesnt-exist build-run-base: ./run_base/Dockerfile cat ../dependencies/python/run_time.txt > ./run_base/pip_dependencies.txt cat ../dependencies/centos-7/precompile_time.txt > ./run_base/yum_repos.txt @@ -61,7 +62,7 @@ pull-run-base: @echo "-----------" # Tool Images -$(TOOL_BUILD_TARGETS): build-% : ./%/Dockerfile pull-build-base +$(TOOL_BUILD_TARGETS): build-% : ./%/Dockerfile pull-build-base pull-run-base mkdir -p logs cp ./utils.py $* $(BUILD_COMMAND)\ diff --git a/docker/run_base/.dockerignore b/docker/run_base/.dockerignore new file mode 100644 index 000000000..51cc96c8d --- /dev/null +++ b/docker/run_base/.dockerignore @@ -0,0 +1 @@ +/Dockerfile \ No newline at end of file diff --git a/docker/run_base/Dockerfile b/docker/run_base/Dockerfile index 458772403..4cfecad67 100644 --- a/docker/run_base/Dockerfile +++ b/docker/run_base/Dockerfile @@ -32,4 +32,5 @@ RUN git config --global user.email "openlane.user@localhost" ## Wheel Build Dependencies RUN python3 -m pip install --no-cache-dir --upgrade pip COPY ./pip_dependencies.txt /pip_dependencies.txt +RUN yum install -y swig3 gcc gcc-c++ python3-devel RUN python3 -m pip install --no-cache-dir -r /pip_dependencies.txt \ No newline at end of file diff --git a/docker/utils.py b/docker/utils.py index 1f3632331..0648c93f1 100644 --- a/docker/utils.py +++ b/docker/utils.py @@ -29,7 +29,7 @@ SUPPORTED_OPERATING_SYSTEMS = {"centos-7"} -def test_manifest_exists(repository, tag) -> str: +def test_manifest_exists(repository, tag) -> bool: url = f"https://registry.hub.docker.com/v2/repositories/{repository}/tags/{tag}" req = urllib.request.Request(url, headers={"Accept": "application/json"}) status = None @@ -303,6 +303,9 @@ def fetch_submodules_from_tarballs(filter, repository, commit): for name, submodule in submodules_by_name.items(): submodule["commit"] = shas_by_path.get(submodule["path"]) + if submodule["url"].startswith(tuple(["./", "../"])): + submodule["url"] = urllib.parse.urljoin(repository, submodule["url"]) + if submodule["url"].endswith(".git"): submodule["url"] = submodule["url"][:-4] diff --git a/requirements.txt b/requirements.txt index f8faac9cb..1f2a0fa0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ -r ./dependencies/python/precompile_time.txt --r ./dependencies/python/run_time.txt \ No newline at end of file +click>=8.0.0,<9 +pyyaml>=6,<7 \ No newline at end of file diff --git a/scripts/openroad/common/io.tcl b/scripts/openroad/common/io.tcl index 246e3d7a2..0636f5223 100644 --- a/scripts/openroad/common/io.tcl +++ b/scripts/openroad/common/io.tcl @@ -114,7 +114,7 @@ proc print_units {args} { proc read_libs {args} { sta::parse_key_args "read_libs" args \ keys {-typical -slowest -fastest}\ - flags {-no_extra} + flags {-no_extra -set_operating_conditions} if { ![info exists keys(-typical)] } { puts "read_libs -typical is required" @@ -134,6 +134,13 @@ proc read_libs {args} { foreach lib $corner($corner_name) { puts "read_liberty -corner $corner_name $lib" read_liberty -corner $corner_name $lib + if { [info exists flags(-set_operating_conditions)] } { + set lib_info [fetch_library_info $lib] + set lib_name [lindex $lib_info 0] + set operating_conditions [lindex $lib_info 1] + puts "\[INFO] Setting operating conditions to '$operating_conditions'…" + set_operating_conditions -library $lib_name $operating_conditions + } } if { ![info exists flags(-no_extra)] } { if { [info exists ::env(EXTRA_LIBS) ] } { @@ -151,7 +158,7 @@ proc read_libs {args} { proc read {args} { sta::parse_key_args "read" args \ keys {-lib_fastest -lib_typical -lib_slowest} \ - flags {-no_spefs} + flags {-no_spefs -set_lib_operating_conditions} if { [info exists ::env(IO_READ_DEF)] && $::env(IO_READ_DEF) } { if { [ catch {read_lef $::env(MERGED_LEF)} errmsg ]} { @@ -184,6 +191,9 @@ proc read {args} { if { [info exists keys(-lib_slowest)] } { lappend read_libs_args -slowest "$keys(-lib_slowest)" } + if { [info exists flags(-set_lib_operating_conditions)] } { + lappend read_libs_args -set_operating_conditions + } read_libs {*}$read_libs_args @@ -319,3 +329,9 @@ proc read_spefs {} { } } } + +proc fetch_library_info {lib} { + set extraction [exec python3 $::env(SCRIPTS_DIR)/utils/get_default_operating_conditions.py $lib] + set result [split $extraction ":"] + return $result +} diff --git a/scripts/openroad/irdrop.tcl b/scripts/openroad/irdrop.tcl index 9685e6c96..ab0fab67e 100644 --- a/scripts/openroad/irdrop.tcl +++ b/scripts/openroad/irdrop.tcl @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. source $::env(SCRIPTS_DIR)/openroad/common/io.tcl -read +read -set_lib_operating_conditions read_spef $::env(CURRENT_SPEF) source $::env(SCRIPTS_DIR)/openroad/common/set_rc.tcl diff --git a/scripts/utils/get_default_operating_conditions.py b/scripts/utils/get_default_operating_conditions.py new file mode 100644 index 000000000..537006a55 --- /dev/null +++ b/scripts/utils/get_default_operating_conditions.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# Copyright 2023 Efabless Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import sys + +import click +from libparse import LibertyParser + + +@click.command() +@click.argument("liberty", type=click.Path(dir_okay=False, exists=True)) +def get_default_operating_conditions(liberty): + library = LibertyParser(open(liberty)) + ast = library.ast + + default_operating_conditions_id = None + operating_conditions_raw = {} + for child in ast.children: + if child.id == "default_operating_conditions": + default_operating_conditions_id = child.value + if child.id == "operating_conditions": + operating_conditions_raw[child.args[0]] = child + + if default_operating_conditions_id is None: + if len(operating_conditions_raw) > 1: + print( + "No default operating condition defined, and the liberty file has multiple operating conditions.", + file=sys.stderr, + ) + exit(-1) + elif len(operating_conditions_raw) < 1: + print("Liberty file has no operating conditions.", file=sys.stderr) + exit(-1) + default_operating_conditions_id = list(operating_conditions_raw.keys())[0] + + print(f"{ast.args[0]}:{default_operating_conditions_id}", end="") + + +if __name__ == "__main__": + get_default_operating_conditions()