diff options
author | Yann Herklotz <git@yannherklotz.com> | 2021-07-11 01:19:52 +0200 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2021-07-11 01:19:52 +0200 |
commit | aa986aacbb80e9f92f77d65de74ba5051054eac7 (patch) | |
tree | 0a1a6c9f209e818f7a1ec675ae8983abc5b9de2c /benchmarks/polybench-syn-div/linear-algebra/solvers/durbin.c | |
parent | f46b0cd924705dcb4817129bb0504767c2225c20 (diff) | |
download | vericert-aa986aacbb80e9f92f77d65de74ba5051054eac7.tar.gz vericert-aa986aacbb80e9f92f77d65de74ba5051054eac7.zip |
Add divider benchmarks
Diffstat (limited to 'benchmarks/polybench-syn-div/linear-algebra/solvers/durbin.c')
-rw-r--r-- | benchmarks/polybench-syn-div/linear-algebra/solvers/durbin.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn-div/linear-algebra/solvers/durbin.c b/benchmarks/polybench-syn-div/linear-algebra/solvers/durbin.c new file mode 100644 index 0000000..5646e6e --- /dev/null +++ b/benchmarks/polybench-syn-div/linear-algebra/solvers/durbin.c @@ -0,0 +1,98 @@ +/** + * 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 + */ +/* durbin.c: this file is part of PolyBench/C */ + +#ifndef SYNTHESIS +#include <stdio.h> +#endif + +#define plus(i) i = i + ONE +/* Include polybench common header. */ +static +void init_array (int n, + int r[ 40 + 0]) +{ + int ONE = 1; + int i; + + for (i = 0; i < n; plus(i)) + { + r[i] = (n+ONE-i); + } +} + + + +static +int print_array(int n, + int y[ 40 + 0]) + +{ + int ONE = 1; + int i; + int res = 0; + + for (i = 0; i < n; plus(i)) { + res ^= y[i]; + } + +#ifndef SYNTHESIS + printf("finished: %u\n", res); +#endif + + return res; +} + +static +void kernel_durbin(int n, + int r[ 40 + 0], + int y[ 40 + 0]) +{ + int z[40]; + int alpha; + int beta; + int sum; + + int ONE = 1; + int i,k; + y[0] = -r[0]; + beta = 1; + alpha = -r[0]; + + for (k = 1; k < n; plus(k)) { + beta = (ONE-alpha*alpha)*beta; + sum = 0; + for (i=0; i<k; plus(i)) { + sum += r[k-i-ONE]*y[i]; + } + alpha = - (r[k] + sum / beta); + + for (i=0; i<k; plus(i)) { + z[i] = y[i] + alpha*y[k-i-ONE]; + } + for (i=0; i<k; plus(i)) { + y[i] = z[i]; + } + y[k] = alpha; + } +} + + +int main() +{ + int n = 40; + int r[40 + 0]; + int y[40 + 0]; + + init_array (n, r); + kernel_durbin (n, r, y); + + return print_array(n, y); +} |