diff --git a/codes/adi/adi.c b/codes/adi/adi.c index 1eee045b3e9a1be2f675cf94a0aba227364c5b97..ff772fdba933b968dcf9bc69d2828bfd08cd2df0 100644 --- a/codes/adi/adi.c +++ b/codes/adi/adi.c @@ -56,6 +56,27 @@ 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_2D(u,N,N,n,n)) +{ + int i; + double err = 0; + double *accurate = &_binary_data_bin_start; + double *test = &(u[0][0]); + + /* calculate the mean squared error */ + for(i = 0; i < n*n; i++) { + err += (accurate[i] - test[i])*(accurate[i] - test[i]); + } + err /= n*n; + printf("error: %f\n", err); +} + + /* Main computational kernel. The whole function will be timed, including the call and return. */ @@ -154,6 +175,8 @@ int main(int argc, char** argv) polybench_stop_instruments; polybench_print_instruments; + calc_error(n, POLYBENCH_ARRAY(u)); + /* Prevent dead-code elimination. All live-out data must be printed by the function call in argument. */ polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(u)));