From aba1066919919bf068b723fca3741be6f3a1de97 Mon Sep 17 00:00:00 2001 From: Nadesh Ramanathan Date: Sun, 15 Nov 2020 11:44:21 +0000 Subject: some fixes --- benchmarks/polybench-syn/stencils/fdtd-2d.c | 14 +++++++------- benchmarks/polybench-syn/stencils/heat-3d.c | 20 +++++++++----------- 2 files changed, 16 insertions(+), 18 deletions(-) (limited to 'benchmarks/polybench-syn/stencils') 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