-
Notifications
You must be signed in to change notification settings - Fork 68
462 lines (407 loc) · 19.4 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
test-difftest-main:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Mill Installation
run: |
sudo curl -L https://github.com/com-lihaoyi/mill/releases/download/0.11.1/0.11.1 > /usr/local/bin/mill
chmod +x /usr/local/bin/mill
- name: Compile
run: |
mill -i design[chisel3].compile
mill -i design[chisel].compile
- name: Generate Verilog
run: |
make MFC=0
make MFC=1
test-difftest-nutshell:
runs-on: ubuntu-22.04
needs: test-difftest-main
steps:
- uses: actions/checkout@v4
- name: Enable -Werror for EMU Build
run: |
echo "CXX_NO_WARNING=1" >> $GITHUB_ENV
- name: Prepare environment
run: |
cd $GITHUB_WORKSPACE/..
git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://
git clone https://github.com/OpenXiangShan/xs-env
cd xs-env
sudo -s ./setup-tools.sh
source ./setup.sh
- name: Prepare NutShell
run: |
cd $GITHUB_WORKSPACE/../xs-env
rm -r NutShell
git clone -b dev-difftest --single-branch https://github.com/OSCPU/NutShell.git
cd NutShell && git submodule update --init
rm -r difftest
cp -r $GITHUB_WORKSPACE .
- name: Simulation without DiffTest
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu NO_DIFF=1 EMU_TRACE=1 -j2
./build/emu -b 0 -e 100 -i ./ready-to-run/microbench.bin --dump-wave -C 10000
./build/emu -b 0 -e 100 -i ./ready-to-run/microbench.bin --dump-wave-full -C 10000
- name: Simulation with No Diff
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --no-diff
- name: Basic Difftest
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Basic Difftest without Image
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
./build/emu -b 0 -e 0 --no-diff -C 10000
- name: Basic Difftest with PGO build
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make -C ./difftest clean_obj
make emu PGO_WORKLOAD=`realpath ready-to-run/microbench.bin` LLVM_PROFDATA=llvm-profdata PGO_EMU_ARGS="--diff `realpath ./ready-to-run/riscv64-nemu-interpreter-so` 2>/dev/null" -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Snapshot
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_SNAPSHOT=1 -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Trace
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_TRACE=1 -j2
./build/emu -b 10 -e 12 -i ./ready-to-run/microbench.bin --dump-wave --diff ./ready-to-run/riscv64-nemu-interpreter-so
./build/emu -b 10 -e 12 -i ./ready-to-run/microbench.bin --dump-wave-full --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with two threads
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu EMU_THREADS=2 -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Verilator Coverage
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
rm -rf *.coverage
make emu EMU_COVERAGE=1 -j2
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so -C 10000 --dump-coverage
make -C difftest coverage
ls -lh *.coverage
- name: Difftest with DiffTrace
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu -j2
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --dump-difftrace microbench
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --load-difftrace microbench
- name: Difftest with Footprints
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu -j2
./build/emu -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --dump-footprints microbench.bin
./build/emu -e 0 -i microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --as-footprints
- name: Difftest with Batch
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu MILL_ARGS="--difftest-config B" -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Global DPI-C Enable
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu MILL_ARGS="--difftest-config E" -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Squash and Global Enable
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu MILL_ARGS="--difftest-config ES" -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with Squash Batch and Global Enable
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu MILL_ARGS="--difftest-config ESB" -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so
- name: Difftest with JsonProfile and DiffTestIOTrace
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu MILL_ARGS="--difftest-config ET" -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --iotrace-name iotrace
cd difftest && export NOOP_HOME=$(pwd)
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=EL MFC=1
make emu WITH_CHISELDB=0 WITH_CONSTANTIN=0 -j2
./build/emu -b 0 -e 0 -i ../ready-to-run/microbench.bin --diff ../ready-to-run/riscv64-nemu-interpreter-so --iotrace-name ../iotrace
- name: Difftest with JsonProfile and DiffTestIOTrace-ZSTD
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make emu MILL_ARGS="--difftest-config ET" IOTRACE_ZSTD=1 -j2
./build/emu -b 0 -e 0 -i ./ready-to-run/microbench.bin --diff ./ready-to-run/riscv64-nemu-interpreter-so --iotrace-name iotrace
cd difftest && export NOOP_HOME=$(pwd)
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=EL MFC=1
make emu WITH_CHISELDB=0 WITH_CONSTANTIN=0 IOTRACE_ZSTD=1 -j2
./build/emu -b 0 -e 0 -i ../ready-to-run/microbench.bin --diff ../ready-to-run/riscv64-nemu-interpreter-so --iotrace-name ../iotrace
test-difftest-fuzzing:
# This test runs on ubuntu-20.04 for two reasons:
# (1) riscv-arch-test can be built with riscv-linux-gnu toolchain 9.4.0,
# which is the default apt-installed version on ubuntu 20.04.
# On ubuntu 22.04, toolchain 11.4.0 won't compile riscv-arch-test.
# (2) to test whether difftest compiles correctly on ubuntu 20.04
runs-on: ubuntu-20.04
needs: test-difftest-main
steps:
- uses: actions/checkout@v4
- name: Enable -Werror for EMU Build
run: |
echo "CXX_NO_WARNING=1" >> $GITHUB_ENV
- name: Prepare environment
run: |
cd $GITHUB_WORKSPACE/..
git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://
git clone https://github.com/OpenXiangShan/xs-env
cd xs-env
sudo -s ./setup-tools.sh
- name: Build the coverage-guided fuzzer - xfuzz
run: |
cd $GITHUB_WORKSPACE/..
git clone https://github.com/OpenXiangShan/xfuzz.git
cargo install cargo-make
cd xfuzz && make init && make build
- name: Build the fuzzing corpus - riscv-arch-test
run: |
cd $GITHUB_WORKSPACE/..
git clone https://github.com/OpenXiangShan/riscv-arch-test.git
cd riscv-arch-test/riscv-test-suite
make build_I CROSS=riscv64-linux-gnu- RISCV_ARCH=rv64gc -j2
rm build/*.elf build/*.txt
- name: Build the REF - LLVM instrumented Spike
run: |
cd $GITHUB_WORKSPACE/..
git clone https://github.com/OpenXiangShan/riscv-isa-sim.git
export SPIKE_HOME=$(pwd)/riscv-isa-sim
make -C riscv-isa-sim/difftest CPU=ROCKET_CHIP SANCOV=1 -j2
- name: Build and run the rocket-chip fuzzer
run: |
cd $GITHUB_WORKSPACE/..
export SPIKE_HOME=$(pwd)/riscv-isa-sim
export XFUZZ_HOME=$(pwd)/xfuzz
export NOOP_HOME=$(pwd)/rocket-chip
export CORPUS=$(pwd)/riscv-arch-test/riscv-test-suite/build
git clone -b dev-difftest --single-branch https://github.com/OpenXiangShan/rocket-chip.git
cd rocket-chip && make init
rm -r difftest
cp -r $GITHUB_WORKSPACE .
make bootrom CROSS=riscv64-linux-gnu-
make emu XFUZZ=1 REF=$SPIKE_HOME/difftest/build/riscv64-spike-so LLVM_COVER=1 -j2
./build/fuzzer -v -- $CORPUS/I-add-01.bin
./build/fuzzer -f --max-runs 100 --corpus-input $CORPUS -- --max-cycles 10000 | grep max_runs
test-difftest-vcs:
runs-on: ubuntu-22.04
needs: test-difftest-main
steps:
- uses: actions/checkout@v4
- name: Enable -Werror for EMU Build
run: |
echo "CXX_NO_WARNING=1" >> $GITHUB_ENV
- name: Prepare environment
run: |
cd $GITHUB_WORKSPACE/..
git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://
git clone https://github.com/OpenXiangShan/xs-env
cd xs-env
sudo -s ./setup-tools.sh
source ./setup.sh
- name: Prepare NutShell
run: |
cd $GITHUB_WORKSPACE/../xs-env
rm -r NutShell
git clone -b dev-difftest --single-branch https://github.com/OSCPU/NutShell.git
cd NutShell && git submodule update --init
rm -r difftest
cp -r $GITHUB_WORKSPACE .
- name: Verilator Build with VCS Top (NO_DIFF)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv NO_DIFF=1 VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +max-cycles=100000
- name: Verilator Build with VCS Top (SYNTHESIS)(with DutZone)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config Z" SYNTHESIS=1 VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000
- name: Verilator Build with VCS Top (disable DPIC RAM/FLASH)(with DutZone)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config Z" DISABLE_DIFFTEST_RAM_DPIC=1 DISABLE_DIFFTEST_FLASH_DPIC=1 VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so
- name: Verilator Build with VCS Top (with DutZone PerfCnt)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config ZP" DIFFTEST_PERFCNT=1 VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so
- name: Verilator Build with VCS Top (with Batch InternalStep PerfCnt)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config BIP" DIFFTEST_PERFCNT=1 VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so
- name: Verilator Build with VCS Top (with GlobalEnable Squash Replay Batch PerfCnt)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config ESRBP" DIFFTEST_PERFCNT=1 VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so
- name: Verilator Build with VCS Top (with GlobalEnable Squash Replay Batch InternalStep NonBlock PerfCnt)
run: |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config ESRBINP" DIFFTEST_PERFCNT=1 VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +no-diff +max-cycles=100000
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so
- name: Verilator Build with VCS Top (with workload-list)
run : |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
echo "./ready-to-run/microbench.bin 10000" > list.txt
echo "./ready-to-run/linux.bin 20000" >> list.txt
make simv VCS=verilator WORKLOAD_SWITCH=1 -j2
./build/simv +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so +workload-list=./list.txt
- name: Verilator Build with VCS Top (with JsonProfile and DiffTestIOTrace)
run : |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config ZET" VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=iotrace
cd difftest && export NOOP_HOME=$(pwd)
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=ZEL MFC=1
make simv VCS=verilator WITH_CHISELDB=0 WITH_CONSTANTIN=0
./build/simv +workload=../ready-to-run/microbench.bin +e=0 +diff=../ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=../iotrace
- name: Verilator Build with VCS Top (with JsonProfile and DiffTestIOTrace-ZSTD)
run : |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv MILL_ARGS="--difftest-config ZET" VCS=verilator IOTRACE_ZSTD=1 -j2
./build/simv +workload=./ready-to-run/microbench.bin +e=0 +diff=./ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=iotrace
cd difftest && export NOOP_HOME=$(pwd)
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=ZEL MFC=1
make simv VCS=verilator WITH_CHISELDB=0 WITH_CONSTANTIN=0 IOTRACE_ZSTD=1
./build/simv +workload=../ready-to-run/microbench.bin +e=0 +diff=../ready-to-run/riscv64-nemu-interpreter-so +iotrace-name=../iotrace
- name: Verilator Build with VCS Top (with LogPerf and WarmUp)
run : |
cd $GITHUB_WORKSPACE/../xs-env
source ./env.sh
cd $GITHUB_WORKSPACE/../xs-env/NutShell
source ./env.sh
make clean
make simv VCS=verilator -j2
./build/simv +workload=./ready-to-run/microbench.bin +b=0 +e=-1 +diff=./ready-to-run/riscv64-nemu-interpreter-so +max-instrs=5000 +warmup_instr=1000