Skip to content
Snippets Groups Projects
Commit 8321c788 authored by Daniel Maier's avatar Daniel Maier
Browse files

covariance: error checking

parent a035db41
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,25 @@ void print_array(int m,
POLYBENCH_DUMP_FINISH;
}
extern double _binary_data_bin_start;
extern double _binary_data_bin_end;
static
void calc_error(int m,
DATA_TYPE POLYBENCH_2D(cov,M,M,m,m))
{
int i, j;
double err = 0;
double *accurate = &_binary_data_bin_start;
double *test = &(cov[0][0]);
/* calculate the mean squared error */
for (i = 0; i < m*m; i++) {
err += (accurate[i] - test[i])*(accurate[i] - test[i]);
}
err /= m*m;
printf("error: %f\n", err);
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
......@@ -129,6 +148,8 @@ int main(int argc, char** argv)
by the function call in argument. */
polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(cov)));
calc_error(m, POLYBENCH_ARRAY(cov));
/* Be clean. */
POLYBENCH_FREE_ARRAY(data);
POLYBENCH_FREE_ARRAY(cov);
......
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment