From 2b5420b6d5debdfdf7302e89f71b7b6ce29dbb4f Mon Sep 17 00:00:00 2001 From: Michal Czyz Date: Fri, 29 Mar 2024 14:17:40 +0100 Subject: [PATCH] WIP: Cleanup Signed-off-by: Michal Czyz --- .github/actions/build/action.yml | 26 ------- .github/actions/cache/action.yml | 15 ---- .github/actions/free-disk/action.yml | 23 ------ .github/actions/implementation/action.yml | 94 ----------------------- .github/actions/test/action.yml | 24 ------ .github/scripts/validate_json.py | 37 --------- .github/workflows/xls-modules-dma.json | 37 +++++++++ .github/workflows/xls-modules.json | 39 ---------- .github/workflows/xls-modules.yml | 52 +++++++++---- 9 files changed, 75 insertions(+), 272 deletions(-) delete mode 100644 .github/actions/build/action.yml delete mode 100644 .github/actions/cache/action.yml delete mode 100644 .github/actions/free-disk/action.yml delete mode 100644 .github/actions/implementation/action.yml delete mode 100644 .github/actions/test/action.yml delete mode 100644 .github/scripts/validate_json.py create mode 100644 .github/workflows/xls-modules-dma.json delete mode 100644 .github/workflows/xls-modules.json diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml deleted file mode 100644 index fe2063ce48..0000000000 --- a/.github/actions/build/action.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: build -description: 'Build XLS' - -runs: - using: "composite" - steps: - - name: Cache - uses: ./.github/actions/cache - - - name: Install dependencies via apt - shell: bash - run: sudo apt-get install python3-distutils python3-dev python-is-python3 libtinfo5 build-essential liblapack-dev libblas-dev gfortran - - - name: Install bazelisk - shell: bash - run: | - curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64" - mkdir -p "${GITHUB_WORKSPACE}/bin/" - mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel" - chmod +x "${GITHUB_WORKSPACE}/bin/bazel" - - - name: Bazel Build Tools (opt) - shell: bash - run: | - "${GITHUB_WORKSPACE}/bin/bazel" build --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 -c opt --test_output=errors -- //xls/dslx:interpreter_main //xls/dslx/ir_convert:ir_converter_main //xls/tools:opt_main //xls/tools:codegen_main - diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml deleted file mode 100644 index 9b26be548c..0000000000 --- a/.github/actions/cache/action.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: cache -description: 'Cache Bazel' - -runs: - using: "composite" - steps: - - name: Mount Bazel Cache - uses: actions/cache@v4 - with: - path: "~/.cache/bazel" - # Create/use a cache called bazel-cache-22_04- - # and read the latest cache with prefix bazel-cache-22_04- - # if it doesn't already exist. - key: bazel-cache-22_04-${{ github.sha }} - restore-keys: bazel-cache-22_04- diff --git a/.github/actions/free-disk/action.yml b/.github/actions/free-disk/action.yml deleted file mode 100644 index a2a90a9e36..0000000000 --- a/.github/actions/free-disk/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: free-disk -description: 'Removes unused files from runner' - -# WARNING -# This is not a 100% safe method of reclaiming space. -# Your workflow may depend on removed files. - -runs: - using: "composite" - steps: - - name: Increase build space - shell: bash - run: | - echo "Before cleanup" - df -H - sudo rm -rf /usr/share/dotnet/* - sudo rm -rf /usr/local/lib/android/* - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - echo "After cleanup" - df -H diff --git a/.github/actions/implementation/action.yml b/.github/actions/implementation/action.yml deleted file mode 100644 index 504d56146b..0000000000 --- a/.github/actions/implementation/action.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: implementation -description: 'DSLX to Openroad P&R' -inputs: - xls_module: - description: 'Module in //xls/modules' - required: true - default: 'xls/modules/dma' - rule_ir: - description: 'Bazel rule to generate optimized IR' - required: true - default: 'csr_opt_ir_benchmark' - rule_verilog: - description: 'Bazel rule to generate verilog' - required: true - default: 'verilog_csr' - rule_synthesis: - description: 'Bazel rule to synthesize verilog' - required: true - default: 'csr_benchmark_synth' - rule_pnr: - description: 'Bazel rule to place and route' - required: true - default: 'csr_place_and_route' -runs: - using: "composite" - steps: - - uses: ./.github/actions/cache - - - name: Summary page - shell: bash - run: | - echo "Module ${{inputs.xls_module}}" >> $GITHUB_STEP_SUMMARY - - - name: IR - shell: bash - run: | - bazel run --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_ir}} - - - name: Summary page - shell: bash - run: | - echo "Generate IR :white_check_mark:" >> $GITHUB_STEP_SUMMARY - - - name: Verilog - shell: bash - run: | - bazel build --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_verilog}} - - - name: Summary page - shell: bash - run: | - echo "Verilog codegen :white_check_mark:" >> $GITHUB_STEP_SUMMARY - - - name: Synthesis - shell: bash - run: | - bazel run --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_synthesis}} - - - name: Summary page - shell: bash - run: | - echo -n "Synthesis :white_check_mark:" >> $GITHUB_STEP_SUMMARY - - - name: P&R - shell: bash - run: | - bazel build --local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9 ${{inputs.xls_module}}:${{inputs.rule_pnr}} - - - name: Summary page - shell: bash - run: | - echo -n "Place & Route :white_check_mark:" >> $GITHUB_STEP_SUMMARY - - # ${variable/character_to_replace/new_character} - # ${variable/ slash / underscore } - - name: Prepare artifact name - if: always() - shell: bash - run: | - name_input=${{inputs.xls_module}}/${{inputs.rule_ir}} - name_output="${name_input//\//_}" - echo "artifact_name=${name_output}" >> "$GITHUB_ENV" - - - name: Artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: artifacts-impl-${{ env.artifact_name }} - path: | - ./bazel-bin/${{inputs.xls_module}}/*.log - ./bazel-bin/${{inputs.xls_module}}/*.textproto - ./bazel-bin/${{inputs.xls_module}}/*.ir - ./bazel-bin/${{inputs.xls_module}}/*.v - ./bazel-bin/${{inputs.xls_module}}/*.sv diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml deleted file mode 100644 index eb479a2b85..0000000000 --- a/.github/actions/test/action.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: test -description: 'DSLX Test' -inputs: - xls_module: - description: 'Module in //xls/modules' - required: true - default: 'xls/modules/dma' - rule_test: - description: 'Bazel rule to test DSLX' - required: true - default: 'test_csr' - -runs: - using: "composite" - steps: - - uses: ./.github/actions/cache - - - name: IR - shell: bash - env: - BAZEL_RESOURCES_OPT: "--local_cpu_resources=HOST_CPUS-1 --local_ram_resources=HOST_RAM*.9" - BAZEL_RUN_OPT: "" - run: | - bazel run ${BAZEL_RESOURCES_OPT} ${BAZEL_RUN_OPT} ${{inputs.xls_module}}/${{inputs.rule_test}} diff --git a/.github/scripts/validate_json.py b/.github/scripts/validate_json.py deleted file mode 100644 index d6fe6c6308..0000000000 --- a/.github/scripts/validate_json.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2024 The XLS Authors -# -# 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 json -import os - -# Execution -# In root dir: python .github/scripts/validate_json.py - -# This script uses bazel query to check if each target defined -# in the xls-modules.json exists in the BUILD. - -json_file = open('.github/workflows/xls-modules.json') - -data = json.load(json_file) -json_file.close() - -bazel_rules = [] -for module in data['module']: - for type in ["rule_ir", "rule_verilog", "rule_synthesis", "rule_pnr"]: - bazel_rule = "bazel query " + module['xls_module'] + ":" + module[type] - bazel_rules.append(bazel_rule) - -for bazel_rule in bazel_rules: - RC = os.system(bazel_rule) - assert RC == 0 diff --git a/.github/workflows/xls-modules-dma.json b/.github/workflows/xls-modules-dma.json new file mode 100644 index 0000000000..5aeadd9712 --- /dev/null +++ b/.github/workflows/xls-modules-dma.json @@ -0,0 +1,37 @@ +{ + "dma": { + "name": "//xls/modules/dma", + "rules": [ + { + "ir": "csr_opt_ir_benchmark", + "verilog": "verilog_csr", + "synthesis": "csr_benchmark_synth", + "pnr": "csr_place_and_route" + }, + { + "ir": "axi_csr_opt_ir_benchmark", + "verilog": "verilog_axi_csr", + "synthesis": "axi_csr_benchmark_synth", + "pnr": "axi_csr_place_and_route" + }, + { + "ir": "address_generator_opt_ir_benchmark", + "verilog": "verilog_address_generator", + "synthesis": "address_generator_benchmark_synth", + "pnr": "address_generator_place_and_route" + }, + { + "ir": "frontend_reader_opt_ir_benchmark", + "verilog": "verilog_frontend_reader", + "synthesis": "frontend_reader_benchmark_synth", + "pnr": "frontend_reader_place_and_route" + }, + { + "ir": "frontend_writer_opt_ir_benchmark", + "verilog": "verilog_frontend_writer", + "synthesis": "frontend_writer_benchmark_synth", + "pnr": "frontend_writer_place_and_route" + } + ] + } +} diff --git a/.github/workflows/xls-modules.json b/.github/workflows/xls-modules.json deleted file mode 100644 index a63e472255..0000000000 --- a/.github/workflows/xls-modules.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "module": [ - { - "xls_module": "//xls/modules/dma", - "rule_ir": "csr_opt_ir_benchmark", - "rule_verilog": "verilog_csr", - "rule_synthesis": "csr_benchmark_synth", - "rule_pnr": "csr_place_and_route" - }, - { - "xls_module": "//xls/modules/dma", - "rule_ir": "axi_csr_opt_ir_benchmark", - "rule_verilog": "verilog_axi_csr", - "rule_synthesis": "axi_csr_benchmark_synth", - "rule_pnr": "axi_csr_place_and_route" - }, - { - "xls_module": "//xls/modules/dma", - "rule_ir": "address_generator_opt_ir_benchmark", - "rule_verilog": "verilog_address_generator", - "rule_synthesis": "address_generator_benchmark_synth", - "rule_pnr": "address_generator_place_and_route" - }, - { - "xls_module": "//xls/modules/dma", - "rule_ir": "frontend_reader_opt_ir_benchmark", - "rule_verilog": "verilog_frontend_reader", - "rule_synthesis": "frontend_reader_benchmark_synth", - "rule_pnr": "frontend_reader_place_and_route" - }, - { - "xls_module": "//xls/modules/dma", - "rule_ir": "frontend_writer_opt_ir_benchmark", - "rule_verilog": "verilog_frontend_writer", - "rule_synthesis": "frontend_writer_benchmark_synth", - "rule_pnr": "frontend_writer_place_and_route" - } - ] -} diff --git a/.github/workflows/xls-modules.yml b/.github/workflows/xls-modules.yml index 872bd78704..808ff7d19d 100644 --- a/.github/workflows/xls-modules.yml +++ b/.github/workflows/xls-modules.yml @@ -93,11 +93,6 @@ jobs: sudo apt install jq echo "json_config=$(jq -c . .github/workflows/xls-modules.json)" | tee -a "$GITHUB_ENV" - - name: Validate json - id: validate-json - run: | - python .github/scripts/validate_json.py - implement: needs: config-matrix name: Implementation @@ -129,15 +124,44 @@ jobs: key: ${{env.CACHE_KEY}} restore-keys: ${{env.CACHE_RESTORE_KEY}} - # - name: Implement CSR - # id: implementation - # uses: ./.github/actions/implementation - # with: - # xls_module: ${{ matrix.module.xls_module }} - # rule_ir: ${{ matrix.module.rule_ir }} - # rule_verilog: ${{ matrix.module.rule_verilog }} - # rule_synthesis: ${{ matrix.module.rule_synthesis }} - # rule_pnr: ${{ matrix.module.rule_pnr }} + - name: IR + run: | + bazel run ${{ env.BAZEL_RESOURCES_OPT }} -- ${{env.XLS_MODULE}}:${{ matrix.dma.rules.ir }} + + - name: Verilog + run: | + bazel build ${{ env.BAZEL_RESOURCES_OPT }} -- ${{env.XLS_MODULE}}:${{ matrix.module.verilog }} + + - name: Synthesis + run: | + bazel run ${{ env.BAZEL_RESOURCES_OPT }} -- ${{env.XLS_MODULE}}:${{ matrix.module.synthesis }} + + - name: P&R + run: | + bazel build ${{ env.BAZEL_RESOURCES_OPT }} -- ${{env.XLS_MODULE}}:${{ matrix.module.pnr }} + + # ${variable/character_to_replace/new_character} + # ${variable/ slash / underscore } + - name: Prepare artifact name + if: always() + shell: bash + run: | + name_input=${{env.XLS_MODULE}}/${{ matrix.module.rule_ir }} + name_output="${name_input//\//_}" + echo "artifact_name=${name_output}" >> "$GITHUB_ENV" + + - name: Artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: artifacts-impl-${{ env.artifact_name }} + path: | + ./bazel-bin/${{env.XLS_MODULE}}/*.log + ./bazel-bin/${{env.XLS_MODULE}}/*.textproto + ./bazel-bin/${{env.XLS_MODULE}}/*.ir + ./bazel-bin/${{env.XLS_MODULE}}/*.v + ./bazel-bin/${{env.XLS_MODULE}}/*.sv + test: needs: build