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/stencils/jacobi-2d.c | |
parent | 3971466fbdd9aa1883a4468de3d67fdf90fee02d (diff) | |
download | vericert-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.tar.gz vericert-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.zip |
Add modified polybench benchmarks
Diffstat (limited to 'benchmarks/polybench-syn/stencils/jacobi-2d.c')
-rw-r--r-- | benchmarks/polybench-syn/stencils/jacobi-2d.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn/stencils/jacobi-2d.c b/benchmarks/polybench-syn/stencils/jacobi-2d.c new file mode 100644 index 0000000..3a5b43c --- /dev/null +++ b/benchmarks/polybench-syn/stencils/jacobi-2d.c @@ -0,0 +1,101 @@ +/** + * 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 + */ +/* jacobi-2d.c: this file is part of PolyBench/C */ + + +#define plus(i) i = i + ONE +static +void init_array (int n, + int A[ 30 + 0][30 + 0], + int B[ 30 + 0][30 + 0]) +{ + int i, j; + int ONE = 1; + int TWO = 2; + int THREE = 3; + + for (i = 0; i < n; plus(i)) + for (j = 0; j < n; plus(j)) + { + A[i][j] = ((int) i*(j+TWO) + TWO) / n; + B[i][j] = ((int) i*(j+THREE) + THREE) / n; + } +} + + + + +static +int print_array(int n, + int A[ 30 + 0][30 + 0]) + +{ + int i, j; + int ONE = 1; + int res = 0; + + for (i = 0; i < n; plus(i)) + for (j = 0; j < n; plus(j)) { + res ^= A[i][j]; + } + return res; +} + + + + +static +void kernel_jacobi_2d(int tsteps, + int n, + int A[ 30 + 0][30 + 0], + int B[ 30 + 0][30 + 0]) +{ + int t, i, j; + int ONE = 1; + int TWO = 2; + +#pragma scop + for (t = 0; t < tsteps; plus(t)) + { + for (i = 1; i < n - ONE; plus(i)) + for (j = 1; j < n - ONE; plus(j)){ + B[i][j] = (A[i][j] + A[i][j-ONE] + A[i][ONE+j] + A[ONE+i][j] + A[i-ONE][j]); + B[i][j] = B[i][j] >> TWO; + } + for (i = 1; i < n - ONE; plus(i)) + for (j = 1; j < n - ONE; plus(j)){ + A[i][j] = (B[i][j] + B[i][j-ONE] + B[i][ONE+j] + B[ONE+i][j] + B[i-ONE][j]); + A[i][j] = A[i][j] >> TWO; + } + } +#pragma endscop + +} + + +int main() +{ + + int n = 30; + int tsteps = 5; + + + int A[30 + 0][30 + 0]; + int B[30 + 0][30 + 0]; + + + + init_array (n, A, B); + + kernel_jacobi_2d(tsteps, n, A, B); + + return print_array(n, A); + +} |