From 7d126836fc35d96bda349723caae16d04981374f Mon Sep 17 00:00:00 2001 From: Daniel Maier <daniel.maier@tu-berlin.de> Date: Wed, 26 Sep 2018 16:24:52 +0200 Subject: [PATCH] hotspot: error checking --- codes/correlation/correlation.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/codes/correlation/correlation.c b/codes/correlation/correlation.c index 6e81435..20f38d1 100644 --- a/codes/correlation/correlation.c +++ b/codes/correlation/correlation.c @@ -38,6 +38,22 @@ void init_array (int m, } +static +void calc_error(int m, + DATA_TYPE POLYBENCH_2D(corr,M,M,m,m)) + +{ + int i, j; + double error = 0; + + for (i = 0; i < m; i++) + for (j = 0; j < m; j++) { + error += (corr[i][j] - 1.0)*(corr[i][j] - 1.0); + } + error /= m*m; + error = sqrtf(error); + printf("error: %f\n", error); +} /* DCE code. Must scan the entire live-out data. Can be used also to check the correctness of the output. */ @@ -158,6 +174,9 @@ int main(int argc, char** argv) by the function call in argument. */ polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(corr))); + /* calculate error */ + calc_error(m, POLYBENCH_ARRAY(corr)); + /* Be clean. */ POLYBENCH_FREE_ARRAY(data); POLYBENCH_FREE_ARRAY(corr); -- GitLab