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

trisolv calc_error

parent e227ced8
No related branches found
No related tags found
No related merge requests found
File added
File added
......@@ -59,6 +59,36 @@ 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(x,N,n))
{
int i;
double err = 0;
double *accurate = &_binary_data_bin_start;
double *test = x;
for(i = 0; i < n; i++) {
if(fabs(accurate[i] - test[i]) > 0.0) {
double e;
if(fabs(accurate[i]) > 0.0) {
e = fabs((accurate[i] - test[i])/accurate[i]);
}
else {
e = fabs(accurate[i] - test[i]);
}
/* clamp error to max 1 */
if(e > 1)
e = 1;
err += e;
}
}
err /= n;
printf("error: %f\n", err);
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
......@@ -111,6 +141,8 @@ int main(int argc, char** argv)
by the function call in argument. */
polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(x)));
calc_error(n, POLYBENCH_ARRAY(x));
/* Be clean. */
POLYBENCH_FREE_ARRAY(L);
POLYBENCH_FREE_ARRAY(x);
......
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