aboutsummaryrefslogtreecommitdiff
path: root/rcc-legacy/tests/performance/04_spmv1.sy
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:10:31 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:10:31 +0800
commit72af0dedf9e18911da65b9a5c4906689e868d9fc (patch)
tree2ecbad93f96ab8ad7e26dc02cd02d802f853ab97 /rcc-legacy/tests/performance/04_spmv1.sy
parent8faf6d290d6703b1775e0ad7a8928a4ebea4b11b (diff)
downloadrcc-project-72af0dedf9e18911da65b9a5c4906689e868d9fc.tar.gz
rcc-project-72af0dedf9e18911da65b9a5c4906689e868d9fc.tar.xz
[legacy] Add functional and performance test suites
Diffstat (limited to 'rcc-legacy/tests/performance/04_spmv1.sy')
-rw-r--r--rcc-legacy/tests/performance/04_spmv1.sy50
1 files changed, 50 insertions, 0 deletions
diff --git a/rcc-legacy/tests/performance/04_spmv1.sy b/rcc-legacy/tests/performance/04_spmv1.sy
new file mode 100644
index 0000000..b9ad122
--- /dev/null
+++ b/rcc-legacy/tests/performance/04_spmv1.sy
@@ -0,0 +1,50 @@
+void spmv(int n,int xptr[], int yidx[], int vals[], int b[], int x[]){
+ int i, j, k;
+ i = 0;
+ while (i < n){
+ x[i] = 0;
+ i = i + 1;
+ }
+
+ i = 0;
+ while (i < n){
+ j = xptr[i];
+ while (j < xptr[i + 1]){
+ x[yidx[j]] = x[yidx[j]] + vals[j];
+ j = j + 1;
+ }
+
+ j = xptr[i];
+ while (j < xptr[i + 1]){
+ x[yidx[j]] = x[yidx[j]] + vals[j] * (b[i] - 1);
+ j = j + 1;
+ }
+ i = i + 1;
+ }
+}
+
+const int N = 100010;
+const int M = 3000000;
+
+int x[N], y[M], v[M];
+int a[N], b[N], c[N];
+
+int main(){
+ int n = getarray(x) - 1;
+ int m = getarray(y);
+ getarray(v);
+
+ getarray(a);
+
+ starttime();
+
+ int i = 0;
+ while (i < 5){
+ spmv(n, x, y, v, a, b);
+ spmv(n, x, y, v, b, a);
+ i=i+1;
+ }
+ stoptime();
+ putarray(n, b);
+ return 0;
+}