diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 95b38be..bd63c80 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,6 @@ # Base image with Miniconda FROM continuumio/miniconda3:latest ENV DEBIAN_FRONTEND=noninteractive - # ------------------------------ # Install system packages # ------------------------------ @@ -10,80 +9,107 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ git \ curl \ wget \ + openssh-server \ openssh-client \ + rsync \ less \ vim \ nano \ locales \ build-essential \ ca-certificates \ + kmod \ tmux \ unzip \ && rm -rf /var/lib/apt/lists/* +# Install LibGL +RUN apt-get update && apt-get install -y \ + libgl1-mesa-glx \ + libgl1-mesa-dri \ + libglu1-mesa \ + libx11-6 \ + libxext6 \ + libxrender1 \ + libxi6 \ + libxrandr2 \ + libxcursor1 \ + libxinerama1 \ + libxft2 \ + && rm -rf /var/lib/apt/lists/* + + +# Install CPIO to get firemarshal running +RUN sudo apt update +RUN sudo apt install cpio + # Fix locale setup - ensure it's in locale.gen first RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \ locale-gen en_US.UTF-8 - # Set locale environment variables ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US:en ENV LC_ALL=en_US.UTF-8 - # Set JVM encoding options to handle Unicode (fixes Shapeless error) ENV SBT_OPTS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dfile.encoding.pkg=UTF-8" ENV _JAVA_OPTIONS="-Dfile.encoding=UTF-8" ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8" - # Auto-activate base RUN conda config --set auto_activate_base true - # Install conda-lock <1.5 RUN conda install -c conda-forge 'conda-lock<1.5' -y - +RUN conda install -c conda-forge 'libstdcxx-ng>=12' -y # Install firtool RUN conda config --add channels ucb-bar && \ conda config --set channel_priority strict && \ conda install -y firtool - +# ------------------------------ +# SSH setup +# ------------------------------ +RUN mkdir -p /run/sshd && \ + ssh-keygen -A && \ + echo "Port 22" >> /etc/ssh/sshd_config && \ + echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \ + echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config && \ + echo "PermitRootLogin no" >> /etc/ssh/sshd_config # ------------------------------ # Create a non-root user for VSCode # ------------------------------ ARG USERNAME=vscode ARG USER_UID=1000 ARG USER_GID=$USER_UID - RUN groupadd --gid $USER_GID $USERNAME \ && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ && echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME - -# Make /workspace writable -RUN mkdir -p /workspace && chown -R $USERNAME:$USERNAME /workspace - +# Make /workspace writable and set up SSH directory +RUN mkdir -p /workspace && chown -R $USERNAME:$USERNAME /workspace && \ + mkdir -p /home/$USERNAME/.ssh && chmod 700 /home/$USERNAME/.ssh && \ + chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh USER $USERNAME WORKDIR /workspace - # ------------------------------ # Clone and build Chipyard (cached) # ------------------------------ ARG CHIPYARD_REPO=https://github.com/AnshKetchum/chipyard.git ARG CHIPYARD_BRANCH=main - RUN git clone --branch $CHIPYARD_BRANCH $CHIPYARD_REPO chipyard WORKDIR /workspace/chipyard - # Hack: for all directories to be trusted RUN git config --global --add safe.directory '*' - # Ensure encoding environment is set for the build user too ENV SBT_OPTS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dfile.encoding.pkg=UTF-8" ENV _JAVA_OPTIONS="-Dfile.encoding=UTF-8" - +# Install chipyard deps RUN chmod +x ./build-setup.sh && ./build-setup.sh -s 9 -s 10 +# Install Sky130 vlsi deps +RUN chmod +x ./scripts/init-sky130.sh && source env.sh && ./scripts/init-sky130.sh + +# Clone Hammer for any local development if need be +RUN git clone https://github.com/AnshKetchum/hammer /workspace/hammer # ------------------------------ # Default command diff --git a/.github/workflows/chipyard-tests.yml b/.github/workflows/chipyard-tests.yml new file mode 100644 index 0000000..ad35ed7 --- /dev/null +++ b/.github/workflows/chipyard-tests.yml @@ -0,0 +1,67 @@ +name: Chipyard Integration Tests + +on: + workflow_dispatch: + pull_request: + branches: [ main ] + +jobs: + run-chipyard-benchmarks: + runs-on: ubuntu-latest + timeout-minutes: 180 # adjust if needed + container: + image: eyeamansh/chipyard-dev:latest + options: --user root --network host + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Verify Chipyard Directory Exists + run: | + if [ ! -d "/workspace/chipyard" ]; then + echo "Error: /workspace/chipyard directory not found." + exit 1 + fi + + - name: Activate Environment + working-directory: /workspace/chipyard + shell: bash + run: | + set -e + source env.sh + echo "Environment activated." + + - name: Run DRAMSim2 Baseline Benchmark + working-directory: /workspace/chipyard/sims/verilator + shell: bash + run: | + set -e + echo "Running DRAMSim2 baseline benchmark..." + make run-binary \ + CONFIG=RocketConfig \ + BINARY=/workspace/chipyard/.conda-env/riscv-tools/riscv64-unknown-elf/share/riscv-tests/benchmarks/memcpy.riscv \ + -B | tee run_baseline.log + + echo "Checking for success pattern in run_baseline.log..." + grep -q "PASS" run_baseline.log && echo "✅ DRAMSim2 benchmark passed!" || (echo "❌ DRAMSim2 benchmark failed." && exit 1) + + - name: Clean Build Directory + working-directory: /workspace/chipyard/sims/verilator + run: | + echo "Cleaning build directory..." + make clean + + - name: Run MemorySim Benchmark + working-directory: /workspace/chipyard/sims/verilator + shell: bash + run: | + set -e + echo "Running MemorySim benchmark..." + make run-binary \ + CONFIG=MemorySimRocketConfig \ + BINARY=/workspace/chipyard/.conda-env/riscv-tools/riscv64-unknown-elf/share/riscv-tests/benchmarks/memcpy.riscv \ + -B | tee run_memorysim.log + + echo "Checking for success pattern in run_memorysim.log..." + grep -q "PASS" run_memorysim.log && echo "✅ MemorySim benchmark passed!" || (echo "❌ MemorySim benchmark failed." && exit 1) diff --git a/docs/chipyard.md b/docs/chipyard.md index 8d46de7..84c913c 100644 --- a/docs/chipyard.md +++ b/docs/chipyard.md @@ -1,6 +1,6 @@ # Running Chipyard Benchmarks -## DRAMSim Comparison +## DRAMSim 2 Comparison To compare output with DRAMSim, go ahead and run the following benchmark to establish a baseline - @@ -14,4 +14,14 @@ To run MemorySim, go ahead and run the following benchmark ```bash make run-binary CONFIG=MemorySimRocketConfig BINARY=/workspace/chipyard/.conda-env/riscv-tools/riscv64-unknown-elf/share/riscv-tests/benchmarks/memcpy.riscv -B | tee run.log +``` + + +### Running the dev container +```bash +docker run -d --privileged --network=host -it --rm --user root \ + --memory=32g --memory-swap=64g \ + --name chipyard-development-environment \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + eyeamansh/chipyard-dev:latest ``` \ No newline at end of file diff --git a/flow.sh b/flow.sh new file mode 100644 index 0000000..b4e584e --- /dev/null +++ b/flow.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Define image and tags +IMAGE_NAME="eyeamansh/chipyard-dev" +GIT_SHA=$(git rev-parse --short HEAD) + +echo "[info] Building Docker image for chipyard-dev..." +docker build --network=host -t chipyard-dev -f .devcontainer/Dockerfile . + +echo "[info] Tagging image with commit SHA and latest..." +docker tag chipyard-dev "${IMAGE_NAME}:${GIT_SHA}" +docker tag chipyard-dev "${IMAGE_NAME}:latest" + +echo "[info] Pushing image to Docker Hub..." +docker push "${IMAGE_NAME}:${GIT_SHA}" +docker push "${IMAGE_NAME}:latest" + +echo "[success] Pushed:" +echo " - ${IMAGE_NAME}:${GIT_SHA}" +echo " - ${IMAGE_NAME}:latest"