Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "snitch_cluster"]
path = snitch_cluster
url = git@github.com:pulp-platform/snitch_cluster.git
10 changes: 6 additions & 4 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,11 @@ rule dasm_to_trace:
txt="{test}.logs/trace_hart_00000.trace.txt",
json="{test}.logs/trace_hart_00000.trace.json",
params:
spike=config["spike"],
gentrace=config["gentrace"],
llvm_mc=config["llvm-mc"],
llvm_mcflags=config["llvm-mcflags"],
shell:
"{params.spike} < {input} | {params.gentrace} --permissive --dump-hart-perf {log.json} -o {log.txt}"
"{params.gentrace} {input} --mc-exec {params.llvm_mc} --mc-flags \"{params.llvm_mcflags}\" --permissive --dump-hart-perf {log.json} -o {log.txt}"


# Rule used to generate traces for debugging purposes, not used for csv generation
Expand All @@ -387,10 +388,11 @@ rule dasm_to_trace_debug:
output:
txt="{test}.logs/logs/trace_hart_00000.trace.txt",
params:
spike=config["spike"],
gentrace=config["gentrace"],
llvm_mc=config["llvm-mc"],
llvm_mcflags=config["llvm-mcflags"],
shell:
"{params.spike} < {input} | {params.gentrace} --permissive > {output.txt}"
"{params.gentrace} {input} --mc-exec {params.llvm_mc} --mc-flags \"{params.llvm_mcflags}\" --permissive -o {log.txt}"


rule verilator:
Expand Down
54 changes: 22 additions & 32 deletions default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ xdsl-opt: xdsl-opt # from virtualenv
mlir-opt: /usr/bin/mlir-opt-16
mlir-translate: /usr/bin/mlir-translate-16
cc: /opt/snitch-llvm/bin/clang++
spike: /opt/snitch-spike/bin/spike-dasm
vltsim: /opt/snitch-rtl/bin/snitch_cluster.vlt
gentrace: /opt/snitch_cluster/util/trace/gen_trace.py
llvm-mc: /opt/snitch-llvm/bin/llvm-mc
vltsim: /opt/snitch_cluster.vlt
gentrace: snitch_cluster/util/trace/gen_trace.py

# Flags
asflags:
Expand All @@ -19,18 +19,18 @@ asflags:
- -fno-common
- -O3
- -D__DEFINED_uint64_t
- -I/opt/snitch_cluster/target/snitch_cluster/sw/runtime/rtl/src
- -I/opt/snitch_cluster/target/snitch_cluster/sw/runtime/common
- -I/opt/snitch_cluster/sw/snRuntime/api
- -I/opt/snitch_cluster/sw/snRuntime/src
- -I/opt/snitch_cluster/sw/snRuntime/src/omp/
- -I/opt/snitch_cluster/sw/snRuntime/api/omp/
- -I/opt/snitch_cluster/sw/math/arch/riscv64/bits/
- -I/opt/snitch_cluster/sw/math/arch/generic
- -I/opt/snitch_cluster/sw/math/src/include
- -I/opt/snitch_cluster/sw/math/src/internal
- -I/opt/snitch_cluster/sw/math/include/bits
- -I/opt/snitch_cluster/sw/math/include
- -Isnitch_cluster/target/snitch_cluster/sw/runtime/rtl/src
- -Isnitch_cluster/target/snitch_cluster/sw/runtime/common
- -Isnitch_cluster/sw/snRuntime/api
- -Isnitch_cluster/sw/snRuntime/src
- -Isnitch_cluster/sw/snRuntime/src/omp/
- -Isnitch_cluster/sw/snRuntime/api/omp/
- -Isnitch_cluster/sw/math/arch/riscv64/bits/
- -Isnitch_cluster/sw/math/arch/generic
- -Isnitch_cluster/sw/math/src/include
- -Isnitch_cluster/sw/math/src/internal
- -Isnitch_cluster/sw/math/include/bits
- -Isnitch_cluster/sw/math/include
cflags:
- -Wno-unused-command-line-argument
- -menable-experimental-extensions
Expand All @@ -43,30 +43,20 @@ cflags:
- -fno-common
- -O3
- -D__DEFINED_uint64_t
- -I/opt/snitch_cluster/target/snitch_cluster/sw/runtime/rtl/src
- -I/opt/snitch_cluster/target/snitch_cluster/sw/runtime/common
- -I/opt/snitch_cluster/sw/snRuntime/api
- -I/opt/snitch_cluster/sw/snRuntime/src
- -I/opt/snitch_cluster/sw/snRuntime/src/omp/
- -I/opt/snitch_cluster/sw/snRuntime/api/omp/
- -I/opt/snitch_cluster/sw/math/arch/riscv64/bits/
- -I/opt/snitch_cluster/sw/math/arch/generic
- -I/opt/snitch_cluster/sw/math/src/include
- -I/opt/snitch_cluster/sw/math/src/internal
- -I/opt/snitch_cluster/sw/math/include/bits
- -I/opt/snitch_cluster/sw/math/include
- -Isnitch_cluster/sw/runtime/impl
- -Isnitch_cluster/sw/runtime/src
- -Isnitch_cluster/sw/runtime/api
ldflags:
- -fuse-ld=/opt/snitch-llvm/bin/ld.lld
- -nostartfiles
- -nostdlib
- -L/opt/snitch-llvm/lib/clang/15.0.0/lib/
- -L/opt/snitch_cluster/target/snitch_cluster/sw/runtime/
- -L/opt/snitch_cluster/target/snitch_cluster/sw/runtime/rtl
- -L/opt/snitch_cluster/target/snitch_cluster/sw/runtime/rtl/build
- -T/opt/snitch_cluster/sw/snRuntime/base.ld
- -Tsnitch_cluster/sw/runtime/base.ld
- -lc
- -lsnRuntime
- -lclang_rt.builtins-riscv32
llvm-mcflags:
- -disassemble
- -mcpu=snitch
xdsl-passes:
- test-lower-linalg-to-snitch
mlir-opt-flags-linalg:
Expand Down
51 changes: 7 additions & 44 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,11 @@
# Build: make docker-build
# Run: make docker-run
#-------------------------------------------------------------------------------
ARG SNITCH_COMMIT=7f430f2
# Digest of ghcr.io/pulp-platform/snitch_cluster:main as of 2025-09.
# Digest of ghcr.io/pulp-platform/snitch_cluster:main for commit ecf876f.
# Pinned because the registry has no semver tags, only branch names.
ARG SNITCH_BASE_IMAGE=ghcr.io/pulp-platform/snitch_cluster@sha256:ad2491d877e84803297962091ce3485821bb529e921079ec4547f4a26d14d92a
ARG SNITCH_BASE_IMAGE=ghcr.io/pulp-platform/snitch_cluster-sw@sha256:f4e4ebfe0a984b8d8d64afa878551da8c09740a2e1b05b200694efdcb428ce46

#-------------------------------------------------------------------------------
# Stage 1: Builder
# Clones the repository and builds verilator model, software, and spike.
#-------------------------------------------------------------------------------
FROM ${SNITCH_BASE_IMAGE} AS builder
ARG SNITCH_COMMIT

# The base image sets SN_LLVM_BINROOT, but commit 7f430f2 expects LLVM_BINROOT.
ENV LLVM_BINROOT="/tools/riscv-llvm/bin"

# Patch .gitmodules to replace SSH URLs with HTTPS
# Clone the snitch_cluster repository into /repo
# If the repo URL or commit hash doesn't change, this layer remains cached.
RUN git config --global url."https://github".insteadOf "git://github" \
&& git config --global url."https://github.com/".insteadOf "git@github.com:" \
&& git clone --recursive https://github.com/pulp-platform/snitch_cluster /repo \
&& cd /repo \
&& git reset --hard ${SNITCH_COMMIT} \
&& make -C target/snitch_cluster verilator \
&& make -C target/snitch_cluster DEBUG=ON sw \
&& cd /repo/target/snitch_cluster/work-vlt/riscv-isa-sim \
&& ./configure --prefix=/opt/snitch-spike \
&& make install
FROM ${SNITCH_BASE_IMAGE} AS snitch

#-------------------------------------------------------------------------------
# Stage 2: Final Toolchain Image
Expand All @@ -53,23 +30,10 @@ ENV DEBIAN_FRONTEND=noninteractive
# Combine related COPY commands to reduce image layers.
# Copying parent directories is more efficient than many individual sub-directories.

COPY --from=builder /repo/target/snitch_cluster/bin/snitch_cluster_bin.vlt /opt/snitch-rtl/bin/snitch_cluster.vlt

COPY --from=builder /opt/snitch-spike /opt/snitch-spike
COPY --from=builder /tools/riscv-llvm /opt/snitch-llvm


# Copy the entire 'sw' directory at once instead of its individual sub-directories.
COPY --from=builder /repo/sw /opt/snitch_cluster/sw

# Copy the entire runtime directory at once.
COPY --from=builder /repo/target/snitch_cluster/sw/runtime /opt/snitch_cluster/target/snitch_cluster/sw/runtime
COPY --from=snitch /tools/bin/snitch_cluster.vlt /opt/snitch_cluster.vlt
COPY --from=snitch /tools/riscv-llvm /opt/snitch-llvm

# Copy Snitch Python package files.
COPY --from=builder /repo/pyproject.toml /opt/snitch_cluster/
COPY --from=builder /repo/util /opt/snitch_cluster/util
COPY --from=builder /repo/nonfree/util /opt/snitch_cluster/nonfree/util
COPY --from=builder /repo/target/snitch_cluster/util /opt/snitch_cluster/target/snitch_cluster/util
ENV PATH="/opt:/opt/snitch-llvm/bin:$PATH"

# === Optimized Package Installation ===
# Split apt commands into logical, cacheable layers.
Expand Down Expand Up @@ -123,8 +87,7 @@ ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN uv venv /opt/venv -p 3.11 \
&& uv sync --locked --no-install-project \
&& uv pip install /opt/snitch_cluster
&& uv sync --locked --no-install-project

WORKDIR /src

Expand Down
1 change: 1 addition & 0 deletions snitch_cluster
Submodule snitch_cluster added at ecf876