From bd45239a2b99217612f31aa90344bb726928c470 Mon Sep 17 00:00:00 2001 From: Daniel Maier <daniel.maier@tu-berlin.de> Date: Tue, 2 Oct 2018 16:06:30 +0200 Subject: [PATCH] jacobi-1d: error checking --- codes/jacobi-1d/jacobi-1d.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/codes/jacobi-1d/jacobi-1d.c b/codes/jacobi-1d/jacobi-1d.c index feceb5d..6cd537c 100644 --- a/codes/jacobi-1d/jacobi-1d.c +++ b/codes/jacobi-1d/jacobi-1d.c @@ -57,6 +57,26 @@ void print_array(int n, POLYBENCH_DUMP_FINISH; } +extern double _binary_data_bin_start; +extern double _binary_data_bin_end; + +static +void calc_error(int n, + DATA_TYPE POLYBENCH_1D(A,N,n)) +{ + int i; + double err = 0; + double *accurate = &_binary_data_bin_start; + double *test = &(A[0]); + + /* calculate the mean squared error */ + for(i = 0; i < n; i++) { + err += (accurate[i] - test[i])*(accurate[i] - test[i]); + } + err /= n; + printf("error: %f\n", err); +} + /* Main computational kernel. The whole function will be timed, including the call and return. */ @@ -109,6 +129,8 @@ int main(int argc, char** argv) by the function call in argument. */ polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(A))); + calc_error(n, POLYBENCH_ARRAY(A)); + /* Be clean. */ POLYBENCH_FREE_ARRAY(A); POLYBENCH_FREE_ARRAY(B); -- GitLab