Skip to content

Commit

Permalink
Rework build-setup | Add single-node CI
Browse files Browse the repository at this point in the history
  • Loading branch information
abejgonzalez committed Dec 8, 2022
1 parent 43b7564 commit a37a935
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 73 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/chipyard-full-flow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: chipyard-ci-full-flow

on:
# run ci on pull requests targeting following branches (runs on the merge commit)
pull_request:
branches:
- main
- '1.[0-9]*.x'

defaults:
run:
shell: bash -leo pipefail {0}

env:
REMOTE_WORK_DIR: ${{ secrets.BUILDDIR }}/cy-ci-shared/cy-${{ github.sha }}

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: ferry
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 }}
eval "$(conda shell.bash hook)"
export MAKEFLAGS="-j32"
./build-setup.sh -f
run-tutorial:
name: run-tutorial
needs: [setup-repo]
runs-on: ferry
steps:
- name: Run smoke test
run: |
cd ${{ env.REMOTE_WORK_DIR }}
eval "$(conda shell.bash hook)"
source env.sh
cd sims/verilator
make verilog
cleanup:
name: cleanup
needs: [run-tutorial]
runs-on: ferry
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
steps:
- name: Delete repo copy and conda env
run: |
rm -rf ${{ env.REMOTE_WORK_DIR }}
2 changes: 1 addition & 1 deletion .github/workflows/chipyard-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}

Expand Down
12 changes: 5 additions & 7 deletions docs/Chipyard-Basics/Initial-Repo-Setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,25 @@ Start by checking out the proper Chipyard version. Run:
# note: this may not be the latest release if the documentation version != "stable"
git checkout |version|
Next run the following script to create Chipyard's Conda environment including a pre-built RISC-V toolchain.
Next run the following script to setup Chipyard completely with a specific toolchain.
There are two toolchains, one for normal RISC-V programs called ``riscv-tools`` which is the one needed for most Chipyard use-cases, and another for Hwacha/Gemmini called ``esp-tools``.
Run the following script based off which compiler you would like to use.

.. code-block:: shell
./build-setup.sh riscv-tools # or esp-tools
This script wraps around the conda environment initialization process and also runs the ``init-submodules-no-riscv-tools.sh`` and ``build-toolchain-extra.sh`` scripts.
This script wraps around the conda environment initialization process, initializes all submodules (with the ``init-submodules-no-riscv-tools.sh`` script), installs a toolchain, and runs other setups.
See ``./build-setup.sh --help`` for more details on what this does and how to disable parts of the setup.

The ``init-submodules-no-riscv-tools.sh`` script will initialize and checkout all of the necessary git submodules.
This will also validate that you are on a tagged branch, otherwise it will prompt for confirmation.
When updating Chipyard to a new version, you will also want to rerun this script to update the submodules.
Using ``git`` directly will try to initialize all submodules; this is not recommended unless you expressly desire this behavior.

The ``build-toolchain-extra.sh`` script will install extra toolchain utilities/tests used by Chipyard.
This command builds utilities like Spike, RISC-V Proxy Kernel, libgloss, and RISC-V tests from source for a specific toolchain type.
.. Note:: By default, the ``build-setup.sh`` script installs extra toolchain utilities (RISC-V tests, PK, Spike, etc) to ``$CONDA_PREFIX/<toolchain-type>``. Thus, if you uninstall the compiler using ``conda remove`` these utilities/tests will also have to be re-installed/built.

.. Note:: By default, the ``build-toolchain-extra.sh`` script installs to ``$CONDA_PREFIX/<toolchain-type>``. Thus, if you uninstall the compiler using ``conda remove`` these utilities/tests will also have to be re-installed/built.

.. Note:: If you already have a working conda environment setup, separate Chipyard clones can use that pre-used environment in combination with running the aforementioned scripts yourself (``init-submodules...`` and ``build-toolchain...``).
.. Note:: If you already have a working conda environment setup, separate Chipyard clones can use that pre-used environment in combination with running the aforementioned scripts yourself (``init-submodules...``, ``build-toolchain...``, etc).

.. Note:: If you are a power user and would like to build your own compiler/toolchain, you can refer to the https://github.com/ucb-bar/riscv-tools-feedstock and https://github.com/ucb-bar/esp-tools-feedstock repositories (submoduled in the ``toolchains/*`` directories) on how to build the compiler yourself.

Expand Down
9 changes: 1 addition & 8 deletions docs/Simulation/FPGA-Accelerated-Simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ FireSim supports running on Amazon EC2 F1 FPGA-enabled cloud instances and on lo
The rest of this documentation assumes you are running on an Amazon EC2 F1 FPGA-enabled virtual instance.
In order to simuate your Chipyard design using FireSim, make sure to follow the repository setup as described by
:ref:`Chipyard-Basics/Initial-Repo-Setup:Initial Repository Setup`, if you have not already.

Next, initalize FireSim as a library in Chipyard by running:

.. code-block:: shell
# At the root of your chipyard repo
./scripts/firesim-setup.sh
This setup should have setup the Chipyard repository including FireSim by running the ``./scripts/firesim-setup.sh`` script.
``firesim-setup.sh`` initializes additional submodules and then invokes
FireSim's ``build-setup.sh`` script adding ``--library`` to properly
initialize FireSim as a library submodule in Chipyard. You may run
Expand Down
2 changes: 1 addition & 1 deletion generators/boom
2 changes: 1 addition & 1 deletion generators/gemmini
Submodule gemmini updated 41 files
+1 −1 .github/workflows/config.yml
+1 −1 CHIPYARD.hash
+3 −11 README.md
+1 −1 SPIKE.hash
+0 −2 scripts/build-midas.sh
+1 −1 scripts/build-onnx-inference.sh
+4 −7 scripts/build-vcs.sh
+3 −6 scripts/build-verilator.sh
+1 −2 scripts/run-midas.sh
+1 −1 software/gemmini-ort.json
+1 −1 software/gemmini-rocc-tests
+1 −2 software/gemmini-tests-interactive.json
+1 −2 software/gemmini-tests.json
+1 −1 software/onnxruntime-riscv
+23 −35 src/main/scala/gemmini/AccumulatorMem.scala
+56 −137 src/main/scala/gemmini/AccumulatorScale.scala
+1 −5 src/main/scala/gemmini/Activation.scala
+60 −239 src/main/scala/gemmini/Arithmetic.scala
+4 −7 src/main/scala/gemmini/BeatMerger.scala
+5 −61 src/main/scala/gemmini/Configs.scala
+7 −3 src/main/scala/gemmini/ConfigsFP.scala
+24 −38 src/main/scala/gemmini/Controller.scala
+1 −8 src/main/scala/gemmini/CustomConfigs.scala
+8 −11 src/main/scala/gemmini/DMA.scala
+1 −0 src/main/scala/gemmini/DMACommandTracker.scala
+15 −5 src/main/scala/gemmini/DSEConfigs.scala
+17 −16 src/main/scala/gemmini/ExecuteController.scala
+8 −23 src/main/scala/gemmini/GemminiConfigs.scala
+4 −34 src/main/scala/gemmini/GemminiISA.scala
+4 −4 src/main/scala/gemmini/LoadController.scala
+2 −7 src/main/scala/gemmini/LocalAddr.scala
+95 −123 src/main/scala/gemmini/LoopConv.scala
+53 −152 src/main/scala/gemmini/LoopMatmul.scala
+1 −1 src/main/scala/gemmini/MeshWithDelays.scala
+0 −23 src/main/scala/gemmini/NormCmd.scala
+0 −635 src/main/scala/gemmini/Normalizer.scala
+183 −243 src/main/scala/gemmini/ReservationStation.scala
+49 −116 src/main/scala/gemmini/Scratchpad.scala
+14 −65 src/main/scala/gemmini/StoreController.scala
+2 −2 src/main/scala/gemmini/TransposePreloadUnroller.scala
+1 −2 src/main/scala/gemmini/ZeroWriter.scala
2 changes: 1 addition & 1 deletion generators/hwacha
136 changes: 115 additions & 21 deletions scripts/build-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,63 @@ common_setup
usage() {
echo "Usage: ${0} [OPTIONS] [riscv-tools | esp-tools]"
echo ""
echo "Helper script to initialize repository that wraps other scripts."
echo "Sets up conda environment, initializes submodules, and installs toolchain collateral."
echo ""
echo "Installation Types"
echo " riscv-tools: if set, builds the riscv toolchain (this is also the default)"
echo " esp-tools: if set, builds esp-tools toolchain used for the hwacha vector accelerator"
echo ""
echo "Helper script to fully initialize repository that wraps other scripts."
echo "By default it initializes/installs things in the following order:"
echo " 1. Conda environment"
echo " 2. Chipyard submodules"
echo " 3. Toolchain collateral (Spike, PK, tests, libgloss)"
echo " 4. Ctags"
echo " 5. Chipyard pre-compile sources"
echo " 6. FireSim"
echo " 7. FireSim pre-compile sources"
echo " 8. FireMarshal"
echo " 9. FireMarshal pre-compile br-base sources"
echo " 10. Runs repo. clean-up"
echo ""
echo "**See below for options to skip parts of the setup. However, they are not guaranteed to be tested/working.**"
echo ""
echo "Options"
echo " --help -h : Display this message"
echo " --unpinned-deps -ud : Use unpinned conda environment"
echo " --force -f : Skip prompt checking for tagged release/conda"
echo " --skip-validate : DEPRECATED: Same functionality as --force"
echo " --skip-conda : Skip conda env creation"
echo " --skip-toolchain-extra : Skip building extra RISC-V toolchain collateral (Spike, PK, tests, libgloos)"
echo " --help -h : Display this message"

echo " --force -f : Skip all prompts and checks"
echo " --skip-validate : DEPRECATED: Same functionality as --force"
echo " --verbose : Verbose printout"

echo " --use-unpinned-deps -ud : Use unpinned conda environment"

echo " --skip-conda : Skip (1) conda env creation"

echo " --skip-toolchain-extra : Skip (3) building toolchain-specific extra RISC-V toolchain collateral"

echo " --skip-cy-precompile : Skip (5) Chipyard pre-compile SBT sources"

echo " --skip-firesim : Skip (6) (7) FireSim setup and pre-compile SBT sources"
echo " --skip-firesim-precompile : Skip (7) FireSim pre-compile SBT sources"

echo " --skip-firemarshal : Skip (8) (9) FireMarshal setup and pre-compile br-base sources"
echo " --skip-firemarshal-br-base : Skip (9) FireMarshal pre-compile br-base sources"

echo " --skip-repo-clean : Skip (10) repository cleanup"

exit "$1"
}

TOOLCHAIN="riscv-tools"
USE_PINNED_DEPS=true
TOOLCHAIN_TYPE="riscv-tools"
FORCE_FLAG=""
VERBOSE=false
USE_UNPINNED_DEPS=false
SKIP_CONDA=false
SKIP_TOOLCHAIN=false
SKIP_TOOLCHAIN_EXTRA=false
SKIP_CY_PRECOMPILE=false
SKIP_FIRESIM=false
SKIP_FIRESIM_PRECOMPILE=false
SKIP_FIREMARSHAL=false
SKIP_FIREMARSHAL_BR_BASE=false
SKIP_REPO_CLEAN=false

# getopts does not support long options, and is inflexible
while [ "$1" != "" ];
Expand All @@ -44,31 +79,47 @@ do
-h | --help )
usage 3 ;;
riscv-tools | esp-tools)
TOOLCHAIN=$1 ;;
-ud | --unpinned-deps )
USE_PINNED_DEPS=false ;;
TOOLCHAIN_TYPE=$1 ;;
--force | -f | --skip-validate)
FORCE_FLAG=$1 ;;
--verbose)
set -x ;;
-ud | --use-unpinned-deps )
USE_UNPINNED_DEPS=true ;;
--skip-conda)
SKIP_CONDA=true ;;
--skip-toolchain-extra)
SKIP_TOOLCHAIN=true ;;
SKIP_TOOLCHAIN_EXTRA=true ;;
--skip-cy-precompile)
SKIP_CY_PRECOMPILE=true ;;
--skip-firesim)
SKIP_FIRESIM=true ;;
--skip-firesim-precompile)
SKIP_FIRESIM_PRECOMPILE=true ;;
--skip-firemarshal)
SKIP_FIREMARSHAL=true ;;
--skip-firemarshal-br-base)
SKIP_FIREMARSHAL_BR_BASE=true ;;
--skip-repo-clean)
SKIP_REPO_CLEAN=true ;;
* )
error "invalid option $1"
usage 1 ;;
esac
shift
done

{

if [ "$SKIP_CONDA" = false ]; then
# note: lock file must end in .conda-lock.yml - see https://github.com/conda-incubator/conda-lock/issues/154
CONDA_REQS=$RDIR/conda-reqs
CONDA_LOCK_REQS=$CONDA_REQS/conda-lock-reqs
LOCKFILE=$CONDA_LOCK_REQS/conda-requirements-$TOOLCHAIN-linux-64.conda-lock.yml
LOCKFILE=$CONDA_LOCK_REQS/conda-requirements-$TOOLCHAIN_TYPE-linux-64.conda-lock.yml

if [ "$USE_PINNED_DEPS" = false ]; then
if [ "$USE_UNPINNED_DEPS" = true ]; then
# auto-gen the lockfile
conda-lock -f $CONDA_REQS/chipyard.yaml -f $CONDA_REQS/$TOOLCHAIN.yaml --lockfile $LOCKFILE
conda-lock -f $CONDA_REQS/chipyard.yaml -f $CONDA_REQS/$TOOLCHAIN_TYPE.yaml --lockfile $LOCKFILE
fi

# use conda-lock to create env
Expand All @@ -87,14 +138,57 @@ fi

$RDIR/scripts/init-submodules-no-riscv-tools.sh $FORCE_FLAG

if [ "$SKIP_TOOLCHAIN" = false ]; then
$RDIR/scripts/build-toolchain-extra.sh $FORCE_FLAG $TOOLCHAIN
if [ "$SKIP_TOOLCHAIN_EXTRA" = false ]; then
$RDIR/scripts/build-toolchain-extra.sh $FORCE_FLAG $TOOLCHAIN_TYPE
fi

$RDIR/scripts/gen-tags.sh

if [ "$SKIP_CY_PRECOMPILE" = false ]; then
pushd $RDIR/sims/verilator
make launch-sbt SBT_COMMAND=";project chipyard; compile"
make launch-sbt SBT_COMMAND=";project tapeout; compile"
popd
fi

if [ "$SKIP_FIRESIM" = false ]; then
$RDIR/scripts/firesim-setup.sh
$RDIR/sims/firesim/gen-tags.sh

if [ "$SKIP_FIRESIM_PRECOMPILE" = false ]; then
pushd $RDIR/sims/firesim
(
source sourceme-f1-manager.sh --skip-ssh-setup
pushd sim
make sbt SBT_COMMAND="project firechip; compile" TARGET_PROJECT=firesim
popd
)
popd
fi
fi

if [ "$SKIP_FIREMARSHAL" = false ]; then
pushd $RDIR/software/firemarshal
./init-submodules.sh

if [ "$SKIP_FIREMARSHAL_BR_BASE" = false ]; then
source $RDIR/scripts/fix-open-files.sh
./marshal -v build br-base.json
./marshal -v clean br-base.json
fi
popd
fi

if [ "$SKIP_REPO_CLEAN" = false ]; then
$RDIR/scripts/repo-clean.sh
fi

cat << EOT >> env.sh
# line auto-generated by $0
conda activate $RDIR/.conda-env
source $RDIR/scripts/fix-open-files.sh
EOT

echo "Setup complete!"

} 2>&1 | tee build-setup.log
33 changes: 0 additions & 33 deletions scripts/first-clone-setup-fast.sh

This file was deleted.

Loading

0 comments on commit a37a935

Please sign in to comment.