Skip to content

Commit ba5dda9

Browse files
committed
test fpga sim
1 parent a46d9f4 commit ba5dda9

File tree

2 files changed

+113
-19
lines changed

2 files changed

+113
-19
lines changed

.github/workflows/xiangshan.yml

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,74 @@ on:
99
- cron: '00 14 * * *'
1010

1111
jobs:
12-
xiangshan-difftest:
12+
# xiangshan-pldm-sim:
13+
# strategy:
14+
# fail-fast: false
15+
# matrix:
16+
# branch: [ master, kunminghu-v3 ]
17+
# topo:
18+
# - name: single
19+
# num_cores: 1
20+
# workload: "$NOOP_HOME/ready-to-run/linux.bin"
21+
# ref: "$NOOP_HOME/ready-to-run/riscv64-nemu-interpreter-so"
22+
# - name: dual
23+
# num_cores: 2
24+
# workload: "/nfs/home/share/ci-workloads/linux-hello-smp-new/bbl.bin"
25+
# ref: "$NOOP_HOME/ready-to-run/riscv64-nemu-interpreter-dual-so"
26+
# debug_args: [ "--difftest-config ZESNHP" ]
27+
# config: [ DefaultConfig ]
28+
29+
# runs-on: self-hosted
30+
# timeout-minutes: 720
31+
# name: ${{ matrix.branch }}-${{ matrix.topo.name }}
32+
# steps:
33+
# - uses: actions/checkout@v4
34+
35+
# - name: Set Env
36+
# run: |
37+
# source /nfs/home/ci-runner/ci-runner-difftest/tools/env.sh
38+
39+
# - name: Prepare XiangShan
40+
# run: |
41+
# cd $GITHUB_WORKSPACE/..
42+
# NOOP_HOME="$PWD/XiangShan-${{ matrix.branch }}"
43+
# echo "NOOP_HOME=$NOOP_HOME" >> "$GITHUB_ENV"
44+
# if [ ! -d "$NOOP_HOME" ]; then
45+
# git clone -b ${{ matrix.branch }} --single-branch https://github.com/OpenXiangShan/XiangShan.git $NOOP_HOME
46+
# fi
47+
# cd $NOOP_HOME
48+
# git fetch --depth=1 origin ${{ matrix.branch }}
49+
# git checkout ${{ matrix.branch }}
50+
# git reset --hard origin/${{ matrix.branch }}
51+
# rm -rf difftest && make init
52+
# rm -rf difftest && cp -r $GITHUB_WORKSPACE .
53+
# make clean
54+
55+
# - name: Generate Verilog
56+
# run: |
57+
# cd $NOOP_HOME
58+
# make sim-verilog PLDM=1 NUM_CORES=${{ matrix.topo.num_cores }} DEBUG_ARGS="${{ matrix.debug_args }}" CONFIG=${{ matrix.config }} WITH_CHISELDB=0 WITH_CONSTANTIN=0 -j200
59+
60+
# - name: Build SIMV
61+
# run: |
62+
# cd $NOOP_HOME
63+
# make simv VCS=verilator NUM_CORES=${{ matrix.topo.num_cores }} WITH_CHISELDB=0 WITH_CONSTANTIN=0 DIFFTEST_PERFCNT=1 EMU_THREADS=16 \
64+
# PGO_WORKLOAD=${{ matrix.topo.workload }} PGO_MAX_CYCLE=400000 LLVM_PROFDATA=llvm-profdata -j200
65+
66+
# - name: Test with Linux
67+
# run: |
68+
# cd $NOOP_HOME
69+
# ulimit -s 32768
70+
# ./build/simv +workload=${{ matrix.topo.workload }} +diff=${{ matrix.topo.ref }} 2>&1 | tee pldm.log
71+
72+
xiangshan-fpga-sim:
1373
strategy:
1474
fail-fast: false
1575
matrix:
16-
branch: [ master, kunminghu-v3 ]
17-
topo:
18-
- name: single
19-
num_cores: 1
20-
workload: "$NOOP_HOME/ready-to-run/linux.bin"
21-
ref: "$NOOP_HOME/ready-to-run/riscv64-nemu-interpreter-so"
22-
- name: dual
23-
num_cores: 2
24-
workload: "/nfs/home/share/ci-workloads/linux-hello-smp-new/bbl.bin"
25-
ref: "$NOOP_HOME/ready-to-run/riscv64-nemu-interpreter-dual-so"
26-
debug_args: [ "--difftest-config ZESNHP" ]
27-
config: [ DefaultConfig ]
28-
76+
branch: [ master ]
77+
# branch: [ master, kunminghu-v3 ]
2978
runs-on: self-hosted
3079
timeout-minutes: 720
31-
name: ${{ matrix.branch }}-${{ matrix.topo.name }}
3280
steps:
3381
- uses: actions/checkout@v4
3482

@@ -55,16 +103,26 @@ jobs:
55103
- name: Generate Verilog
56104
run: |
57105
cd $NOOP_HOME
58-
make sim-verilog PLDM=1 NUM_CORES=${{ matrix.topo.num_cores }} DEBUG_ARGS="${{ matrix.debug_args }}" CONFIG=${{ matrix.config }} WITH_CHISELDB=0 WITH_CONSTANTIN=0 -j200
106+
make sim-verilog FPGA=1 DEBUG_ARGS="--difftest-config ESBIFDU" CONFIG=FpgaDiffDefaultConfig WITH_CHISELDB=0 WITH_CONSTANTIN=0 -j200
107+
108+
- name: Build Fpga Host
109+
run: |
110+
cd $NOOP_HOME
111+
make -C difftest fpga-build FPGA=1 FPGA_SIM=1 DIFFTEST_PERFCNT=1 -j200
59112
60113
- name: Build SIMV
61114
run: |
62115
cd $NOOP_HOME
63-
make simv VCS=verilator NUM_CORES=${{ matrix.topo.num_cores }} WITH_CHISELDB=0 WITH_CONSTANTIN=0 DIFFTEST_PERFCNT=1 EMU_THREADS=16 \
64-
PGO_WORKLOAD=${{ matrix.topo.workload }} PGO_MAX_CYCLE=400000 LLVM_PROFDATA=llvm-profdata -j200
116+
make simv VCS=verilator FPGA_SIM=1 WITH_CHISELDB=0 WITH_CONSTANTIN=0 DIFFTEST_PERFCNT=1 EMU_THREADS=16 -j200
117+
118+
- name: Test with Microbench
119+
run: |
120+
cd $NOOP_HOME
121+
ulimit -s 32768
122+
bash difftest/scripts/fpga_sim/ci.sh | tee fpga-microbench.log
65123
66124
- name: Test with Linux
67125
run: |
68126
cd $NOOP_HOME
69127
ulimit -s 32768
70-
./build/simv +workload=${{ matrix.topo.workload }} +diff=${{ matrix.topo.ref }} 2>&1 | tee simv.log
128+
bash difftest/scripts/fpga_sim/ci-linux.sh | tee fpga-linux.log

scripts/fpga_sim/ci-linux.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
set -e # exit when some command failed
2+
set -o pipefail
3+
4+
HOST_PID=""
5+
SIMV_PID=""
6+
7+
cleanup() {
8+
echo "[CLEANUP] kill fpga-host and simv..."
9+
trap - INT TERM EXIT
10+
if [[ -n "$SIMV_PID" ]]; then
11+
kill -INT "$SIMV_PID" 2>/dev/null || true
12+
fi
13+
14+
if [[ -n "$HOST_PID" ]]; then
15+
kill -INT "$HOST_PID" 2>/dev/null || true
16+
fi
17+
}
18+
19+
trap cleanup INT TERM EXIT
20+
21+
./build/fpga-host --diff ready-to-run/riscv64-nemu-interpreter-so -i ready-to-run/linux.bin &
22+
HOST_PID=$!
23+
24+
sleep 2
25+
26+
./build/simv +workload=./ready-to-run/linux.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so & #> build/try.txt 2>&1 &
27+
SIMV_PID=$!
28+
29+
set +e # disable exit to get exitCode
30+
wait $HOST_PID
31+
HOST_EXIT_CODE=$?
32+
set -e
33+
34+
kill -9 $SIMV_PID
35+
36+
exit $HOST_EXIT_CODE

0 commit comments

Comments
 (0)