diff --git a/.github/workflows/ci-pivoted.yml b/.github/workflows/ci-pivoted.yml index fc250968..e852ab62 100644 --- a/.github/workflows/ci-pivoted.yml +++ b/.github/workflows/ci-pivoted.yml @@ -16,13 +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 - name: Clean and make pivoted run: | - . .venv/bin/activate cp results/pivoted.csv results/pivoted_old.csv.txt make clean make diff --git a/Snakefile b/Snakefile index 6cfa8f94..b7327077 100644 --- a/Snakefile +++ b/Snakefile @@ -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 diff --git a/default.yaml b/default.yaml index ea15b7ad..1e2b1a5b 100644 --- a/default.yaml +++ b/default.yaml @@ -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 # Flags @@ -19,18 +20,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 @@ -43,30 +37,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: diff --git a/docker/Dockerfile b/docker/Dockerfile index 5b94d005..50406f1a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,59 +1,14 @@ -#------------------------------------------------------------------------------- -# 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:bfe84cbb917169c39ae6a26c811c19665d3bc04ebf926155bc442bcd5cba59db AS toolchain # 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 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 7c343831fc09819511a4eea54a725a02c4da765f \ + && make DEBUG=ON sn-runtime -j # === Optimized Package Installation === # Split apt commands into logical, cacheable layers. @@ -95,13 +50,9 @@ RUN apt-get -y update \ # 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 +# Install uv 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 + && ln -s /root/.local/bin/uv /usr/local/bin/uv -ENTRYPOINT ["/entrypoint.sh"] +COPY requirements.txt ./requirements.txt +RUN uv pip install -r ./requirements.txt diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100755 index a90b7f6d..00000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -SETUP=/src/docker/venv.sh - -if [ -f "${SETUP}" ]; then - source "${SETUP}" -else - >&2 echo "WARNING: can't find source repo mounted at /src, brace for bad things" -fi - -exec "$@" diff --git a/docker/venv.sh b/docker/venv.sh deleted file mode 100755 index b8eeeebf..00000000 --- a/docker/venv.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -VENV_DIR=/src/.venv-docker -FORCE_VENV=0 - -if [[ -d /src/xdsl ]]; then - pushd /src/xdsl > /dev/null - if [[ 1 -eq ${FORCE_VENV} ]] || [[ ! -d ${VENV_DIR} ]] || [[ ! -f ${VENV_DIR}/bin/activate ]]; then - uv venv -p 3.11 ${VENV_DIR} - source ${VENV_DIR}/bin/activate - uv pip install -r /src/requirements.txt - else - source ${VENV_DIR}/bin/activate - fi - popd -fi - diff --git a/requirements.txt b/requirements.txt index 82e955b5..a249777c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,3 @@ seaborn numpy snakemake==8.14.0 git+https://github.com/xdslproject/xdsl.git@902bfbc8#egg=xdsl -/opt/snitch_cluster/