diff options
author | Yann Herklotz <git@yannherklotz.com> | 2020-08-13 23:24:40 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2020-08-13 23:24:40 +0100 |
commit | 045c0dc29fc31a8d3f15da8b3130dbc4706ea581 (patch) | |
tree | 56e9eb2ec6c318648e47c43d6b8abb2458ae236e /benchmarks/polybench-syn/linear-algebra/blas/gesummv.c | |
parent | 3971466fbdd9aa1883a4468de3d67fdf90fee02d (diff) | |
download | vericert-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.tar.gz vericert-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.zip |
Add modified polybench benchmarks
Diffstat (limited to 'benchmarks/polybench-syn/linear-algebra/blas/gesummv.c')
-rw-r--r-- | benchmarks/polybench-syn/linear-algebra/blas/gesummv.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/gesummv.c b/benchmarks/polybench-syn/linear-algebra/blas/gesummv.c new file mode 100644 index 0000000..606a581 --- /dev/null +++ b/benchmarks/polybench-syn/linear-algebra/blas/gesummv.c @@ -0,0 +1,115 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet <pouchet.ohio-state.edu> + * Tomofumi Yuki <tomofumi.yuki.fr> + * + * Web address: http://polybench.sourceforge.net + */ +/* gesummv.c: this file is part of PolyBench/C */ + + +#define plus(i) i = i + ONE + +static +void init_array(int n, + int *alpha, + int *beta, + int A[ 30 + 0][30 + 0], + int B[ 30 + 0][30 + 0], + int x[ 30 + 0]) +{ + int i, j; + int ONE = 1; + + *alpha = 3; + *beta = 2; + for (i = 0; i < n; plus(i)) + { + x[i] = (int)( i % n) / n; + for (j = 0; j < n; plus(j)) { + A[i][j] = (int) ((i*j+ONE) % n) / n; + B[i][j] = (int) ((i*j+ONE+ONE) % n) / n; + } + } +} + + + + +static +int print_array(int n, + int y[ 30 + 0]) + +{ + int i; + int ONE = 1; + int res = 0; + + for (i = 0; i < n; plus(i)) { + res ^= y[i]; + } + return res; +} + +static +void kernel_gesummv(int n, + int alpha, + int beta, + int A[ 30 + 0][30 + 0], + int B[ 30 + 0][30 + 0], + int tmp[ 30 + 0], + int x[ 30 + 0], + int y[ 30 + 0]) +{ + int i, j; + int ONE = 1; + +#pragma scop + for (i = 0; i < n; plus(i)) + { + tmp[i] = 0; + y[i] = 0; + for (j = 0; j < n; plus(j)) + { + tmp[i] = A[i][j] * x[j] + tmp[i]; + y[i] = B[i][j] * x[j] + y[i]; + } + y[i] = alpha * tmp[i] + beta * y[i]; + } +#pragma endscop + +} + + +int main() +{ + + int n = 30; + + + int alpha; + int beta; + int A[30 + 0][30 + 0]; + int B[30 + 0][30 + 0]; + int tmp[30 + 0]; + int x[30 + 0]; + int y[30 + 0]; + + init_array (n, &alpha, &beta, + A, + B, + x); + + kernel_gesummv (n, alpha, beta, + A, + B, + tmp, + x, + y); + + + return print_array(n, y); + +} |