From e113d8dc3f1ccb3a19839975b3a823804695c69a Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Fri, 20 Oct 2023 11:26:29 -0700 Subject: [PATCH 01/12] Add EXTRA_SIM_PREPROC_DEFINES to common-sims-flags.mk This allows adding e.g. EXTRA_SIM_PREPROC_DEFINES="+define+NUM_CORES=2" to the make command to change Vortex Verilog parameters. --- sims/common-sim-flags.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sims/common-sim-flags.mk b/sims/common-sim-flags.mk index c2ae022c..2b56e989 100644 --- a/sims/common-sim-flags.mk +++ b/sims/common-sim-flags.mk @@ -46,4 +46,5 @@ SIM_PREPROC_DEFINES = \ +define+RANDOMIZE_MEM_INIT \ +define+RANDOMIZE_REG_INIT \ +define+RANDOMIZE_GARBAGE_ASSIGN \ - +define+RANDOMIZE_INVALID_ASSIGN + +define+RANDOMIZE_INVALID_ASSIGN \ + $(EXTRA_SIM_PREPROC_DEFINES) From c35a1121dae272f0977c0d54e14bdd13d9305ee8 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Sun, 22 Oct 2023 14:59:38 -0700 Subject: [PATCH 02/12] [ci] Test CI with different REMOTE_CHIPYARD_DIR than local --- .github/actions/prepare-gpu/action.yml | 1 + .github/scripts/defaults.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/prepare-gpu/action.yml b/.github/actions/prepare-gpu/action.yml index 050e4657..7abca2ba 100644 --- a/.github/actions/prepare-gpu/action.yml +++ b/.github/actions/prepare-gpu/action.yml @@ -20,6 +20,7 @@ runs: - name: Init submodules to ensure stimuli is located run: | conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-${{ inputs.toolchain }} + cd $REMOTE_CHIPYARD_DIR ./scripts/init-submodules-no-riscv-tools.sh --force shell: bash -leo pipefail {0} diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index a5f7f62e..b723cd13 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -9,8 +9,8 @@ REMOTE_MAKE_NPROC=4 # CI_DIR is defined externally based on the GH repository secret BUILDDIR REMOTE_PREFIX=$CI_DIR/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME//\//-} -REMOTE_WORK_DIR=$GITHUB_WORKSPACE -REMOTE_CHIPYARD_DIR=$GITHUB_WORKSPACE +REMOTE_WORK_DIR=$REMOTE_PREFIX/$GITHUB_WORKSPACE +REMOTE_CHIPYARD_DIR=$REMOTE_PREFIX/$GITHUB_WORKSPACE REMOTE_SIM_DIR=$REMOTE_CHIPYARD_DIR/sims/verilator REMOTE_FIRESIM_DIR=$REMOTE_CHIPYARD_DIR/sims/firesim/sim REMOTE_FPGA_DIR=$REMOTE_CHIPYARD_DIR/fpga From e8586a1d039867aed466296896c14d05feed350d Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Sun, 22 Oct 2023 15:45:11 -0700 Subject: [PATCH 03/12] [ci] Don't overwrite REMOTE_WORK_DIR in default.sh --- .github/actions/prepare-gpu/action.yml | 1 + .github/scripts/defaults.sh | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/prepare-gpu/action.yml b/.github/actions/prepare-gpu/action.yml index 7abca2ba..40a7e5b8 100644 --- a/.github/actions/prepare-gpu/action.yml +++ b/.github/actions/prepare-gpu/action.yml @@ -21,6 +21,7 @@ runs: run: | conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-${{ inputs.toolchain }} cd $REMOTE_CHIPYARD_DIR + echo $PWD ./scripts/init-submodules-no-riscv-tools.sh --force shell: bash -leo pipefail {0} diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index b723cd13..abdcdef5 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -9,8 +9,9 @@ REMOTE_MAKE_NPROC=4 # CI_DIR is defined externally based on the GH repository secret BUILDDIR REMOTE_PREFIX=$CI_DIR/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME//\//-} -REMOTE_WORK_DIR=$REMOTE_PREFIX/$GITHUB_WORKSPACE -REMOTE_CHIPYARD_DIR=$REMOTE_PREFIX/$GITHUB_WORKSPACE +# Use env.REMOTE_WORK_DIR set in workflow file +# REMOTE_WORK_DIR=$REMOTE_PREFIX/$GITHUB_WORKSPACE +REMOTE_CHIPYARD_DIR=$REMOTE_WORK_DIR REMOTE_SIM_DIR=$REMOTE_CHIPYARD_DIR/sims/verilator REMOTE_FIRESIM_DIR=$REMOTE_CHIPYARD_DIR/sims/firesim/sim REMOTE_FPGA_DIR=$REMOTE_CHIPYARD_DIR/fpga From 0fb28faaa5b84d954362027df8f9d81a585d06a1 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Sun, 22 Oct 2023 15:45:48 -0700 Subject: [PATCH 04/12] [ci] Add chipyard-gpu-flow based off of chipyard-full-flow This is supposed to be a much more minimal workflow. --- .github/workflows/chipyard-gpu-flow.yml | 112 ++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/chipyard-gpu-flow.yml diff --git a/.github/workflows/chipyard-gpu-flow.yml b/.github/workflows/chipyard-gpu-flow.yml new file mode 100644 index 00000000..4b776b92 --- /dev/null +++ b/.github/workflows/chipyard-gpu-flow.yml @@ -0,0 +1,112 @@ +name: chipyard-ci-full-flow + +on: + push: + branches: + - graphics + +defaults: + run: + shell: bash -leo pipefail {0} + +env: + REMOTE_WORK_DIR: ${{ secrets.BUILDDIR }}/cy-ci-shared/cy-${{ github.sha }} + JAVA_TMP_DIR: /tmp/cy-${{ github.sha }}-full + MAKEFLAGS: "-j32" + +jobs: + cancel-prior-workflows: + name: cancel-prior-workflows + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} + + # Set up a set of boolean conditions to control which branches of the CI + # workflow will execute This is based off the conditional job execution + # example here: https://github.com/dorny/paths-filter#examples + change-filters: + name: filter-jobs-on-changes + runs-on: ubuntu-latest + # Queried by downstream jobs to determine if they should run. + outputs: + needs-rtl: ${{ steps.filter.outputs.all_count != steps.filter.outputs.skip-rtl_count }} + + steps: + - uses: actions/checkout@v3 + - name: Git workaround + uses: ./.github/actions/git-workaround + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + all: + - '**' + + # If any of the files changed match, do a doc build + docs: &docs-filter + - 'docs/**' + - '.readthedocs.yml' + + # If all files match to this filter, skip the main ci pipeline + skip-rtl: + - *docs-filter + - '**/*.md' + - '**/.gitignore' + - '.github/ISSUE_TEMPLATE/**' + + setup-repo: + name: setup-repo + needs: [change-filters, cancel-prior-workflows] + if: needs.change-filters.outputs.needs-rtl == 'true' + runs-on: self-hosted + steps: + - name: Delete old checkout + run: | + ls -alh . + rm -rf ${{ github.workspace }}/* || true + rm -rf ${{ github.workspace }}/.* || true + ls -alh . + - uses: actions/checkout@v3 + - name: Setup repo copy + run: | + git clone $GITHUB_WORKSPACE ${{ env.REMOTE_WORK_DIR }} + - name: Setup repo + run: | + cd ${{ env.REMOTE_WORK_DIR }} + mkdir ${{ env.JAVA_TMP_DIR }} + ./build-setup.sh -f -v + + run-coalescer: + name: run-coalescer + needs: [setup-repo] + runs-on: self-hosted + steps: + - name: Build RTL + run: | + cd ${{ env.REMOTE_WORK_DIR }} + eval "$(conda shell.bash hook)" + source env.sh + cd sims/verilator + make verilog CONFIG=MemtraceCoreConfig + - name: Run RTL sim + run: | + cd ${{ env.REMOTE_WORK_DIR }} + eval "$(conda shell.bash hook)" + source env.sh + cd sims/verilator + make run-binary run_binary CONFIG=MemtraceCoreConfig BINARY=none EXTRA_SIM_FLAGS="+memtracefile=$LOCAL_CHIPYARD_DIR/generators/rocket-gpu/tracefiles/vecadd.core1.thread4.trace" + + + cleanup: + name: cleanup + needs: [run-coalescer] + runs-on: self-hosted + if: ${{ always() }} + steps: + - name: Delete repo copy and conda env + run: | + rm -rf ${{ env.REMOTE_WORK_DIR }} + rm -rf ${{ env.JAVA_TMP_DIR }} From 757b5d7d32acc9b4141f53eb8c7f3b6e45b6ca34 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Sun, 22 Oct 2023 19:43:36 -0700 Subject: [PATCH 05/12] [ci] Add ssh key in chipyard-gpu-flow --- .github/workflows/chipyard-gpu-flow.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/chipyard-gpu-flow.yml b/.github/workflows/chipyard-gpu-flow.yml index 4b776b92..210ef42a 100644 --- a/.github/workflows/chipyard-gpu-flow.yml +++ b/.github/workflows/chipyard-gpu-flow.yml @@ -12,6 +12,7 @@ defaults: env: REMOTE_WORK_DIR: ${{ secrets.BUILDDIR }}/cy-ci-shared/cy-${{ github.sha }} JAVA_TMP_DIR: /tmp/cy-${{ github.sha }}-full + SSH_AUTH_SOCK: /tmp/ssh_agent_github.sock MAKEFLAGS: "-j32" jobs: @@ -69,6 +70,12 @@ jobs: rm -rf ${{ github.workspace }}/* || true rm -rf ${{ github.workspace }}/.* || true ls -alh . + # note: the agent spun up here will be made available throughout the + # workflow via env.SSH_AUTH_SOCK. + - name: Run ssh-agent + run: | + eval `ssh-agent -a $SSH_AUTH_SOCK -s` + echo "${{ secrets.PRIVATE_SSH_KEY }}" | ssh-add - - uses: actions/checkout@v3 - name: Setup repo copy run: | From 8226e4f6f77e16bb94e1240b96200e4b853a0fd7 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Sun, 22 Oct 2023 20:58:20 -0700 Subject: [PATCH 06/12] [ci] Add remote repo copy step; put REMOTE_WORK_DIR in env --- .github/workflows/chipyard-run-tests-gpu.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/chipyard-run-tests-gpu.yml b/.github/workflows/chipyard-run-tests-gpu.yml index 55970939..a5c3ea03 100644 --- a/.github/workflows/chipyard-run-tests-gpu.yml +++ b/.github/workflows/chipyard-run-tests-gpu.yml @@ -12,6 +12,7 @@ defaults: env: tools-cache-version: v17 CI_DIR: ${{ secrets.BUILDDIR }} + REMOTE_WORK_DIR: ${{ secrets.BUILDDIR }}/cy-ci-shared/cy-${{ github.sha }} JVM_OPTS: -Xmx3200m # Customize the JVM maximum heap limit conda-env-name-no-time: cy-${{ github.run_id }} workflow-timestamp: ${{ github.event.pull_request.updated_at }} @@ -88,12 +89,29 @@ jobs: - name: Create conda env uses: ./.github/actions/create-conda-env + setup-repo: + name: setup-repo + needs: create-conda-env + if: needs.change-filters.outputs.needs-rtl == 'true' + runs-on: self-hosted + steps: + - name: Delete old checkout + run: | + ls -alh . + rm -rf ${{ github.workspace }}/* || true + rm -rf ${{ github.workspace }}/.* || true + ls -alh . + - uses: actions/checkout@v3 + - name: Setup repo copy + run: | + git clone $GITHUB_WORKSPACE ${{ env.REMOTE_WORK_DIR }} + # Sentinel job to simplify how we specify which that basic setup is complete # # When adding new prep jobs, please add them to `needs` below setup-complete: name: setup-complete - needs: [create-conda-env] + needs: setup-repo runs-on: self-hosted steps: - name: Set up complete From e3132398ba4dbea8675bec808552cc9f88f30a11 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Sun, 22 Oct 2023 21:36:26 -0700 Subject: [PATCH 07/12] [ci] Fix access to REMOTE_CHIPYARD_DIR --- .github/actions/prepare-gpu/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/prepare-gpu/action.yml b/.github/actions/prepare-gpu/action.yml index 40a7e5b8..a7d4ff38 100644 --- a/.github/actions/prepare-gpu/action.yml +++ b/.github/actions/prepare-gpu/action.yml @@ -20,7 +20,7 @@ runs: - name: Init submodules to ensure stimuli is located run: | conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-${{ inputs.toolchain }} - cd $REMOTE_CHIPYARD_DIR + cd ${{ env.REMOTE_WORK_DIR }} echo $PWD ./scripts/init-submodules-no-riscv-tools.sh --force shell: bash -leo pipefail {0} From a0e0a45a89d6928cd853e7639a0cd06a3e5d801c Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Mon, 23 Oct 2023 00:02:01 -0700 Subject: [PATCH 08/12] [ci] Experiment with working-directory --- .github/actions/prepare-rtl/action.yml | 1 + .github/workflows/chipyard-run-tests-gpu.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/actions/prepare-rtl/action.yml b/.github/actions/prepare-rtl/action.yml index b4abde09..478f0241 100644 --- a/.github/actions/prepare-rtl/action.yml +++ b/.github/actions/prepare-rtl/action.yml @@ -36,6 +36,7 @@ runs: conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-${{ inputs.toolchain }} if [[ "${{ steps.rtl-build-id.outputs.cache-hit }}" != 'true' ]]; then echo "Cache miss on ${{ inputs.group-key }}-${{ github.sha }}" + echo "Cache miss happened in: $PWD" ./.github/scripts/${{ inputs.build-script }} ${{ inputs.group-key }} ${{ inputs.build-type }} else echo "Cache hit do not rebuild RTL for ${{ inputs.group-key }}" diff --git a/.github/workflows/chipyard-run-tests-gpu.yml b/.github/workflows/chipyard-run-tests-gpu.yml index a5c3ea03..30e1687c 100644 --- a/.github/workflows/chipyard-run-tests-gpu.yml +++ b/.github/workflows/chipyard-run-tests-gpu.yml @@ -161,6 +161,7 @@ jobs: - name: Prepare GPU binaries uses: ./.github/actions/prepare-gpu - name: Build RTL on self-hosted + working-directory: ${{ env.REMOTE_WORK_DIR }} uses: ./.github/actions/prepare-rtl with: group-key: "group-gpu" From 2ef343e75d61ab62f29531c7e802ea601a059404 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Mon, 23 Oct 2023 00:04:58 -0700 Subject: [PATCH 09/12] [ci] Attempt cd'ing in a step --- .github/actions/prepare-rtl/action.yml | 4 ++++ .github/workflows/chipyard-run-tests-gpu.yml | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/actions/prepare-rtl/action.yml b/.github/actions/prepare-rtl/action.yml index 478f0241..1a3463e8 100644 --- a/.github/actions/prepare-rtl/action.yml +++ b/.github/actions/prepare-rtl/action.yml @@ -21,6 +21,10 @@ inputs: runs: using: "composite" steps: + - name: cd into remote + run: | + cd "${{ env.REMOTE_WORK_DIR }}" + - uses: actions/cache@v3 id: rtl-build-id with: diff --git a/.github/workflows/chipyard-run-tests-gpu.yml b/.github/workflows/chipyard-run-tests-gpu.yml index 30e1687c..a5c3ea03 100644 --- a/.github/workflows/chipyard-run-tests-gpu.yml +++ b/.github/workflows/chipyard-run-tests-gpu.yml @@ -161,7 +161,6 @@ jobs: - name: Prepare GPU binaries uses: ./.github/actions/prepare-gpu - name: Build RTL on self-hosted - working-directory: ${{ env.REMOTE_WORK_DIR }} uses: ./.github/actions/prepare-rtl with: group-key: "group-gpu" From eb1741ade95544d9c6fe170d97d1130ed759fa57 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Mon, 23 Oct 2023 09:02:12 -0700 Subject: [PATCH 10/12] [ci] Add missing shell: --- .github/actions/prepare-rtl/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/prepare-rtl/action.yml b/.github/actions/prepare-rtl/action.yml index 1a3463e8..bbd8d56f 100644 --- a/.github/actions/prepare-rtl/action.yml +++ b/.github/actions/prepare-rtl/action.yml @@ -24,6 +24,7 @@ runs: - name: cd into remote run: | cd "${{ env.REMOTE_WORK_DIR }}" + shell: bash -leo pipefail {0} - uses: actions/cache@v3 id: rtl-build-id From 3290f06c95410636f0fad44ff675d218a74887a3 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Mon, 23 Oct 2023 11:03:42 -0700 Subject: [PATCH 11/12] [ci] Revert back to local-only; disable gpu-flow --- .github/actions/prepare-rtl/action.yml | 5 ----- .github/scripts/defaults.sh | 5 ++--- .github/workflows/chipyard-gpu-flow.yml | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/actions/prepare-rtl/action.yml b/.github/actions/prepare-rtl/action.yml index bbd8d56f..478f0241 100644 --- a/.github/actions/prepare-rtl/action.yml +++ b/.github/actions/prepare-rtl/action.yml @@ -21,11 +21,6 @@ inputs: runs: using: "composite" steps: - - name: cd into remote - run: | - cd "${{ env.REMOTE_WORK_DIR }}" - shell: bash -leo pipefail {0} - - uses: actions/cache@v3 id: rtl-build-id with: diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index abdcdef5..a5f7f62e 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -9,9 +9,8 @@ REMOTE_MAKE_NPROC=4 # CI_DIR is defined externally based on the GH repository secret BUILDDIR REMOTE_PREFIX=$CI_DIR/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME//\//-} -# Use env.REMOTE_WORK_DIR set in workflow file -# REMOTE_WORK_DIR=$REMOTE_PREFIX/$GITHUB_WORKSPACE -REMOTE_CHIPYARD_DIR=$REMOTE_WORK_DIR +REMOTE_WORK_DIR=$GITHUB_WORKSPACE +REMOTE_CHIPYARD_DIR=$GITHUB_WORKSPACE REMOTE_SIM_DIR=$REMOTE_CHIPYARD_DIR/sims/verilator REMOTE_FIRESIM_DIR=$REMOTE_CHIPYARD_DIR/sims/firesim/sim REMOTE_FPGA_DIR=$REMOTE_CHIPYARD_DIR/fpga diff --git a/.github/workflows/chipyard-gpu-flow.yml b/.github/workflows/chipyard-gpu-flow.yml index 210ef42a..58cbd866 100644 --- a/.github/workflows/chipyard-gpu-flow.yml +++ b/.github/workflows/chipyard-gpu-flow.yml @@ -1,9 +1,9 @@ -name: chipyard-ci-full-flow +name: chipyard-ci-full-flow-gpu on: push: branches: - - graphics + # - graphics defaults: run: From d65720c135c7092629e07b7eeb5875bd02b638b0 Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Mon, 23 Oct 2023 11:05:25 -0700 Subject: [PATCH 12/12] [ci] Test with vcs --- .github/scripts/defaults.sh | 4 ++-- .github/workflows/chipyard-gpu-flow.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index a5f7f62e..88dca6c1 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -11,13 +11,13 @@ REMOTE_MAKE_NPROC=4 REMOTE_PREFIX=$CI_DIR/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME//\//-} REMOTE_WORK_DIR=$GITHUB_WORKSPACE REMOTE_CHIPYARD_DIR=$GITHUB_WORKSPACE -REMOTE_SIM_DIR=$REMOTE_CHIPYARD_DIR/sims/verilator +REMOTE_SIM_DIR=$REMOTE_CHIPYARD_DIR/sims/vcs REMOTE_FIRESIM_DIR=$REMOTE_CHIPYARD_DIR/sims/firesim/sim REMOTE_FPGA_DIR=$REMOTE_CHIPYARD_DIR/fpga # local variables (aka within the docker container) LOCAL_CHIPYARD_DIR=$GITHUB_WORKSPACE -LOCAL_SIM_DIR=$LOCAL_CHIPYARD_DIR/sims/verilator +LOCAL_SIM_DIR=$LOCAL_CHIPYARD_DIR/sims/vcs LOCAL_FIRESIM_DIR=$LOCAL_CHIPYARD_DIR/sims/firesim/sim # CI uses temp directories with very long names diff --git a/.github/workflows/chipyard-gpu-flow.yml b/.github/workflows/chipyard-gpu-flow.yml index 58cbd866..5a5a1398 100644 --- a/.github/workflows/chipyard-gpu-flow.yml +++ b/.github/workflows/chipyard-gpu-flow.yml @@ -1,9 +1,9 @@ name: chipyard-ci-full-flow-gpu -on: - push: - branches: - # - graphics +# on: +# push: +# branches: +# - graphics defaults: run: