Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 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
6 changes: 0 additions & 6 deletions .github/workflows/ci-pivoted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies in venv
run: |
uv venv -p 3.11
uv pip install -r /src/requirements.txt
uv pip install /opt/snitch_cluster/
- name: Clean and make pivoted
run: |
. .venv/bin/activate
cp results/pivoted.csv results/pivoted_old.csv.txt
make clean
make
Expand Down
4 changes: 3 additions & 1 deletion Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,10 @@ rule dasm_to_trace:
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 Down
54 changes: 22 additions & 32 deletions default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
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++
cc: /tools/riscv-llvm/bin/clang++
llvm-mc: /tools/riscv-llvm/bin/llvm-mc
spike: /opt/snitch-spike/bin/spike-dasm
vltsim: /opt/snitch-rtl/bin/snitch_cluster.vlt
vltsim: snitch_cluster.vlt
gentrace: /opt/snitch_cluster/util/trace/gen_trace.py
xdsl_commit: /src/xdsl_commit.txt

Expand All @@ -20,18 +21,11 @@ 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
- -I/opt/snitch_cluster/sw/runtime/src
- -I/opt/snitch_cluster/sw/runtime/impl
- -I/opt/snitch_cluster/sw/runtime/api
- -I/opt/snitch_cluster/sw/runtime/src/omp/
- -I/opt/snitch_cluster/sw/runtime/api/omp/
cflags:
- -Wno-unused-command-line-argument
- -menable-experimental-extensions
Expand All @@ -44,30 +38,26 @@ 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
- -I/opt/snitch_cluster/sw/runtime/src
- -I/opt/snitch_cluster/sw/runtime/impl
- -I/opt/snitch_cluster/sw/runtime/api
- -I/opt/snitch_cluster/sw/runtime/src/omp/
- -I/opt/snitch_cluster/sw/runtime/api/omp/
ldflags:
- -fuse-ld=/opt/snitch-llvm/bin/ld.lld
- -fuse-ld=/tools/riscv-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
- -L/tools/riscv-llvm/lib/clang/15.0.0/lib/
- -L/opt/snitch_cluster/sw/runtime/
- -L/opt/snitch_cluster/sw/runtime/impl
- -L/opt/snitch_cluster/sw/runtime/build
- -T/opt/snitch_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
74 changes: 13 additions & 61 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,16 @@
#-------------------------------------------------------------------------------
# Stage 1: Builder
# Clones the repository and builds the necessary artifacts.
#-------------------------------------------------------------------------------
FROM ghcr.io/pulp-platform/snitch_cluster:main AS builder
FROM ghcr.io/pulp-platform/snitch_cluster-sw@sha256:290416751224ccb0a5bf5a583dbad6bc60c985f8fd4a2577775a4af43f2abf6a AS toolchain
ARG VIRTUAL_ENV="/root/.venvs/snitch_cluster"
ARG PYTHON_VERSION=3.11

# 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 "[email protected]:" \
&& git clone --recursive https://github.com/pulp-platform/snitch_cluster /repo \
&& cd /repo \
&& git reset --hard 7f430f2 \
# Build the verilator model and software in the same layer
&& 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

WORKDIR /src

RUN curl -L -o riscv32-snitch-llvm-ubuntu2204-15.0.0-snitch-0.2.0.tar.gz https://github.com/pulp-platform/llvm-project/releases/download/15.0.0-snitch-0.2.0/riscv32-snitch-llvm-ubuntu2204-15.0.0-snitch-0.2.0.tar.gz \
&& tar -xzf riscv32-snitch-llvm-ubuntu2204-15.0.0-snitch-0.2.0.tar.gz -C /src

#-------------------------------------------------------------------------------
# Stage 2: Final Toolchain Image
# Creates the final, lean image by copying artifacts from the builder
# and installing only necessary runtime dependencies.
#-------------------------------------------------------------------------------
FROM ubuntu:22.04 AS toolchain

# Set this environment variable early.
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 /src/riscv32-snitch-llvm-ubuntu2204-15.0.0-snitch-0.2.0 /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 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
&& git clone --recursive https://github.com/pulp-platform/snitch_cluster /opt/snitch_cluster \
&& cd /opt/snitch_cluster \
&& git reset --hard 742fbe3259125fc182fba11f756fd0af4d87404f \
&& make DEBUG=ON sn-runtime -j

# === Optimized Package Installation ===
# Split apt commands into logical, cacheable layers.
Expand All @@ -74,7 +31,8 @@ RUN wget -O /etc/apt/keyrings/llvm-snapshot.gpg.key https://apt.llvm.org/llvm-sn
# 3. Update package lists and install final packages.
# This is the layer that will most likely change.
# Using --no-install-recommends reduces bloat.
RUN apt-get -y update \
RUN apt-add-repository ppa:deadsnakes/ppa \
&& apt-get -y update \
&& apt-get -y install --no-install-recommends \
# python runtime dependencies
zlib1g \
Expand All @@ -92,16 +50,10 @@ RUN apt-get -y update \
# misc
make \
git \
python${PYTHON_VERSION}-dev \
# 4. Clean up in the SAME RUN command to reduce final image size.
&& rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/*

# Install uv and Python in a single layer, and ensure uv is in PATH
RUN wget -qO- https://astral.sh/uv/install.sh | sh \
&& ln -s /root/.local/bin/uv /usr/local/bin/uv \
&& /root/.local/bin/uv python install

COPY docker/entrypoint.sh /entrypoint.sh
# Ensure the entrypoint is executable
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
COPY requirements.txt ./requirements.txt
COPY xdsl ./xdsl
RUN . ${VIRTUAL_ENV}/bin/activate && pip install -r ./requirements.txt
13 changes: 0 additions & 13 deletions docker/entrypoint.sh

This file was deleted.

20 changes: 0 additions & 20 deletions docker/venv.sh

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pandas
seaborn
numpy
snakemake==8.14.0
-e /src/xdsl
-e xdsl
Loading