From 79d8a87d68eadd33bfc1e5d25d4eb827000a232b Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Wed, 4 Nov 2020 11:31:55 +0000 Subject: Add small changes to durbin and adpcm --- benchmarks/CHStone/adpcm/adpcm.c | 6 +- .../polybench-syn/linear-algebra/solvers/durbin.c | 157 +++++++++++++-------- 2 files changed, 99 insertions(+), 64 deletions(-) (limited to 'benchmarks') diff --git a/benchmarks/CHStone/adpcm/adpcm.c b/benchmarks/CHStone/adpcm/adpcm.c index bcdc6dd..a7c47d5 100755 --- a/benchmarks/CHStone/adpcm/adpcm.c +++ b/benchmarks/CHStone/adpcm/adpcm.c @@ -461,7 +461,7 @@ adpcm_main (const int test_data[SIZE], int compressed[SIZE], int result[SIZE]) int dec_sh; int dec_ph1, dec_ph2; - int i, j; + unsigned int i, j; /* reset, initialize required memory */ @@ -770,13 +770,13 @@ adpcm_main (const int test_data[SIZE], int compressed[SIZE], int result[SIZE]) { int opA1, opB1; int opA2, opB2; - if(i==0){ + if((int)i==0){ opA1 = xd; opB1 = (*h_ptr++); opA2 = xs; opB2 = (*h_ptr++); } - else if(i==11){ + else if((int)i==11){ opA1 = (*ac_ptr++); opB1 = (*h_ptr++); opA2 = (*ad_ptr++); diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c index 677c23c..92afb09 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c @@ -9,19 +9,61 @@ */ /* durbin.c: this file is part of PolyBench/C */ +#ifndef SYNTHESIS +#include +#endif + +unsigned int divider(unsigned int x, unsigned int y) +{ + unsigned int r0, q0, y0, y1; + + r0 = x; + q0 = 0; + y0 = y; + y1 = y; + do + { + y1 = 2 * y1; + } while (y1 <= x); + do + { + y1 = y1 / 2; + q0 = 2 * q0; + if (r0 >= y1) + { + r0 = r0 - y1; + q0 = q0 + 1; + } + } while ((int)y1 != (int)y0); + return q0; +} + +int sdivider(int N, int D) { + if (D < 0) { + if (N < 0) + return divider(-N, -D); + else + return -divider(N, -D); + } else { + if (N < 0) + return -divider(-N, D); + else + return divider(N, D); + } +} #define plus(i) i = i + ONE /* Include polybench common header. */ static void init_array (int n, - int r[ 40 + 0]) + int r[ 40 + 0]) { - int ONE = 1; - int i, j; + int ONE = 1; + int i, j; - for (i = 0; i < n; plus(i)) + for (i = 0; i < n; plus(i)) { - r[i] = (n+ONE-i); + r[i] = (n+ONE-i); } } @@ -29,74 +71,67 @@ void init_array (int n, static int print_array(int n, - int y[ 40 + 0]) + int y[ 40 + 0]) { - int ONE = 1; - int i; - int res = 0; - - for (i = 0; i < n; plus(i)) { - res += y[i]; - } - return res; + 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 r[ 40 + 0], + int y[ 40 + 0]) { - int z[40]; - int alpha; - int beta; - int sum; - - int ONE = 1; - int i,k; - -#pragma scop - 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