Skip to content

Commit e8aff52

Browse files
committed
Update riscv vector test compilation to be more efficient and fix workflow file
1 parent 183e274 commit e8aff52

File tree

4 files changed

+65
-108
lines changed

4 files changed

+65
-108
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Checkout code
24-
uses: actions/checkout@v2
24+
uses: actions/checkout@v4
2525
with:
2626
submodules: recursive
2727

@@ -71,7 +71,7 @@ jobs:
7171

7272
steps:
7373
- name: Checkout code
74-
uses: actions/checkout@v2
74+
uses: actions/checkout@v4
7575

7676
- name: Install Dependencies
7777
run: |
@@ -114,70 +114,16 @@ jobs:
114114
tests:
115115
runs-on: ubuntu-20.04
116116
needs: build
117+
timeout-minutes: 90
117118
strategy:
118119
fail-fast: false
119120
matrix:
120-
name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm]
121+
name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm, vector]
121122
xlen: [32, 64]
122123

123124
steps:
124125
- name: Checkout code
125-
uses: actions/checkout@v2
126-
127-
- name: Install Dependencies
128-
run: |
129-
sudo bash ./ci/install_dependencies.sh
130-
131-
- name: Cache Toolchain Directory
132-
id: cache-toolchain
133-
uses: actions/cache@v4
134-
with:
135-
path: tools
136-
key: ${{ runner.os }}-toolchain-v0.1
137-
restore-keys: |
138-
${{ runner.os }}-toolchain-
139-
140-
- name: Cache Third Party Directory
141-
id: cache-thirdparty
142-
uses: actions/cache@v4
143-
with:
144-
path: third_party
145-
key: ${{ runner.os }}-thirdparty-v0.1
146-
restore-keys: |
147-
${{ runner.os }}-thirdparty-
148-
149-
- name: Download Build Artifact
150-
uses: actions/download-artifact@v4
151-
with:
152-
name: build-${{ matrix.xlen }}
153-
path: build${{ matrix.xlen }}
154-
155-
- name: Run tests
156-
run: |
157-
cd build${{ matrix.xlen }}
158-
source ci/toolchain_env.sh
159-
chmod -R +x . # Ensure all files have executable permissions
160-
if [ "${{ matrix.name }}" == "regression" ]; then
161-
./ci/regression.sh --unittest
162-
./ci/regression.sh --isa
163-
./ci/regression.sh --kernel
164-
./ci/regression.sh --regression
165-
else
166-
./ci/regression.sh --${{ matrix.name }}
167-
fi
168-
169-
vector-tests:
170-
runs-on: ubuntu-22.04
171-
needs: build
172-
strategy:
173-
fail-fast: false
174-
matrix:
175-
name: [vector]
176-
xlen: [32, 64]
177-
178-
steps:
179-
- name: Checkout code
180-
uses: actions/checkout@v2
126+
uses: actions/checkout@v4
181127

182128
- name: Install Dependencies
183129
run: |

ci/regression.sh.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ config1()
221221
CONFIGS="-DISSUE_WIDTH=2" ./ci/blackbox.sh --driver=simx --app=diverge
222222
CONFIGS="-DISSUE_WIDTH=4" ./ci/blackbox.sh --driver=simx --app=diverge
223223

224+
# simd width
225+
CONFIGS="-DSIMD_WIDTH=1" ./ci/blackbox.sh --driver=rtlsim --app=dogfood --args="-ttrig"
226+
CONFIGS="-DSIMD_WIDTH=2" ./ci/blackbox.sh --driver=rtlsim --app=dogfood --args="-ttrig"
227+
CONFIGS="-DSIMD_WIDTH=1" ./ci/blackbox.sh --driver=simx --app=dogfood --args="-ttrig"
228+
CONFIGS="-DSIMD_WIDTH=2" ./ci/blackbox.sh --driver=simx --app=dogfood --args="-ttrig"
229+
224230
# ALU scaling
225231
CONFIGS="-DISSUE_WIDTH=2 -DNUM_ALU_BLOCK=1 -DNUM_ALU_LANES=2" ./ci/blackbox.sh --driver=rtlsim --app=diverge
226232
CONFIGS="-DISSUE_WIDTH=4 -DNUM_ALU_BLOCK=4 -DNUM_ALU_LANES=4" ./ci/blackbox.sh --driver=rtlsim --app=diverge
@@ -394,8 +400,8 @@ vector()
394400
{
395401
echo "begin vector tests..."
396402

397-
make -C sim/simx clean && CONFIGS="-DEXT_V_ENABLE" make -C sim/simx
398-
TOOLDIR=@TOOLDIR@ XLEN=@XLEN@ VLEN=256 REG_TESTS=1 GEN_TESTS=1 ./tests/riscv/riscv-vector-tests/run-test.sh
403+
make -C sim/simx clean && CONFIGS="-DVLEN=256 -DEXT_V_ENABLE" make -C sim/simx
404+
VLEN=256 REG_TESTS=1 GEN_TESTS=1 ./tests/riscv/riscv-vector-tests/run-test.sh
399405

400406
echo "vector tests done!"
401407
}

tests/riscv/riscv-vector-tests/gen-test.sh.in

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
#!/bin/bash
22

3+
XLEN=${XLEN:-"@XLEN@"}
4+
TOOLDIR=${TOOLDIR:-"@TOOLDIR@"}
5+
RISCV_TOOLCHAIN_PATH=${RISCV_TOOLCHAIN_PATH:-"$TOOLDIR/riscv$XLEN-gnu-toolchain"}
6+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
37
PREV_DIR=$(pwd)
48

59
sudo apt-get install device-tree-compiler
610
wget -O- -q https://go.dev/dl/go1.24.0.linux-amd64.tar.gz | tar -xzf -
711

8-
git clone https://github.com/chipsalliance/riscv-vector-tests.git
12+
export RISCV=$RISCV_TOOLCHAIN_PATH
13+
export PATH=$PATH:$PREV_DIR/go/bin:$RISCV/bin
14+
15+
git clone --recursive https://github.com/chipsalliance/riscv-vector-tests.git
916
cd riscv-vector-tests
10-
wget -O- -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.04.12/riscv64-elf-ubuntu-22.04-gcc-nightly-2024.04.12-nightly.tar.gz | tar -xzf -
11-
export RISCV=$PREV_DIR/riscv-vector-tests/riscv
12-
export PATH=$PATH:$PREV_DIR/go/bin:$PREV_DIR/riscv-vector-tests/riscv/bin
1317

14-
git clone https://github.com/riscv-software-src/riscv-isa-sim.git
18+
git clone --recursive https://github.com/riscv-software-src/riscv-isa-sim.git
1519
cd riscv-isa-sim
1620
git reset --hard 91793ed7d964aa0031c5a9a31fa05ec3d11b3b0f
1721
mkdir build && cd build
1822
../configure --prefix=$RISCV
1923
make -j$(nproc) && sudo make install
2024
cd ../..
2125

22-
cd env
23-
git clone https://github.com/riscv/riscv-test-env.git
24-
cd ..
25-
26-
make generate-stage1 --environment-overrides VLEN=$VLEN XLEN=$XLEN MARCH=rv"$XLEN"imafv_zve"$XLEN"f MODE=machine && make all -j$(nproc) --environment-overrides VLEN=$VLEN XLEN=$XLEN MARCH=rv"$XLEN"imafv_zve"$XLEN"f MODE=machine
26+
make generate-stage1 --environment-overrides VLEN=$VLEN XLEN=$XLEN MARCH=rv"$XLEN"imafv_zve"$XLEN"f MODE=machine
27+
make all -j$(nproc) --environment-overrides VLEN=$VLEN XLEN=$XLEN MARCH=rv"$XLEN"imafv_zve"$XLEN"f MODE=machine
2728
mv out/v"$VLEN"x"$XLEN"machine/bin/stage2 $PREV_DIR/v"$VLEN"x"$XLEN"
2829

2930
cd $PREV_DIR
Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/bin/bash
2-
RISCV_TOOLCHAIN_PATH=${RISCV_TOOLCHAIN_PATH:-$TOOLDIR"/riscv"$XLEN"-gnu-toolchain"}
32

3+
XLEN=${XLEN:-"@XLEN@"}
4+
TOOLDIR=${TOOLDIR:-"@TOOLDIR@"}
5+
RISCV_TOOLCHAIN_PATH=${RISCV_TOOLCHAIN_PATH:-"$TOOLDIR/riscv$XLEN-gnu-toolchain"}
46
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5-
RESTORE_PREV_DIR=$(pwd)
7+
TEST_DIR=${TEST_DIR:-"$SCRIPT_DIR/testcases"}
68

79
VECTOR_TESTS_REPOSITORY=https://github.com/MichaelJSr/testcases/raw/main
810
VECTOR_TESTS_BASE_NAME=vector-tests.tar.bz2
911

10-
vector_tests()
12+
download_tests()
1113
{
1214
parts=$(eval echo {a..z})
1315
for x in $parts
@@ -20,14 +22,12 @@ vector_tests()
2022
}
2123

2224
# get selected testcases from command line or run default testcases
23-
if [ "$#" == "0" ];
24-
then
25+
if [ "$#" -eq 0 ]; then
2526
# write out test case name explicitely if there are collisions with other test names
2627
testcases=(vmv vslide vmerge vrgather \
2728
vle8 vle16 vle32 \
2829
vse8 vse16 vse32 \
2930
vlseg vlsseg vluxseg vloxseg \
30-
vsseg vssseg vsuxseg vsoxseg \
3131
vlse8 vlse16 vlse32 \
3232
vsse8 vsse16 vsse32 \
3333
vloxei vluxei vsoxei vsuxei \
@@ -50,70 +50,74 @@ then
5050
vadc vmadc vsbc vmsbc \
5151
vsext vzext \
5252
vid)
53-
if [ $XLEN -eq 32 ]; then
53+
if [ "$XLEN" -eq 32 ]; then
5454
testcases+=()
55-
elif [ $XLEN -eq 64 ]; then
55+
elif [ "$XLEN" -eq 64 ]; then
5656
testcases+=(vle64 vse64 vlse64 vsse64 vfwcvt vfncvt \
57-
vfwadd vfwsub \
5857
vfwmul vfwred vfwmacc vfwnmacc vfwmsac vfwnmsac )
5958
fi
6059
else
6160
testcases="${@}"
6261
fi
6362

64-
cd $SCRIPT_DIR
65-
6663
# Fallback #1: If testcases directory exists, use the existing testcases
67-
if [ ! -d "$SCRIPT_DIR/testcases" ]; then
68-
mkdir testcases
69-
cd testcases
64+
if [ ! -d "$TEST_DIR" ]; then
65+
mkdir $TEST_DIR
66+
pushd $TEST_DIR
7067
# Fallback #2: Generate testcases
7168
if [ -n "$GEN_TESTS" ] && [ $GEN_TESTS -eq 1 ]; then
7269
/bin/bash ../gen-test.sh
70+
testcases+=(vsseg vssseg vsuxseg vsoxseg)
71+
if [ "$XLEN" -eq 64 ]; then
72+
testcases+=(vfwadd vfwsub)
73+
fi
7374
# Fallback #3: Download testcases
7475
else
75-
vector_tests
76+
download_tests
7677
fi
78+
popd
7779
fi
7880

79-
cd $SCRIPT_DIR/testcases/v$VLEN"x"$XLEN
81+
pushd "$TEST_DIR/v${VLEN}x$XLEN"
8082

81-
rm *".ddr4.log"
83+
rm -f "*.ddr4.log" > /dev/null 2>&1
8284
for testcase in ${testcases[@]}; do
83-
rm "$testcase"*.elf "$testcase"*.bin "$testcase"*.dump "$testcase"*.log
85+
rm -f "$testcase*.bin" "$testcase*.dump" "$testcase*.log" > /dev/null 2>&1
8486
done
8587

8688
passed=0
8789
failed=0
88-
selected=0
89-
90-
# count all available testcases, exclude *.elf, *.bin, *.dump, *.log to prevent double counting
91-
all=$(($(ls | wc -l) - $(ls -d *.elf | wc -l) - $(ls -d *.bin | wc -l) - $(ls -d *.dump | wc -l) - $(ls -d *.log | wc -l)))
9290

9391
for testcase in ${testcases[@]}; do
94-
for f in "$testcase"* ; do
95-
ln -s "$f" "$f.elf";
96-
"$RISCV_TOOLCHAIN_PATH"/bin/riscv"$XLEN"-unknown-elf-objdump -D "$f.elf" > "$f.dump";
97-
"$RISCV_TOOLCHAIN_PATH"/bin/riscv"$XLEN"-unknown-elf-objcopy -O binary "$f.elf" "$f.bin";
98-
$SCRIPT_DIR/../../../sim/simx/simx -v -c 1 "$f.bin" &> "$f.log";
99-
if [ $? -eq 1 ]; then
92+
echo "Testcase: $testcase"
93+
find . -type f -name "${testcase}*" 2>/dev/null | while read -r f; do
94+
"$RISCV_TOOLCHAIN_PATH/bin/riscv$XLEN-unknown-elf-objdump" -D "$f" > "$f.dump"
95+
"$RISCV_TOOLCHAIN_PATH/bin/riscv$XLEN-unknown-elf-objcopy" -O binary "$f" "$f.bin"
96+
echo "running $SCRIPT_DIR/../../../sim/simx/simx -v $f.bin"
97+
"$SCRIPT_DIR/../../../sim/simx/simx" -v "$f.bin" > "$f.log"
98+
if [ $? -eq 0 ]; then
10099
echo "$f PASSED"
101-
let "passed++"
100+
((passed++))
102101
else
103102
echo "$f FAILED"
104-
let "failed++"
103+
((failed++))
105104
fi
106105
# REG_TESTS=1 informs the script to delete the previous binary after each vector test to save disk space
107106
# Otherwise, the vector regression tests would run out of disk space eventually
108107
if [ -n "$REG_TESTS" ] && [ $REG_TESTS -eq 1 ]; then
109-
cat $f.log
110-
rm $f.*
111-
rm $f
108+
cat "$f.log"
109+
rm -f "$f..bin" "$f.dump" "$f.log" > /dev/null 2>&1
112110
fi
113-
let "selected++"
114111
done
115112
done
116-
cd $RESTORE_PREV_DIR
117-
echo "Passed $passed out of $selected selected vector tests."
118-
echo "Total available vector tests: $all"
113+
114+
popd
115+
116+
if [ $failed -eq 0 ]; then
117+
echo "All $total vector tests passed."
118+
else
119+
total=$((passed + failed))
120+
echo "$failed out of $total vector tests failed."
121+
fi
122+
119123
exit $failed

0 commit comments

Comments
 (0)