diff options
author | Yann Herklotz <git@yannherklotz.com> | 2021-09-18 14:40:45 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2021-09-18 14:40:45 +0100 |
commit | b666f88219893c82361606f8652297ecc7fb7a9f (patch) | |
tree | 946c2ddb5ce21b7af24ce6945fe5f83cbb274061 /benchmarks/polybench-syn-div/linear-algebra/solvers/trisolv.c | |
parent | c4d44af5f3135aba4d4878f8f41c80d1f0b9e9a2 (diff) | |
parent | c4436c02648502c4cb327d2018229e62a2c0d1c0 (diff) | |
download | vericert-b666f88219893c82361606f8652297ecc7fb7a9f.tar.gz vericert-b666f88219893c82361606f8652297ecc7fb7a9f.zip |
Merge branch 'master' into develop
Diffstat (limited to 'benchmarks/polybench-syn-div/linear-algebra/solvers/trisolv.c')
-rw-r--r-- | benchmarks/polybench-syn-div/linear-algebra/solvers/trisolv.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn-div/linear-algebra/solvers/trisolv.c b/benchmarks/polybench-syn-div/linear-algebra/solvers/trisolv.c new file mode 100644 index 0000000..f426853 --- /dev/null +++ b/benchmarks/polybench-syn-div/linear-algebra/solvers/trisolv.c @@ -0,0 +1,97 @@ +/** + * 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 + */ +/* trisolv.c: this file is part of PolyBench/C */ + +#ifndef SYNTHESIS +#include <stdio.h> +#endif + +#define plus(i) i = i + ONE +static +void init_array(int n, + int L[ 40 ][40 ], + int x[ 40 ], + int b[ 40 ]) +{ + int i, j; + int ONE = 1; + + for (i = 0; i < n; plus(i)) + { + x[i] = -999; + b[i] = i ; + for (j = 0; j <= i; plus(j)) + L[i][j] = (int) (((i+n-j+ONE)*(ONE+ONE)) / n); + } +} + + + + +static +int check_array(int n, + int x[ 40]) + +{ + int i; + int res = 0; + int ONE = 1; + for (i = 0; i < n; plus(i)) { + res ^= x[i]; + } + +#ifndef SYNTHESIS + printf("finished: %u\n", res); +#endif + return res; +} + + + + +static +void kernel_trisolv(int n, + int L[ 40 + 0][40 + 0], + int x[ 40 + 0], + int b[ 40 + 0]) +{ + int i, j; + int ONE = 1; + + for (i = 0; i < n; plus(i)) + { + x[i] = b[i]; + for (j = 0; j <i; plus(j)) + x[i] -= L[i][j] * x[j]; + + x[i] = (x[i] / L[i][i]); + + } + +} + + +int main() +{ + + int n = 40; + + + int L[40 + 0][40 + 0]; + int x[40 + 0]; + int b[40 + 0]; + + init_array (n, L, x, b); + kernel_trisolv (n, L, x, b); + + return check_array(n, x); + + return 0; +} |