From aba1066919919bf068b723fca3741be6f3a1de97 Mon Sep 17 00:00:00 2001 From: Nadesh Ramanathan Date: Sun, 15 Nov 2020 11:44:21 +0000 Subject: some fixes --- .../polybench-syn/linear-algebra/solvers/durbin.c | 9 ++++++++- .../polybench-syn/linear-algebra/solvers/trisolv.c | 13 +++++++++++-- benchmarks/polybench-syn/run-vericert.sh | 2 +- benchmarks/polybench-syn/stencils/fdtd-2d.c | 14 +++++++------- benchmarks/polybench-syn/stencils/heat-3d.c | 20 +++++++++----------- 5 files changed, 36 insertions(+), 22 deletions(-) (limited to 'benchmarks') diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c index dd6d05e..4b1a87f 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c @@ -9,6 +9,9 @@ */ /* durbin.c: this file is part of PolyBench/C */ +#ifndef SYNTHESIS +#include +#endif unsigned int divider(unsigned int x, unsigned int y) { @@ -76,9 +79,13 @@ int print_array(int n, int res = 0; for (i = 0; i < n; plus(i)) { - res += y[i]; + res ^= y[i]; } +#ifndef SYNTHESIS + printf("finished: %u\n", res); +#endif + return res; } diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c b/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c index 8e76231..2f636df 100644 --- a/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c +++ b/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c @@ -11,6 +11,11 @@ #include "../../include/misc.h" + +#ifndef SYNTHESIS +#include +#endif + #define plus(i) i = i + ONE static void init_array(int n, @@ -23,7 +28,7 @@ void init_array(int n, for (i = 0; i < n; plus(i)) { - x[i] = - 999; + x[i] = -999; b[i] = i ; for (j = 0; j <= i; plus(j)) L[i][j] = (int) divider((i+n-j+ONE)*(ONE+ONE), n); @@ -42,8 +47,12 @@ int check_array(int n, int res = 0; int ONE = 1; for (i = 0; i < n; plus(i)) { - res += x[i]; + res ^= x[i]; } + +#ifndef SYNTHESIS + printf("finished: %u\n", res); +#endif return res; } diff --git a/benchmarks/polybench-syn/run-vericert.sh b/benchmarks/polybench-syn/run-vericert.sh index 3be6098..7256235 100755 --- a/benchmarks/polybench-syn/run-vericert.sh +++ b/benchmarks/polybench-syn/run-vericert.sh @@ -8,7 +8,7 @@ while read benchmark ; do ./$benchmark.o cresult=$(echo $?) echo "C output: "$cresult - ../../bin/vericert -O0 -finline --debug-hls $benchmark.c -o $benchmark.v + ../../bin/vericert -DSYNTHESIS -O0 -finline --debug-hls $benchmark.c -o $benchmark.v iverilog -o $benchmark.iver -- $benchmark.v ./$benchmark.iver > $benchmark.tmp veriresult=$(tail -1 $benchmark.tmp | cut -d' ' -f2) diff --git a/benchmarks/polybench-syn/stencils/fdtd-2d.c b/benchmarks/polybench-syn/stencils/fdtd-2d.c index 17acd34..853d362 100644 --- a/benchmarks/polybench-syn/stencils/fdtd-2d.c +++ b/benchmarks/polybench-syn/stencils/fdtd-2d.c @@ -10,6 +10,8 @@ /* fdtd-2d.c: this file is part of PolyBench/C */ +#include "../include/misc.h" + #define plus(i) i = i + ONE static void init_array (int tmax, @@ -22,18 +24,16 @@ void init_array (int tmax, { int i, j; int ONE = 1; - int TWO = 1; - int THREE = 1; for (i = 0; i < tmax; plus(i)) _fict_[i] = (int) i; for (i = 0; i < nx; plus(i)) for (j = 0; j < ny; plus(j)) - { - ex[i][j] = ((int) i*(j+ONE)) / nx; - ey[i][j] = ((int) i*(j+TWO)) / ny; - hz[i][j] = ((int) i*(j+THREE)) / nx; - } + { + ex[i][j] = sdivider(i*(j+1) , nx); + ey[i][j] = sdivider(i*(j+2) , ny); + hz[i][j] = sdivider(i*(j+3) , nx); + } } diff --git a/benchmarks/polybench-syn/stencils/heat-3d.c b/benchmarks/polybench-syn/stencils/heat-3d.c index 6529e8b..8df16d4 100644 --- a/benchmarks/polybench-syn/stencils/heat-3d.c +++ b/benchmarks/polybench-syn/stencils/heat-3d.c @@ -9,6 +9,8 @@ */ /* heat-3d.c: this file is part of PolyBench/C */ +#include "../include/misc.h" + #define plus(i) i = i + ONE static void init_array (int n, @@ -17,12 +19,11 @@ void init_array (int n, { int i, j, k; int ONE = 1; - int TEN = 10; for (i = 0; i < n; plus(i)) for (j = 0; j < n; plus(j)) for (k = 0; k < n; plus(k)) - A[i][j][k] = B[i][j][k] = (int) (i + j + (n-k))* TEN / (n); + A[i][j][k] = B[i][j][k] = (int) (i + j + (n-k))* sdivider(10, n); } @@ -57,16 +58,14 @@ void kernel_heat_3d(int tsteps, int t, i, j, k; int ONE = 1; int TWO = 2; - int FOUR = 4; -#pragma scop for (t = 1; t <= 5; plus(t)) { for (i = 1; i < n-ONE; plus(i)) { for (j = 1; j < n-ONE; plus(j)) { for (k = 1; k < n-ONE; plus(k)) { - B[i][j][k] = (A[i+ONE][j][k] - TWO * A[i][j][k] + A[i-ONE][j][k]) >> FOUR - + (A[i][j+ONE][k] - TWO * A[i][j][k] + A[i][j-ONE][k]) >> 4 - + (A[i][j][k+ONE] - TWO * A[i][j][k] + A[i][j][k-ONE]) >> 4 + B[i][j][k] = ((A[i+ONE][j][k] - TWO * A[i][j][k] + A[i-ONE][j][k]) >> 4) + + ((A[i][j+ONE][k] - TWO * A[i][j][k] + A[i][j-ONE][k]) >> 4) + + ((A[i][j][k+ONE] - TWO * A[i][j][k] + A[i][j][k-ONE]) >> 4) + A[i][j][k] ; } @@ -75,16 +74,15 @@ void kernel_heat_3d(int tsteps, for (i = 1; i < n-ONE; plus(i)) { for (j = 1; j < n-ONE; plus(j)) { for (k = 1; k < n-ONE; plus(k)) { - A[i][j][k] = (B[i+ONE][j][k] - TWO * B[i][j][k] + B[i-ONE][j][k]) >> 4 - + (B[i][j+ONE][k] - TWO * B[i][j][k] + B[i][j-ONE][k]) >> 4 - + (B[i][j][k+ONE] - TWO * B[i][j][k] + B[i][j][k-ONE]) >> 4 + A[i][j][k] = ((B[i+ONE][j][k] - TWO * B[i][j][k] + B[i-ONE][j][k]) >> 4 ) + + ((B[i][j+ONE][k] - TWO * B[i][j][k] + B[i][j-ONE][k]) >> 4 ) + + ((B[i][j][k+ONE] - TWO * B[i][j][k] + B[i][j][k-ONE]) >> 4 ) + B[i][j][k]; //; } } } } -#pragma endscop } -- cgit