Skip to content

Commit

Permalink
[OPEN] GVSOC support for the Snitch Cluster platform (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahaelbayad authored Jan 14, 2025
1 parent c3f11d6 commit 3c64bda
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ jobs:
TestRQAdd
testRQGEMMTransB
num-cores: 9
simulators: |
banshee
gvsoc
snitch-kernels-tiled-singlebuffer-L2:
uses: ./.github/workflows/TestRunnerTiledSnitchSequential.yml
Expand Down Expand Up @@ -131,6 +134,9 @@ jobs:
"L1": [5000, 10000]
}
]
simulators: |
banshee
gvsoc
### Mempool Tests ###
mempool-kernels:
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/TestRunnerSnitch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ on:
num-cores:
required: true
type: number
simulator:
required: false
default: "banshee"
simulators:
required: true
type: string

jobs:
Expand All @@ -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
25 changes: 14 additions & 11 deletions .github/workflows/TestRunnerTiledSnitchSequential.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ on:
required: false
default: "L2"
type: string
simulator:
required: false
default: "banshee"
simulators:
required: true
type: string


Expand All @@ -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

27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,29 @@
- Minimal library with CycleCounter and utility function

### Changed
- Update the Banshee's commit to include a recent PR.
- 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
6 changes: 6 additions & 0 deletions Container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions DeeployTest/Platforms/Snitch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
10 changes: 5 additions & 5 deletions DeeployTest/Platforms/Snitch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion DeeployTest/testRunner_snitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
metavar = "<simulator>",
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()
Expand Down
2 changes: 1 addition & 1 deletion DeeployTest/testRunner_tiled_snitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
metavar = "<simulator>",
dest = "simulator",
type = str,
choices = ["banshee", "vsim", "vsim.gui"],
choices = ["banshee", "vsim", "vsim.gui", "gvsoc"],
default = "banshee",
help = "Select the simulator to use")

Expand Down
5 changes: 5 additions & 0 deletions DeeployTest/testUtils/testRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)

Expand All @@ -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}"
Expand Down Expand Up @@ -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 && \
Expand Down
5 changes: 5 additions & 0 deletions cmake/simulation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
Expand All @@ -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 "================================================================================")
Expand Down
13 changes: 13 additions & 0 deletions cmake/snitch/snitch.cmake
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 3c64bda

Please sign in to comment.