Skip to content

Commit 44d2ca5

Browse files
committed
Add simple vector extension test to CI
1 parent 6dda489 commit 44d2ca5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ci-tests/test-spike

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ riscv64-linux-gnu-gcc -static -O2 -o hello $CI/hello.c
2626
riscv64-linux-gnu-gcc -static -O2 -o dummy-slliuw $CI/dummy-slliuw.c
2727
riscv64-linux-gnu-gcc -static -O2 -o customcsr $CI/customcsr.c
2828
riscv64-linux-gnu-gcc -static -O2 -o atomics $CI/atomics.c
29+
riscv64-linux-gnu-gcc -static -O2 -march=rv64gcbv -ftree-vectorize -o vector-sum $CI/vector-sum.c
30+
# make sure the vector test actually vectorized
31+
riscv64-linux-gnu-objdump -d vector-sum | grep vredsum.vs
2932

3033
# run snippy-based tests
3134
wget https://github.com/syntacore/snippy/releases/download/snippy-2.1/snippy-x86_64-linux.tar.xz
@@ -45,6 +48,7 @@ g++ -std=c++2a -I$INSTALL/include -L$INSTALL/lib $CI/testlib.cc -lriscv -o /dev/
4548

4649
# run tests
4750
time $INSTALL/bin/spike --isa=rv64gc $BUILD/pk/pk hello | grep "Hello, world! Pi is approximately 3.141588."
51+
time $INSTALL/bin/spike --isa=rv64gcbv $BUILD/pk/pk vector-sum | grep "The sum of the first 1000 positive integers is 500500."
4852
$INSTALL/bin/spike --log-commits --isa=rv64gc $BUILD/pk/pk atomics 2> /dev/null | grep "First atomic counter is 1000, second is 100"
4953
LD_LIBRARY_PATH=$INSTALL/lib ./test-libriscv $BUILD/pk/pk hello | grep "Hello, world! Pi is approximately 3.141588."
5054
LD_LIBRARY_PATH=$INSTALL/lib ./test-customext $BUILD/pk/pk dummy-slliuw | grep "Executed successfully"

ci-tests/vector-sum.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
4+
int main()
5+
{
6+
const size_t N = 1001;
7+
volatile size_t a[N];
8+
size_t* b = (size_t*)a;
9+
10+
for (size_t i = 0; i < N; i++)
11+
a[i] = i;
12+
13+
size_t sum = 0;
14+
for (size_t i = 0; i < N; i++)
15+
sum += b[i];
16+
17+
printf("The sum of the first %zu positive integers is %zu.\n", N - 1, sum);
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)