File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22set -e
3+ set -x
34
45ROOT=` git rev-parse --show-toplevel`
56NPROCS=" $( nproc 2> /dev/null || sysctl -n hw.ncpu) "
@@ -26,6 +27,7 @@ riscv64-linux-gnu-gcc -static -O2 -o hello $CI/hello.c
2627riscv64-linux-gnu-gcc -static -O2 -o dummy-slliuw $CI /dummy-slliuw.c
2728riscv64-linux-gnu-gcc -static -O2 -o customcsr $CI /customcsr.c
2829riscv64-linux-gnu-gcc -static -O2 -o atomics $CI /atomics.c
30+ riscv64-linux-gnu-gcc -static -O2 -march=rv64gcv -o vector-sum $CI /vector-sum.c
2931
3032# run snippy-based tests
3133wget https://github.com/syntacore/snippy/releases/download/snippy-2.1/snippy-x86_64-linux.tar.xz
@@ -45,6 +47,7 @@ g++ -std=c++2a -I$INSTALL/include -L$INSTALL/lib $CI/testlib.cc -lriscv -o /dev/
4547
4648# run tests
4749time $INSTALL /bin/spike --isa=rv64gc $BUILD /pk/pk hello | grep " Hello, world! Pi is approximately 3.141588."
50+ time $INSTALL /bin/spike --isa=rv64gcv $BUILD /pk/pk vector-sum | grep " The sum of the first 1000 positive integers is 500500."
4851$INSTALL /bin/spike --log-commits --isa=rv64gc $BUILD /pk/pk atomics 2> /dev/null | grep " First atomic counter is 1000, second is 100"
4952LD_LIBRARY_PATH=$INSTALL /lib ./test-libriscv $BUILD /pk/pk hello | grep " Hello, world! Pi is approximately 3.141588."
5053LD_LIBRARY_PATH=$INSTALL /lib ./test-customext $BUILD /pk/pk dummy-slliuw | grep " Executed successfully"
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <string.h>
3+ #include <riscv_vector.h>
4+
5+ int main ()
6+ {
7+ const size_t N = 1001 ;
8+ volatile int a [N ];
9+ int * b = (int * )a ;
10+
11+ for (size_t i = 0 ; i < N ; i ++ )
12+ a [i ] = i ;
13+
14+ vint32m8_t vsum = __riscv_vmv_v_x_i32m8 (0 , -1 );
15+ for (size_t i = 0 ; i < N ; ) {
16+ size_t vl = __riscv_vsetvl_e32m8 (N - i );
17+ vint32m8_t v = __riscv_vle32_v_i32m8 (b + i , vl );
18+ vsum = __riscv_vadd_vv_i32m8 (vsum , v , vl );
19+ i += vl ;
20+ }
21+ vint32m1_t vzero = __riscv_vmv_v_x_i32m1 (0 , 1 );
22+ int sum = __riscv_vmv_x_s_i32m1_i32 (__riscv_vredsum_vs_i32m8_i32m1 (vsum , vzero , -1 ));
23+
24+ printf ("The sum of the first %zu positive integers is %d.\n" , N - 1 , sum );
25+
26+ return 0 ;
27+ }
You can’t perform that action at this time.
0 commit comments