diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e359aaca..02d716fe 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -104,6 +104,9 @@ jobs: TestRQAdd testRQGEMMTransB num-cores: 9 + simulators: | + banshee + gvsoc snitch-kernels-tiled-singlebuffer-L2: uses: ./.github/workflows/TestRunnerTiledSnitchSequential.yml @@ -131,6 +134,9 @@ jobs: "L1": [5000, 10000] } ] + simulators: | + banshee + gvsoc ### Mempool Tests ### mempool-kernels: diff --git a/.github/workflows/TestRunnerSnitch.yml b/.github/workflows/TestRunnerSnitch.yml index c7ae8c09..7778fbdd 100644 --- a/.github/workflows/TestRunnerSnitch.yml +++ b/.github/workflows/TestRunnerSnitch.yml @@ -9,9 +9,8 @@ on: num-cores: required: true type: number - simulator: - required: false - default: "banshee" + simulators: + required: true type: string jobs: @@ -29,11 +28,16 @@ jobs: - name: Run Test run: | testNames="${{ inputs.test-names }}" + simulators="${{inputs.simulators}}" cd DeeployTest - echo "$testNames" | while IFS= read -r testName; do - if [[ -n "$testName" ]]; then - echo "Running test: $testName" - python testRunner_snitch.py -t Tests/$testName --simulator=${{ inputs.simulator }} --cores=${{ inputs.num-cores }} --toolchain_install_dir /app/install/riscv-llvm/ + echo "$simulators" | while IFS= read -r simulator; do + if [[ -n "$simulator" ]]; then + echo "$testNames" | while IFS= read -r testName; do + if [[ -n "$testName" ]]; then + echo "Running test $testName using $simulator" + python testRunner_snitch.py -t Tests/$testName --simulator=$simulator --cores=${{ inputs.num-cores }} --toolchain_install_dir /app/install/riscv-llvm/ + fi + done fi done shell: bash \ No newline at end of file diff --git a/.github/workflows/TestRunnerTiledSnitchSequential.yml b/.github/workflows/TestRunnerTiledSnitchSequential.yml index 10a101a9..a99407f8 100644 --- a/.github/workflows/TestRunnerTiledSnitchSequential.yml +++ b/.github/workflows/TestRunnerTiledSnitchSequential.yml @@ -14,9 +14,8 @@ on: required: false default: "L2" type: string - simulator: - required: false - default: "banshee" + simulators: + required: true type: string @@ -43,18 +42,22 @@ jobs: key: ${{ runner.os }}-ccache - name: Run Tests run: | + simulators="${{inputs.simulators}}" cd DeeployTest echo '${{ inputs.tests-config }}' > tests.json mkdir -p /app/.ccache export CCACHE_DIR=/app/.ccache - - jq -c '.[]' tests.json | while read test; do - testName=$(echo "$test" | jq -r '.name') - L1_values=$(echo "$test" | jq -r '.L1[]') - for L1_value in $L1_values; do - echo "Running test: $testName with L1: $L1_value" - python testRunner_tiled_snitch.py -t Tests/$testName --cores=${{ inputs.num-cores }} --simulator=${{ inputs.simulator }} --l1 $L1_value --defaultMemLevel=${{ inputs.default-memory-level }} --toolchain_install_dir /app/install/riscv-llvm/ - done + echo "$simulators" | while IFS= read -r simulator; do + if [[ -n "$simulator" ]]; then + jq -c '.[]' tests.json | while read test; do + testName=$(echo "$test" | jq -r '.name') + L1_values=$(echo "$test" | jq -r '.L1[]') + for L1_value in $L1_values; do + echo "Running test: $testName with L1: $L1_value using $simulator" + python testRunner_tiled_snitch.py -t Tests/$testName --cores=${{ inputs.num-cores }} --simulator=$simulator --l1 $L1_value --defaultMemLevel=${{ inputs.default-memory-level }} --toolchain_install_dir /app/install/riscv-llvm/ + done + done + fi done shell: bash \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b02c2312..c9660a41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,4 +36,29 @@ - Minimal library with CycleCounter and utility function ### Changed -- Update the Banshee's commit to include a recent PR. \ No newline at end of file +- Update the Banshee's commit to include a recent PR. + +## Snitch Cluster Tiling Support + +### Added +- Support for single-buffered tiling from L2. +- Parsers, Templates, TypeCheckers, Layers, and TCF for the newly supported operators. +- A code transformation pass to filter DMA cores or compute cores for an `ExecutionBlock`. +- A code transformation pass to profile an `ExecutionBlock`. +- Test for single kernels, both with and without tiling. +- Adds the `--debug` flag to `cargo install` when installing Banshee to get the possibility of enabling the debug prints. +- New tests for the `snitch_cluster` platform. +- Add macros to `main.c` to disable printing and testing (convenient when running RTL simulations). + +### Changed +- Add the possibility of changing the simulator when using the snitch-tiled test runner. + +## GVSOC support for the Snitch Cluster Platform + +### Added +- gvsoc in the Makefile and dockerfile +- cmake flow for gvsoc +- CI tests regarding Snitch run on GVSOC as well + +### Changed +- Add the RTL library to the snitch_cluster build process in the Makefile, required for GVSOC simulation diff --git a/Container/Dockerfile b/Container/Dockerfile index 2327af8e..2faba86b 100644 --- a/Container/Dockerfile +++ b/Container/Dockerfile @@ -78,6 +78,8 @@ RUN make pulp-sdk RUN make qemu RUN make mempool RUN make banshee +# Copy gvsoc requirements for later as they are removed when toolchain folder is deleted +RUN make gvsoc && cp -r /app/toolchain/gvsoc/core/requirements.txt /app/core-requirements.txt && cp -r /app/toolchain/gvsoc/gapy/requirements.txt /app/gapy-requirements.txt # Dependencies needed for compiling Snitch ## Bender's installaton @@ -114,6 +116,7 @@ ENV CMAKE=/usr/bin/cmake ENV PULP_SDK_HOME=/app/install/pulp-sdk ENV LLVM_INSTALL_DIR=/app/install/llvm ENV SNITCH_HOME=/app/install/snitch_cluster +ENV GVSOC_INSTALL_DIR=/app/install/gvsoc ENV MEMPOOL_HOME=/app/install/mempool ENV PATH=/app/install/qemu/bin:/app/install/banshee:$PATH ENV PATH="/root/.cargo/bin:${PATH}" @@ -140,6 +143,9 @@ pip install toml-to-requirements && \ toml-to-req --toml-file pyproject.toml && \ pip install -r requirements.txt +COPY --from=builder /app/core-requirements.txt ./core-requirements.txt +COPY --from=builder /app/gapy-requirements.txt ./gapy-requirements.txt +RUN pip install -r core-requirements.txt -r gapy-requirements.txt # Copy pre-built toolchains and emulators COPY --from=builder /app/install ./install diff --git a/Deeploy/Targets/Snitch/CodeTransformationPasses/SnitchProfileExecutionBlock.py b/Deeploy/Targets/Snitch/CodeTransformationPasses/SnitchProfileExecutionBlock.py index c2cce339..7559a1a5 100644 --- a/Deeploy/Targets/Snitch/CodeTransformationPasses/SnitchProfileExecutionBlock.py +++ b/Deeploy/Targets/Snitch/CodeTransformationPasses/SnitchProfileExecutionBlock.py @@ -31,7 +31,7 @@ _dumpCycleCntTemplate = NodeTemplate(""" snrt_cluster_hw_barrier(); if (snrt_is_dm_core()) { - #ifndef BANSHEE_SIMULATION + #if !defined(BANSHEE_SIMULATION) && !defined(GVSOC_SIMULATION) DUMP(getCycles()); #else printf("${position} of ${nodeName} block at cycle %d \\n", getCycles()); diff --git a/DeeployTest/Platforms/Snitch/CMakeLists.txt b/DeeployTest/Platforms/Snitch/CMakeLists.txt index 7992d8e4..50ad1352 100644 --- a/DeeployTest/Platforms/Snitch/CMakeLists.txt +++ b/DeeployTest/Platforms/Snitch/CMakeLists.txt @@ -9,5 +9,6 @@ add_deeploy_executable(${ProjectId} EXCLUDE_FROM_ALL ${SOURCES}) target_link_libraries(${ProjectId} PRIVATE network deeploylib) target_compile_options(${ProjectId} INTERFACE network) add_banshee_simulation(${ProjectId}) +add_gvsoc_simulation(${ProjectId}) add_snitch_cluster_vsim_simulation(${ProjectId}) add_snitch_cluster_vsim_gui_simulation(${ProjectId}) \ No newline at end of file diff --git a/DeeployTest/Platforms/Snitch/main.c b/DeeployTest/Platforms/Snitch/main.c index 38cfa96c..e27d075b 100644 --- a/DeeployTest/Platforms/Snitch/main.c +++ b/DeeployTest/Platforms/Snitch/main.c @@ -40,7 +40,7 @@ int main(void) { uint32_t core_id = snrt_global_core_idx(); uint32_t compute_core_id = snrt_global_compute_core_idx(); -#ifdef BANSHEE_SIMULATION +#if !defined(BANSHEE_SIMULATION) && !defined(GVSOC_SIMULATION) uint32_t const num_compute_cores = (NUM_CORES - 1); #else uint32_t const num_compute_cores = snrt_global_compute_core_num(); @@ -98,23 +98,23 @@ int main(void) { snrt_cluster_hw_barrier(); -#ifndef BANSHEE_SIMULATION +#if !defined(BANSHEE_SIMULATION) && !defined(GVSOC_SIMULATION) if (snrt_is_dm_core()) { ResetTimer(); StartTimer(); } -#endif // BANSHEE_SIMULATION +#endif // BANSHEE_SIMULATION and GVSOC_SIMULATION RunNetwork(compute_core_id, num_compute_cores); uint32_t runtimeCycles = 0; -#ifndef BANSHEE_SIMULATION +#if !defined(BANSHEE_SIMULATION) && !defined(GVSOC_SIMULATION) if (snrt_is_dm_core()) { runtimeCycles = getCycles(); DUMP(runtimeCycles); StopTimer(); } -#endif // BANSHEE_SIMULATION +#endif // BANSHEE_SIMULATION and GVSOC_SIMULATION snrt_cluster_hw_barrier(); diff --git a/DeeployTest/testRunner_snitch.py b/DeeployTest/testRunner_snitch.py index 54e90d89..56455982 100644 --- a/DeeployTest/testRunner_snitch.py +++ b/DeeployTest/testRunner_snitch.py @@ -42,7 +42,7 @@ metavar = "", dest = "simulator", type = str, - choices = ["banshee", "vsim", "vsim.gui"], + choices = ["banshee", "vsim", "vsim.gui", "gvsoc"], default = "banshee", help = "Select the simulator to use") args = parser.parse_args() diff --git a/DeeployTest/testRunner_tiled_snitch.py b/DeeployTest/testRunner_tiled_snitch.py index 4cd53246..9573f759 100644 --- a/DeeployTest/testRunner_tiled_snitch.py +++ b/DeeployTest/testRunner_tiled_snitch.py @@ -41,7 +41,7 @@ metavar = "", dest = "simulator", type = str, - choices = ["banshee", "vsim", "vsim.gui"], + choices = ["banshee", "vsim", "vsim.gui", "gvsoc"], default = "banshee", help = "Select the simulator to use") diff --git a/DeeployTest/testUtils/testRunner.py b/DeeployTest/testUtils/testRunner.py index 4002de68..22c4cc17 100644 --- a/DeeployTest/testUtils/testRunner.py +++ b/DeeployTest/testUtils/testRunner.py @@ -319,6 +319,11 @@ def configure_cmake_project(self): else: self.cmake_args += " -D banshee_simulation=OFF" + if self._simulator == 'gvsoc': + self.cmake_args += " -D gvsoc_simulation=ON" + else: + self.cmake_args += " -D gvsoc_simulation=OFF" + command = f"$CMAKE -D TOOLCHAIN={self._args.toolchain} -D TOOLCHAIN_INSTALL_DIR={self._dir_toolchain} -D GENERATED_SOURCE={self._dir_gen} -D platform={self._platform} {self.cmake_args} -B {self._dir_build} -D TESTNAME={self._name_test} .." if self._args.verbose >= 3: diff --git a/Makefile b/Makefile index 5ce77e74..b6895b29 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ QEMU_INSTALL_DIR ?= ${DEEPLOY_INSTALL_DIR}/qemu BANSHEE_INSTALL_DIR ?= ${DEEPLOY_INSTALL_DIR}/banshee MEMPOOL_INSTALL_DIR ?= ${DEEPLOY_INSTALL_DIR}/mempool SNITCH_INSTALL_DIR ?= ${DEEPLOY_INSTALL_DIR}/snitch_cluster +GVSOC_INSTALL_DIR ?= ${DEEPLOY_INSTALL_DIR}/gvsoc CMAKE ?= cmake @@ -52,6 +53,7 @@ PULP_SDK_COMMIT_HASH ?= c216298881cee767afc30928e055982b9e40e568 BANSHEE_COMMIT_HASH ?= 0e105921e77796e83d01c2aa4f4cadfa2005b4d9 MEMPOOL_COMMIT_HASH ?= affd45d94e05e375a6966af6a762deeb182a7bd6 SNITCH_COMMIT_HASH ?= e02cc9e3f24b92d4607455d5345caba3eb6273b2 +GVSOC_COMMIT_HASH ?= e96253a0ca7bbd113850988c2d77289926db37f3 RUSTUP_CARGO ?= $$(rustup which cargo) @@ -75,6 +77,7 @@ echo-bash: @echo "TL/DR: add these lines to run ~/.bashrc" @echo "export PULP_SDK_HOME=${PULP_SDK_INSTALL_DIR}" @echo "export SNITCH_HOME=${SNITCH_INSTALL_DIR}" + @echo "export GVSOC_INSTALL_DIR=${GVSOC_INSTALL_DIR}" @echo "export LLVM_INSTALL_DIR=${LLVM_INSTALL_DIR}" @echo "export PULP_RISCV_GCC_TOOLCHAIN=/PULP_SDK_IS_A_MESS" @echo "export MEMPOOL_HOME=${MEMPOOL_INSTALL_DIR}" @@ -279,10 +282,23 @@ ${SNITCH_INSTALL_DIR}: ${TOOLCHAIN_DIR}/snitch_cluster TMPDIR=tmp pip install -r python-requirements.txt && rm -rf tmp && \ bender vendor init && \ cd ${SNITCH_INSTALL_DIR}/target/snitch_cluster && \ - make sw/runtime/banshee sw/math + make sw/runtime/banshee sw/runtime/rtl sw/math snitch_runtime: ${SNITCH_INSTALL_DIR} +${TOOLCHAIN_DIR}/gvsoc: + cd ${TOOLCHAIN_DIR} && \ + git clone https://github.com/gvsoc/gvsoc.git && \ + cd ${TOOLCHAIN_DIR}/gvsoc && git checkout ${GVSOC_COMMIT_HASH} && \ + git submodule update --init --recursive && \ + pip install -r core/requirements.txt && pip install -r gapy/requirements.txt + +${GVSOC_INSTALL_DIR}: ${TOOLCHAIN_DIR}/gvsoc + cd ${TOOLCHAIN_DIR}/gvsoc && \ + make all TARGETS=pulp.snitch.snitch_cluster_single INSTALLDIR=${GVSOC_INSTALL_DIR} + +gvsoc: ${GVSOC_INSTALL_DIR} + ${TOOLCHAIN_DIR}/qemu: cd ${TOOLCHAIN_DIR} && \ git clone https://github.com/qemu/qemu.git --depth 1 -b stable-6.1 && \ diff --git a/cmake/simulation.cmake b/cmake/simulation.cmake index c4a0bc47..d974f9bc 100644 --- a/cmake/simulation.cmake +++ b/cmake/simulation.cmake @@ -11,9 +11,13 @@ set(num_threads 1 CACHE STRING "Number of active cores") set(banshee_stack_size 16777216 CACHE STRING "Stack size of banshee threads") OPTION(banshee_simulation "Optimize binary for banshee simulation" OFF) +OPTION(gvsoc_simulation "adapt preprocessor macro for gvsoc simulation" OFF) if(banshee_simulation) add_compile_definitions(BANSHEE_SIMULATION) endif() +if(gvsoc_simulation) + add_compile_definitions(GVSOC_SIMULATION) +endif() ######################### ## Utility Functions ## @@ -26,6 +30,7 @@ macro(print_simulation_config) message(STATUS "[Simulator] VCS = " ${VCS}) message(STATUS "[Simulator] banshee_simulation = " ${banshee_simulation}) message(STATUS "[Simulator] banshee_configuration = " ${BANSHEE_CONFIG}) + message(STATUS "[Simulator] gvsoc_simulation = " ${gvsoc_simulation}) message(STATUS "[Simulator] banshee_stack_size = " ${banshee_stack_size}) message(STATUS "[Simulator] num_threads = " ${num_threads}) message(STATUS "================================================================================") diff --git a/cmake/snitch/snitch.cmake b/cmake/snitch/snitch.cmake index b56b6368..e1eaadbe 100644 --- a/cmake/snitch/snitch.cmake +++ b/cmake/snitch/snitch.cmake @@ -1,4 +1,5 @@ set(SNITCH_HOME $ENV{SNITCH_HOME}) +set(GVSOC_INSTALL_DIR $ENV{GVSOC_INSTALL_DIR}) set(SNITCH_RUNTIME_HOME ${SNITCH_HOME}/sw/snRuntime) add_compile_definitions( @@ -22,6 +23,18 @@ macro(add_snitch_cluster_vsim_simulation name) ) endmacro() +macro(add_gvsoc_simulation name) + add_custom_target(gvsoc_${name} + WORKING_DIRECTORY ${GVSOC_INSTALL_DIR} + DEPENDS ${name} + COMMAND ./bin/gvsoc --target=pulp.snitch.snitch_cluster_single --binary ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${name} image flash run + COMMENT "Simulating deeploytest with gvsoc" + POST_BUILD + USES_TERMINAL + VERBATIM + ) +endmacro() + macro(add_snitch_cluster_vsim_gui_simulation name) add_custom_target(vsim.gui_${name} WORKING_DIRECTORY ${SNITCH_HOME}/target/snitch_cluster