From 6bdf36d59234f377829468b97a712b854110e66d Mon Sep 17 00:00:00 2001 From: Hasan Genc Date: Sat, 26 Nov 2022 09:39:26 -0800 Subject: [PATCH] updates to ci --- .github/scripts/build-toolchains.sh | 35 --------- .github/scripts/defaults.sh | 2 + .github/scripts/do-rtl-build.sh | 31 +++++--- .github/scripts/enable-conda.sh | 13 ++++ .github/scripts/install-gemmini.sh | 42 +++++++++++ .github/scripts/install-verilator.sh | 20 ----- .github/scripts/prepare-for-rtl-build.sh | 23 ------ .github/scripts/remove-chipyard.sh | 10 +++ .github/scripts/run-tests-rtl.sh | 6 +- .github/scripts/run-tests-spike.sh | 24 +++--- .github/workflows/config.yml | 96 +++++++++--------------- 11 files changed, 138 insertions(+), 164 deletions(-) delete mode 100755 .github/scripts/build-toolchains.sh create mode 100644 .github/scripts/enable-conda.sh create mode 100755 .github/scripts/install-gemmini.sh delete mode 100755 .github/scripts/install-verilator.sh delete mode 100755 .github/scripts/prepare-for-rtl-build.sh create mode 100755 .github/scripts/remove-chipyard.sh diff --git a/.github/scripts/build-toolchains.sh b/.github/scripts/build-toolchains.sh deleted file mode 100755 index b23d854e..00000000 --- a/.github/scripts/build-toolchains.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -#------------------------------------------------------------- -# create the riscv tools binaries from ucb-bar/chipyard with rocket-chip hash given by riscv-boom -# -# run location: circle ci docker image -# usage: -# $1 - name of the toolchain to build -#------------------------------------------------------------- - -# turn echo on and error on earliest command -set -ex - -# get shared variables -SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" -source $SCRIPT_DIR/defaults.sh - -INSTALL_DIR="$HOME/$1-install" - -if [ ! -d "$INSTALL_DIR" ]; then - cd $HOME - - git clone --progress --verbose https://github.com/ucb-bar/chipyard.git chipyard - cd $LOCAL_CHIPYARD_DIR - - echo "Checking out Chipyard version: $(cat $LOCAL_CHECKOUT_DIR/CHIPYARD.hash)" - git fetch - git checkout $(cat $LOCAL_CHECKOUT_DIR/CHIPYARD.hash) - - cd $HOME - - # init all submodules including the tools (doesn't use CI_MAKE_PROC due to mem. constraints) - CHIPYARD_DIR="$LOCAL_CHIPYARD_DIR" NPROC=$CI_MAKE_NPROC $LOCAL_CHIPYARD_DIR/build-setup.sh --skip-conda esp-tools -fi - diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index 6a02a220..e403fc89 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -28,6 +28,7 @@ LOCAL_ESP_DIR=$HOME/esp-tools-install LOCAL_CHIPYARD_DIR=$HOME/chipyard LOCAL_SIM_DIR=$LOCAL_CHIPYARD_DIR/sims/verilator LOCAL_VERILATOR_DIR=$HOME/verilator-install +LOCAL_CONDA=/opt/conda/ echo "::set-output name=LOCAL_WORK_DIR::$LOCAL_WORK_DIR" echo "::set-output name=LOCAL_CHECKOUT_DIR::$LOCAL_CHECKOUT_DIR" @@ -36,3 +37,4 @@ echo "::set-output name=LOCAL_ESP_DIR::$LOCAL_ESP_DIR" echo "::set-output name=LOCAL_CHIPYARD_DIR::$LOCAL_CHIPYARD_DIR" echo "::set-output name=LOCAL_SIM_DIR::$LOCAL_SIM_DIR" echo "::set-output name=LOCAL_VERILATOR_DIR::$LOCAL_VERILATOR_DIR" +echo "::set-output name=LOCAL_CONDA::$LOCAL_CONDA" diff --git a/.github/scripts/do-rtl-build.sh b/.github/scripts/do-rtl-build.sh index 1b93655e..102aaa60 100755 --- a/.github/scripts/do-rtl-build.sh +++ b/.github/scripts/do-rtl-build.sh @@ -7,20 +7,27 @@ set -ex SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" source $SCRIPT_DIR/defaults.sh -rm -rf $LOCAL_CHIPYARD_DIR/generators/gemmini/* -cd $LOCAL_CHECKOUT_DIR -git submodule update --init --recursive software/gemmini-rocc-tests -mv -f $LOCAL_CHECKOUT_DIR/* $LOCAL_CHIPYARD_DIR/generators/gemmini/ +source $SCRIPT_DIR/enable-conda.sh +cd $LOCAL_CHIPYARD_DIR +source env.sh -TOOLS_DIR=$LOCAL_ESP_DIR -LD_LIB_DIR=$LOCAL_ESP_DIR/lib +cd $LOCAL_CHIPYARD_DIR +echo Printing current chipyard commit +git log -1 --format="%H" -# enter the verilator directory and build the specific config on remote server +cd $LOCAL_CHIPYARD_DIR/generators/gemmini +echo Printing current gemmini commit +git log -1 --format="%H" + +cd $LOCAL_CHIPYARD_DIR/generators/rocket-chip +echo Printing rocket-chip commit +git log -1 --format="%H" + +echo Printing rocket-chip sources +ls src/main/scala/ + +cd $LOCAL_SIM_DIR make -C $LOCAL_SIM_DIR clean -export RISCV=$TOOLS_DIR -export LD_LIBRARY_PATH=$LD_LIB_DIR -export PATH=$LOCAL_VERILATOR_DIR/bin:$PATH -export VERILATOR_ROOT=$LOCAL_VERILATOR_DIR -export COURSIER_CACHE=$LOCAL_WORK_DIR/.coursier-cache make -j$LOCAL_MAKE_NPROC -C $LOCAL_SIM_DIR VERILATOR_OPT_FLAGS="-O0 -OG" JAVA_OPTS="-Xmx2500M -Xss8M" SBT_OPTS="-Dsbt.ivy.home=$LOCAL_CHIPYARD_DIR/.ivy2 -Dsbt.supershell=false -Dsbt.global.base=$LOCAL_CHIPYARD_DIR/.sbt -Dsbt.boot.directory=$LOCAL_CHIPYARD_DIR/.sbt/boot" CONFIG=GemminiRocketConfig + diff --git a/.github/scripts/enable-conda.sh b/.github/scripts/enable-conda.sh new file mode 100644 index 00000000..184ead9b --- /dev/null +++ b/.github/scripts/enable-conda.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +export PATH="$LOCAL_CONDA/bin:$PATH" +conda init +source ~/.bashrc +conda activate base +if ! { conda env list | grep 'chipyard'; } >/dev/null 2>&1; then + conda create -n chipyard + conda activate chipyard + conda install -c conda-forge conda-lock +fi +conda activate chipyard + diff --git a/.github/scripts/install-gemmini.sh b/.github/scripts/install-gemmini.sh new file mode 100755 index 00000000..8a2ef5cd --- /dev/null +++ b/.github/scripts/install-gemmini.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +#------------------------------------------------------------- +# installs gemmini +# +# run location: circle ci docker image +#------------------------------------------------------------- + +# turn echo on and error on earliest command +set -ex + +# get shared variables +SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +source $SCRIPT_DIR/defaults.sh + +source $SCRIPT_DIR/enable-conda.sh + +cd $HOME +rm -rf chipyard +git clone --progress --verbose https://github.com/ucb-bar/chipyard.git chipyard +cd $LOCAL_CHIPYARD_DIR + +echo "Checking out Chipyard version: $(cat $LOCAL_CHECKOUT_DIR/CHIPYARD.hash)" +git fetch +git checkout $(cat $LOCAL_CHECKOUT_DIR/CHIPYARD.hash) + +./build-setup.sh esp-tools + +source env.sh + +cd toolchains/esp-tools/riscv-isa-sim/build +echo "Checking out Spike version $(cat $LOCAL_CHECKOUT_DIR/SPIKE.hash)" +git checkout $(cat $LOCAL_CHECKOUT_DIR/SPIKE.hash) +make && make install + +cd $LOCAL_CHECKOUT_DIR +chown -R $(whoami) . +git config --global --add safe.directory $LOCAL_CHECKOUT_DIR +git submodule update --init --recursive software/gemmini-rocc-tests +rm -rf $LOCAL_CHIPYARD_DIR/generators/gemmini/* $LOCAL_CHIPYARD_DIR/generators/gemmini/.git* +mv -f $LOCAL_CHECKOUT_DIR/* $LOCAL_CHECKOUT_DIR/.git* $LOCAL_CHIPYARD_DIR/generators/gemmini/ + diff --git a/.github/scripts/install-verilator.sh b/.github/scripts/install-verilator.sh deleted file mode 100755 index b996b4d0..00000000 --- a/.github/scripts/install-verilator.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# move verilator to the remote server - -# turn echo on and error on earliest command -set -ex - -# get shared variables -SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" -source $SCRIPT_DIR/defaults.sh - -if [ ! -d "$LOCAL_VERILATOR_DIR" ]; then - git clone http://git.veripool.org/git/verilator $LOCAL_VERILATOR_DIR - cd $LOCAL_VERILATOR_DIR - git checkout $VERILATOR_VERSION - autoconf - export VERILATOR_ROOT=$LOCAL_VERILATOR_DIR - ./configure - make -j$LOCAL_MAKE_NPROC -fi diff --git a/.github/scripts/prepare-for-rtl-build.sh b/.github/scripts/prepare-for-rtl-build.sh deleted file mode 100755 index df3ac470..00000000 --- a/.github/scripts/prepare-for-rtl-build.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# turn echo on and error on earliest command -set -ex - -# get shared variables -SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" -source $SCRIPT_DIR/defaults.sh - -# check to see if both dirs exist -if [ ! -d "$LOCAL_CHIPYARD_DIR" ]; then - cd $HOME - - git clone --progress --verbose https://github.com/ucb-bar/chipyard.git chipyard - cd $LOCAL_CHIPYARD_DIR - - echo "Checking out Chipyard version: $(cat $LOCAL_CHECKOUT_DIR/CHIPYARD.hash)" - git fetch - git checkout $(cat $LOCAL_CHECKOUT_DIR/CHIPYARD.hash) - - # init all submodules (according to what chipyard wants) - ./scripts/init-submodules-no-riscv-tools.sh -fi diff --git a/.github/scripts/remove-chipyard.sh b/.github/scripts/remove-chipyard.sh new file mode 100755 index 00000000..8b82019e --- /dev/null +++ b/.github/scripts/remove-chipyard.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -ex + +SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +source $SCRIPT_DIR/defaults.sh + +rm -rf $LOCAL_CHIPYARD_DIR +rm -rf $LOCAL_CONDA + diff --git a/.github/scripts/run-tests-rtl.sh b/.github/scripts/run-tests-rtl.sh index c5907ddd..47a87ff1 100755 --- a/.github/scripts/run-tests-rtl.sh +++ b/.github/scripts/run-tests-rtl.sh @@ -5,9 +5,10 @@ set -ex SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" source $SCRIPT_DIR/defaults.sh +source $SCRIPT_DIR/enable-conda.sh -TOOLS_DIR=$LOCAL_ESP_DIR -PATH=$PATH:$LOCAL_ESP_DIR/bin +cd $LOCAL_CHIPYARD_DIR +source env.sh cd $LOCAL_CHIPYARD_DIR/generators/gemmini/software/gemmini-rocc-tests CFLAGS=-DFAST ./build.sh @@ -15,4 +16,3 @@ CFLAGS=-DFAST ./build.sh cd build make test-baremetal-bareMetalC RUNNER="'make -C $LOCAL_CHIPYARD_DIR/sims/verilator/ CONFIG=GemminiRocketConfig run-binary-hex BINARY='" - diff --git a/.github/scripts/run-tests-spike.sh b/.github/scripts/run-tests-spike.sh index 9f933aaf..c6dbf850 100755 --- a/.github/scripts/run-tests-spike.sh +++ b/.github/scripts/run-tests-spike.sh @@ -5,23 +5,25 @@ set -ex SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" source $SCRIPT_DIR/defaults.sh +source $SCRIPT_DIR/enable-conda.sh -# clone and build our version of spike -TOOLS_DIR=$LOCAL_ESP_DIR -PATH=$PATH:$LOCAL_ESP_DIR/bin +cd $LOCAL_CHIPYARD_DIR +source env.sh -git clone https://github.com/ucb-bar/esp-isa-sim.git -cd esp-isa-sim -git checkout $(cat $LOCAL_CHECKOUT_DIR/SPIKE.hash) -cp $LOCAL_CHIPYARD_DIR/generators/gemmini/software/gemmini-rocc-tests/include/gemmini_params.h gemmini/ +cd $LOCAL_CHIPYARD_DIR/toolchains/esp-tools/riscv-isa-sim +echo Printing current spike commit +git log -1 --format="%H" -mkdir build -cd build -../configure --prefix=$TOOLS_DIR -make -j8 install +cd $LOCAL_CHIPYARD_DIR/generators/gemmini +echo Printing current gemmini commit +git log -1 --format="%H" cd $LOCAL_CHIPYARD_DIR/generators/gemmini/software/gemmini-rocc-tests +echo Printing current gemmini-rocc-tests commit +git log -1 --format="%H" + ./build.sh cd build make test-baremetal + diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 2a092e8d..f4a2dfda 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -1,11 +1,11 @@ name: Gemmini CI on: [push] jobs: - install-esp-toolchain: - name: install-esp-toolchain + install-gemmini: + name: gemmini-install runs-on: ubuntu-latest container: - image: ucbbar/chipyard-ci-image:554b436 + image: ucbbar/chipyard-ci-image:3f9150 options: --entrypoint /bin/bash steps: - name: checkout @@ -14,47 +14,23 @@ jobs: run: .github/scripts/defaults.sh id: get-paths - - name: toolchain-build - run: .github/scripts/build-toolchains.sh esp-tools + - name: install gemmini + run: .github/scripts/install-gemmini.sh - - name: cache esp-toolchain install - uses: actions/cache@v2 - with: - path: ${{ steps.get-paths.outputs.LOCAL_ESP_DIR }} - key: esp-tools-install-${{ github.ref }}-${{ github.sha }} - - prepare-build-environment: - name: prepare-build-environment - runs-on: ubuntu-latest - container: - image: ucbbar/chipyard-ci-image:554b436 - options: --entrypoint /bin/bash - steps: - - name: checkout - uses: actions/checkout@v2 - - name: get paths - run: .github/scripts/defaults.sh - id: get-paths - - - name: setup build environment - run: .github/scripts/prepare-for-rtl-build.sh - - name: install verilator - run: .github/scripts/install-verilator.sh - - - name: cache prepare-build-environment install + - name: cache gemmini install uses: actions/cache@v2 with: path: | ${{ steps.get-paths.outputs.LOCAL_CHIPYARD_DIR }} - ${{ steps.get-paths.outputs.LOCAL_VERILATOR_DIR }} - key: prepare-build-environment-${{ github.ref }}-${{ github.sha }} + ${{ steps.get-paths.outputs.LOCAL_CONDA }} + key: gemmini-install-${{ github.ref }}-${{ github.sha }} - prepare-gemmini-config: - name: prepare-gemmini-config + build-gemmini-config: + name: build-gemmini-config runs-on: self-hosted - needs: [prepare-build-environment, install-esp-toolchain] + needs: install-gemmini container: - image: ucbbar/chipyard-ci-image:554b436 + image: ucbbar/chipyard-ci-image:3f9150 options: --entrypoint /bin/bash steps: - name: checkout @@ -63,38 +39,34 @@ jobs: run: .github/scripts/defaults.sh id: get-paths - - name: restore cache esp-toolchain install - uses: actions/cache@v2 - with: - path: ${{ steps.get-paths.outputs.LOCAL_ESP_DIR }} - key: esp-tools-install-${{ github.ref }}-${{ github.sha }} + - name: remove chipyard + run: .github/scripts/remove-chipyard.sh - - name: restore cache prepare-build-environment install + - name: restore cache gemmini install uses: actions/cache@v2 with: path: | ${{ steps.get-paths.outputs.LOCAL_CHIPYARD_DIR }} - ${{ steps.get-paths.outputs.LOCAL_VERILATOR_DIR }} - key: prepare-build-environment-${{ github.ref }}-${{ github.sha }} + ${{ steps.get-paths.outputs.LOCAL_CONDA }} + key: gemmini-install-${{ github.ref }}-${{ github.sha }} - name: Building Gemmini Config using Verilator run: .github/scripts/do-rtl-build.sh - - name: cache prepare-gemmini-config install + - name: cache build-gemmini-config install uses: actions/cache@v2 with: path: | ${{ steps.get-paths.outputs.LOCAL_CHIPYARD_DIR }} - ${{ steps.get-paths.outputs.LOCAL_VERILATOR_DIR }} - ${{ steps.get-paths.outputs.LOCAL_ESP_DIR }} - key: prepare-gemmini-config-${{ github.ref }}-${{ github.sha }} + ${{ steps.get-paths.outputs.LOCAL_CONDA }} + key: build-gemmini-config-${{ github.ref }}-${{ github.sha }} spike-run-tests: name: spike-run-tests runs-on: ubuntu-latest - needs: prepare-gemmini-config + needs: install-gemmini container: - image: ucbbar/chipyard-ci-image:554b436 + image: ucbbar/chipyard-ci-image:3f9150 options: --entrypoint /bin/bash steps: - name: checkout @@ -103,14 +75,16 @@ jobs: run: .github/scripts/defaults.sh id: get-paths - - name: restore cache prepare-gemmini-config install + - name: remove chipyard + run: .github/scripts/remove-chipyard.sh + + - name: restore cache gemmini install uses: actions/cache@v2 with: path: | ${{ steps.get-paths.outputs.LOCAL_CHIPYARD_DIR }} - ${{ steps.get-paths.outputs.LOCAL_VERILATOR_DIR }} - ${{ steps.get-paths.outputs.LOCAL_ESP_DIR }} - key: prepare-gemmini-config-${{ github.ref }}-${{ github.sha }} + ${{ steps.get-paths.outputs.LOCAL_CONDA }} + key: gemmini-install-${{ github.ref }}-${{ github.sha }} - name: run-tests run: .github/scripts/run-tests-spike.sh @@ -118,9 +92,9 @@ jobs: rtl-run-tests: name: rtl-run-tests runs-on: ubuntu-latest - needs: prepare-gemmini-config + needs: build-gemmini-config container: - image: ucbbar/chipyard-ci-image:554b436 + image: ucbbar/chipyard-ci-image:3f9150 options: --entrypoint /bin/bash steps: - name: checkout @@ -129,14 +103,16 @@ jobs: run: .github/scripts/defaults.sh id: get-paths - - name: restore cache prepare-gemmini-config install + - name: remove chipyard + run: .github/scripts/remove-chipyard.sh + + - name: restore cache build-gemmini-config install uses: actions/cache@v2 with: path: | ${{ steps.get-paths.outputs.LOCAL_CHIPYARD_DIR }} - ${{ steps.get-paths.outputs.LOCAL_VERILATOR_DIR }} - ${{ steps.get-paths.outputs.LOCAL_ESP_DIR }} - key: prepare-gemmini-config-${{ github.ref }}-${{ github.sha }} + ${{ steps.get-paths.outputs.LOCAL_CONDA }} + key: build-gemmini-config-${{ github.ref }}-${{ github.sha }} - name: run-tests run: .github/scripts/run-tests-rtl.sh