Skip to content

Commit b255026

Browse files
committed
modify ci cd to run mx tests only and compare against new spike
1 parent 2255cac commit b255026

5 files changed

Lines changed: 192 additions & 21 deletions

File tree

.github/scripts/defaults.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,32 @@ LOCAL_CHIPYARD_DIR=$REMOTE_WORK_DIR
1515
LOCAL_SIM_DIR=$LOCAL_CHIPYARD_DIR/sims/verilator
1616

1717
CICONFIG=chipyard.config.WithNoDebug_GemminiRocketConfig
18+
19+
# Branches used by install-gemmini.sh. The chipyard branch needs the
20+
# RadianceGemminiOnlyConfig (graphics) and the gemmini submodule pinned to
21+
# gemmini-mx-cleanup so chipyard's build-setup picks up the same RoCC funct
22+
# layout the spike libgemmini and the rocc tests expect.
23+
CHIPYARD_BRANCH=${CHIPYARD_BRANCH:-graphics}
24+
GEMMINI_SUBMODULE_BRANCH=${GEMMINI_SUBMODULE_BRANCH:-gemmini-mx-cleanup}
25+
26+
# RTL config used for the MX (FP4/FP6/FP8) functional-equivalence job.
27+
MX_CICONFIG=RadianceGemminiOnlyConfig
28+
29+
# The 13 ported MX tiled-matmul tests (passing on spike; expected to pass on
30+
# RTL). matmul_tiled_fp4_64x64_DRAMMvout is intentionally omitted: it uses the
31+
# accumulator -> DRAM mvout path that the spike kernel does not model.
32+
MX_TESTS=(
33+
matmul_tiled_fp8_64x64
34+
matmul_tiled_fp8_128x128
35+
matmul_tiled_fp8_128x128x256
36+
matmul_tiled_fp8_128x128_requant
37+
matmul_tiled_fp4_64x64
38+
matmul_tiled_fp4_64x64_requant
39+
matmul_tiled_fp4_128x128
40+
matmul_tiled_fp4_128x128_requant
41+
matmul_tiled_fp4_128x128x512
42+
matmul_tiled_fp4_128x128x512_requant
43+
matmul_tiled_fp6_128x128
44+
matmul_tiled_fp6_128x128x512
45+
matmul_tiled_fp6_128x128x512_requant
46+
)

.github/scripts/do-rtl-build-mx.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Verilator build of the MX (FP4/FP6/FP8) RTL config used by run-tests-mx.sh.
4+
5+
set -ex
6+
7+
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
8+
source $SCRIPT_DIR/defaults.sh
9+
10+
eval "$(conda shell.bash hook)"
11+
12+
cd $LOCAL_CHIPYARD_DIR
13+
source env.sh
14+
15+
cd $LOCAL_SIM_DIR
16+
make -j$LOCAL_MAKE_NPROC -C $LOCAL_SIM_DIR CONFIG=$MX_CICONFIG

.github/scripts/install-gemmini.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ git clone --progress --verbose https://github.com/ucb-bar/chipyard.git $LOCAL_CH
1515
cd $LOCAL_CHIPYARD_DIR
1616

1717
git fetch
18-
git checkout $(cat $LOCAL_CHECKOUT_DIR/CHIPYARD.hash)
18+
git checkout $CHIPYARD_BRANCH
19+
20+
# Pin the gemmini submodule (used by build-setup.sh) to the branch matching
21+
# this PR's RoCC funct layout. Submodules are otherwise init'd at chipyard's
22+
# recorded gitlink commit, which can be ahead/behind for MX work.
23+
git submodule update --init generators/gemmini
24+
git -C generators/gemmini fetch origin
25+
git -C generators/gemmini checkout $GEMMINI_SUBMODULE_BRANCH
1926

2027
export MAKEFLAGS="-j32"
2128
./build-setup.sh riscv-tools -s 6 -s 7 -s 8 -s 9 -v

.github/scripts/run-tests-mx.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
3+
# Run the ported MX (FP4/FP6/FP8) tiled-matmul tests on both spike and
4+
# verilator. Each test self-checks against the Python golden header and
5+
# prints "PASSED" or "FAILED"; we accept the test iff both simulators see
6+
# PASSED. No byte-level diff is performed (verilator is slow).
7+
8+
set -e
9+
set -o pipefail
10+
11+
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
12+
source $SCRIPT_DIR/defaults.sh
13+
14+
eval "$(conda shell.bash hook)"
15+
16+
cd $LOCAL_CHIPYARD_DIR
17+
source env.sh
18+
19+
# Install the in-repo libgemmini.so over chipyard's stale copy.
20+
cd $LOCAL_CHECKOUT_DIR
21+
chown -R $(whoami) .
22+
git config --global --add safe.directory $LOCAL_CHECKOUT_DIR
23+
git config --global --add safe.directory '*'
24+
rm -rf $RISCV/lib/libgemmini.so
25+
git submodule update --init software/libgemmini
26+
make -C software/libgemmini install
27+
28+
TESTS_DIR=$LOCAL_CHIPYARD_DIR/generators/gemmini/software/gemmini-rocc-tests
29+
30+
# Build both binary flavours:
31+
# build_spike/ -> -DSPIKE_SIM ROCC-only path
32+
# build/ -> default MMIO path used by RTL
33+
cd $TESTS_DIR
34+
./build_spike.sh
35+
./build.sh
36+
37+
PASS=()
38+
FAIL=()
39+
40+
run_one() {
41+
local sim=$1 # "spike" or "rtl"
42+
local name=$2
43+
local logfile=$3
44+
if grep -q "PASSED" "$logfile"; then
45+
PASS+=("$sim:$name")
46+
else
47+
FAIL+=("$sim:$name")
48+
echo "--- $sim:$name FAILED (last 20 lines): ---"
49+
tail -n 20 "$logfile" || true
50+
fi
51+
}
52+
53+
echo "================================================================"
54+
echo " MX tests on spike"
55+
echo "================================================================"
56+
for t in "${MX_TESTS[@]}"; do
57+
bin=$TESTS_DIR/build_spike/bareMetalC/${t}-baremetal
58+
log=/tmp/mx-spike-${t}.log
59+
if [ ! -f "$bin" ]; then
60+
FAIL+=("spike:$t (binary missing)")
61+
continue
62+
fi
63+
spike --extension=gemmini "$bin" > "$log" 2>&1 || true
64+
run_one spike "$t" "$log"
65+
done
66+
67+
echo "================================================================"
68+
echo " MX tests on verilator (CONFIG=$MX_CICONFIG)"
69+
echo "================================================================"
70+
cd $LOCAL_SIM_DIR
71+
for t in "${MX_TESTS[@]}"; do
72+
bin=$TESTS_DIR/build/bareMetalC/${t}-baremetal
73+
log=/tmp/mx-rtl-${t}.log
74+
if [ ! -f "$bin" ]; then
75+
FAIL+=("rtl:$t (binary missing)")
76+
continue
77+
fi
78+
make -C $LOCAL_SIM_DIR run-binary CONFIG=$MX_CICONFIG LOADMEM=1 BINARY="$bin" \
79+
> "$log" 2>&1 || true
80+
run_one rtl "$t" "$log"
81+
done
82+
83+
echo "================================================================"
84+
echo " Summary"
85+
echo "================================================================"
86+
echo "Passed (${#PASS[@]}/$((2*${#MX_TESTS[@]}))):"
87+
for p in "${PASS[@]}"; do echo " PASS $p"; done
88+
echo "Failed (${#FAIL[@]}/$((2*${#MX_TESTS[@]}))):"
89+
for f in "${FAIL[@]}"; do echo " FAIL $f"; done
90+
91+
exit ${#FAIL[@]}

.github/workflows/config.yml

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,48 @@ jobs:
2323
run: |
2424
.github/scripts/install-gemmini.sh
2525
26-
spike-run-tests:
27-
runs-on: as4
28-
needs: install-gemmini
29-
steps:
30-
- name: Delete old checkout
31-
run: |
32-
rm -rf ${{ github.workspace }}/* || true
33-
rm -rf ${{ github.workspace }}/.* || true
34-
- uses: actions/checkout@v3
35-
- name: Run Gemmini Spike tests
36-
run: |
37-
.github/scripts/run-tests-spike.sh
26+
# Legacy non-MX CI jobs (spike sanity + WithNoDebug_GemminiRocketConfig RTL).
27+
# Disabled while the MX (FP4/FP6/FP8) track is the active gate.
28+
# spike-run-tests:
29+
# runs-on: as4
30+
# needs: install-gemmini
31+
# steps:
32+
# - name: Delete old checkout
33+
# run: |
34+
# rm -rf ${{ github.workspace }}/* || true
35+
# rm -rf ${{ github.workspace }}/.* || true
36+
# - uses: actions/checkout@v3
37+
# - name: Run Gemmini Spike tests
38+
# run: |
39+
# .github/scripts/run-tests-spike.sh
40+
#
41+
# build-gemmini-config:
42+
# runs-on: as4
43+
# needs: install-gemmini
44+
# steps:
45+
# - name: Delete old checkout
46+
# run: |
47+
# rm -rf ${{ github.workspace }}/* || true
48+
# rm -rf ${{ github.workspace }}/.* || true
49+
# - uses: actions/checkout@v3
50+
# - name: Building Gemmini Config using Verilator
51+
# run: |
52+
# .github/scripts/do-rtl-build.sh
53+
#
54+
# rtl-run-tests:
55+
# runs-on: as4
56+
# needs: build-gemmini-config
57+
# steps:
58+
# - name: Delete old checkout
59+
# run: |
60+
# rm -rf ${{ github.workspace }}/* || true
61+
# rm -rf ${{ github.workspace }}/.* || true
62+
# - uses: actions/checkout@v3
63+
# - name: Run Gemmini Config tests using Verilator
64+
# run: |
65+
# .github/scripts/run-tests-rtl.sh
3866

39-
build-gemmini-config:
67+
build-mx-config:
4068
runs-on: as4
4169
needs: install-gemmini
4270
steps:
@@ -45,26 +73,26 @@ jobs:
4573
rm -rf ${{ github.workspace }}/* || true
4674
rm -rf ${{ github.workspace }}/.* || true
4775
- uses: actions/checkout@v3
48-
- name: Building Gemmini Config using Verilator
76+
- name: Build MX (RadianceGemminiOnlyConfig) RTL with Verilator
4977
run: |
50-
.github/scripts/do-rtl-build.sh
78+
.github/scripts/do-rtl-build-mx.sh
5179
52-
rtl-run-tests:
80+
mx-run-tests:
5381
runs-on: as4
54-
needs: build-gemmini-config
82+
needs: build-mx-config
5583
steps:
5684
- name: Delete old checkout
5785
run: |
5886
rm -rf ${{ github.workspace }}/* || true
5987
rm -rf ${{ github.workspace }}/.* || true
6088
- uses: actions/checkout@v3
61-
- name: Run Gemmini Config tests using Verilator
89+
- name: Run MX (FP4/FP6/FP8) tests on spike and Verilator
6290
run: |
63-
.github/scripts/run-tests-rtl.sh
91+
.github/scripts/run-tests-mx.sh
6492
6593
cleanup:
6694
name: cleanup
67-
needs: [spike-run-tests, rtl-run-tests]
95+
needs: [mx-run-tests]
6896
runs-on: as4
6997
if: ${{ always() }}
7098
steps:

0 commit comments

Comments
 (0)