From 95861dbef966e2cb612b303615681fc29c3acd3d Mon Sep 17 00:00:00 2001 From: Nadesh Ramanathan Date: Wed, 11 Nov 2020 19:47:42 +0000 Subject: polybench edits --- .../linear-algebra/solvers/cholesky.c | 2 +- .../polybench-syn/linear-algebra/solvers/durbin.c | 2 +- .../polybench-syn/linear-algebra/solvers/lu.c | 2 +- .../polybench-syn/linear-algebra/solvers/ludcmp.c | 126 ++++++++++----------- .../polybench-syn/linear-algebra/solvers/trisolv.c | 22 ++-- 5 files changed, 75 insertions(+), 79 deletions(-) (limited to 'benchmarks/polybench-syn/linear-algebra/solvers') diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c b/benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c index a0d63a0..05e85ea 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c @@ -24,7 +24,7 @@ void init_array(int n, for (i = 0; i < n; plus(i)) { for (j = 0; j <= i; plus(j)) - A[i][j] = (int)(-j % n) / n + ONE; + A[i][j] = (int)sdivider(smodulo(-j, n), n) + ONE; for (j = i + ONE; j < n; plus(j)) { A[i][j] = 0; } diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c index 6a2fd41..dd6d05e 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c @@ -56,7 +56,7 @@ void init_array (int n, int r[ 40 + 0]) { int ONE = 1; - int i, j; + int i; for (i = 0; i < n; plus(i)) { diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/lu.c b/benchmarks/polybench-syn/linear-algebra/solvers/lu.c index 7c8989f..56dadd7 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/lu.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/lu.c @@ -28,7 +28,7 @@ void init_array (int n, for (i = 0; i < n; plus(i)) { for (j = 0; j <= i; plus(j)) - A[i][j] = (-j % n )/ n + ONE; + A[i][j] = sdivider(smodulo(-j, n), n) + ONE; for (j = plus(i); j < n; plus(j)) { A[i][j] = 0; } diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c b/benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c index e85316a..f37d983 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c @@ -9,37 +9,37 @@ */ /* ludcmp.c: this file is part of PolyBench/C */ +#include "../../include/misc.h" + #define plus(i) i = i + ONE -static + static void init_array (int n, - int A[ 40 + 0][40 + 0], - int b[ 40 + 0], - int x[ 40 + 0], - int y[ 40 + 0]) + int A[ 40 + 0][40 + 0], + int b[ 40 + 0], + int x[ 40 + 0], + int y[ 40 + 0]) { int i, j; int ONE = 1; - int TWO = 2; - int FOUR = 4; int fn = (int)n; for (i = 0; i < n; plus(i)) - { - x[i] = 0; - y[i] = 0; - b[i] = (i+ONE)/fn/(TWO) + (FOUR); - } + { + x[i] = 0; + y[i] = 0; + b[i] = divider(i+1, fn*2) + 4; + } for (i = 0; i < n; plus(i)) - { - for (j = 0; j <= i; plus(j)) - A[i][j] = (int)(-j % n) / n + ONE; - for (j = i+ONE; j < n; plus(j)) { - A[i][j] = 0; - } - A[i][i] = 1; + { + for (j = 0; j <= i; plus(j)) + A[i][j] = (int)sdivider(smodulo(-j, n), n) + 1; + for (j = i+ONE; j < n; plus(j)) { + A[i][j] = 0; } + A[i][i] = 1; + } @@ -51,19 +51,19 @@ void init_array (int n, for (t = 0; t < n; plus(t)) for (r = 0; r < n; plus(r)) for (s = 0; s < n; plus(s)) - B[r][s] += A[r][t] * A[s][t]; - for (r = 0; r < n; plus(r)) - for (s = 0; s < n; plus(s)) - A[r][s] = B[r][s]; + B[r][s] += A[r][t] * A[s][t]; + for (r = 0; r < n; plus(r)) + for (s = 0; s < n; plus(s)) + A[r][s] = B[r][s]; } -static + static int check_array(int n, - int x[ 40 + 0]) + int x[ 40 + 0]) { int i; @@ -71,7 +71,7 @@ int check_array(int n, int res = 0; for (i = 0; i < n; plus(i)) { - res += x[i]; + res += x[i]; } return res; } @@ -79,50 +79,48 @@ int check_array(int n, -static + static void kernel_ludcmp(int n, - int A[ 40 + 0][40 + 0], - int b[ 40 + 0], - int x[ 40 + 0], - int y[ 40 + 0]) + int A[ 40 + 0][40 + 0], + int b[ 40 + 0], + int x[ 40 + 0], + int y[ 40 + 0]) { int i, j, k; int ONE = 1; int w; -#pragma scop - for (i = 0; i < n; plus(i)) { + for (i = 0; i < n; plus(i)) { for (j = 0; j =0; i=i-ONE) { - w = y[i]; - for (j = i+ONE; j < n; plus(j)) - w -= A[i][j] * x[j]; - x[i] = w / A[i][i]; + for (i = n-ONE; i >=0; i=i-ONE) { + w = y[i]; + for (j = i+ONE; j < n; plus(j)) + w -= A[i][j] * x[j]; + x[i] = sdivider(w, A[i][i]); } -#pragma endscop } @@ -131,7 +129,6 @@ int main() { int n = 40; - int ONE = 1; int A[40 + 0][40 + 0]; @@ -142,20 +139,17 @@ int main() init_array (n, - A, - b, - x, - y); - - - ; + A, + b, + x, + y); kernel_ludcmp (n, - A, - b, - x, - y); + A, + b, + x, + y); return check_array(n, x); diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c b/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c index 5e760e6..8e76231 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c @@ -9,6 +9,8 @@ */ /* trisolv.c: this file is part of PolyBench/C */ +#include "../../include/misc.h" + #define plus(i) i = i + ONE static void init_array(int n, @@ -24,7 +26,7 @@ void init_array(int n, x[i] = - 999; b[i] = i ; for (j = 0; j <= i; plus(j)) - L[i][j] = (int) (i+n-j+ONE)*(ONE+ONE)/n; + L[i][j] = (int) divider((i+n-j+ONE)*(ONE+ONE), n); } } @@ -57,15 +59,15 @@ void kernel_trisolv(int n, int i, j; int ONE = 1; -#pragma scop - for (i = 0; i < n; plus(i)) - { - x[i] = b[i]; - for (j = 0; j