Skip to content

Commit 91429e6

Browse files
committed
Added an option for generating riscv vector tests during regression testing
1 parent 3ce16c5 commit 91429e6

File tree

4 files changed

+95
-7
lines changed

4 files changed

+95
-7
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,62 @@ jobs:
117117
strategy:
118118
fail-fast: false
119119
matrix:
120-
name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm, vector]
120+
name: [regression, opencl, cache, config1, config2, debug, scope, stress, synthesis, vm]
121+
xlen: [32, 64]
122+
123+
steps:
124+
- 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]
121176
xlen: [32, 64]
122177

123178
steps:

ci/regression.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ vector()
395395
echo "begin vector tests..."
396396

397397
make -C sim/simx clean && CONFIGS="-DEXT_V_ENABLE" make -C sim/simx
398-
TOOLDIR=@TOOLDIR@ XLEN=@XLEN@ VLEN=256 REG_TESTS=1 ./tests/riscv/riscv-vector-tests/run-test.sh
398+
TOOLDIR=@TOOLDIR@ XLEN=@XLEN@ VLEN=256 REG_TESTS=1 GEN_TESTS=0 ./tests/riscv/riscv-vector-tests/run-test.sh
399399

400400
echo "vector tests done!"
401401
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
PREV_DIR=$(pwd)
4+
5+
sudo apt-get install device-tree-compiler
6+
wget -O- -q https://go.dev/dl/go1.24.0.linux-amd64.tar.gz | tar -xzf -
7+
8+
git clone https://github.com/chipsalliance/riscv-vector-tests.git
9+
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
13+
14+
git clone https://github.com/riscv-software-src/riscv-isa-sim.git
15+
cd riscv-isa-sim
16+
git reset --hard 91793ed7d964aa0031c5a9a31fa05ec3d11b3b0f
17+
mkdir build && cd build
18+
../configure --prefix=$RISCV
19+
make -j$(nproc) && sudo make install
20+
cd ../..
21+
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 MODE=machine && make all -j$(nproc) --environment-overrides VLEN=$VLEN XLEN=$XLEN MODE=machine
27+
mv out/v"$VLEN"x"$XLEN"machine/bin/stage2 $PREV_DIR/v"$VLEN"x"$XLEN"
28+
29+
cd $PREV_DIR
30+
sudo rm -rf riscv-vector-tests

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,24 @@ fi
6464

6565
cd $SCRIPT_DIR
6666

67-
# Fallback #2: If testcases directory exists, we will use existing testcases
67+
# Fallback #1: If testcases directory exists, use the existing testcases
6868
if [ ! -d "$SCRIPT_DIR/testcases" ]; then
6969
mkdir testcases
7070
cd testcases
71-
# Fallback #3: Otherwise, download testcases
72-
vector_tests
71+
# Fallback #2: Generate testcases
72+
if [ -n "$GEN_TESTS" ] && [ $GEN_TESTS -eq 1 ]; then
73+
/bin/bash ../gen-test.sh
74+
# Fallback #3: Download testcases
75+
else
76+
vector_tests
77+
fi
7378
fi
7479

7580
cd $SCRIPT_DIR/testcases/v$VLEN"x"$XLEN
7681

77-
# Fallback #1: Copy locally generated testcases (assuming they exist)
7882
rm *".ddr4.log"
7983
for testcase in ${testcases[@]}; do
8084
rm "$testcase"*.elf "$testcase"*.bin "$testcase"*.dump "$testcase"*.log
81-
cp -f $SCRIPT_DIR/../../../third_party/riscv-vector-tests/out/v"$VLEN"x"$XLEN"machine/bin/stage2/"$testcase"* .
8285
done
8386

8487
passed=0

0 commit comments

Comments
 (0)