gcc/libgomp/testsuite/libgomp.c/examples-4/simd-3.c
Maxim Blumenthal 4c1cb4da7a simd-3.c: (main): Change type of res and ref from int to double.
2015-07-14  Maxim Blumenthal  <maxim.blumenthal@intel.com>

libgomp/
	* testsuite/libgomp.c/examples-4/simd-3.c: (main): Change type of res
	and ref from int to double.  Replaced their comparison with
	an inequality of their difference and EPS.
	* testsuite/libgomp.c/examples-4/simd-8.c: (main): Replace the
	comparison of pri and a reference number with an inequality of their
	difference and EPS.
	* testsuite/libgomp.fortran/examples-4/simd-3.f90: (main): Replaced
	the comparison of sum and sum_ref with an inequality of their
	difference and EPS.
	* testsuite/libgomp.fortran/examples-4/simd-8.f90: (main): Replace
	the comparison of pri and a reference number with an inequality of
	their difference and EPS.

From-SVN: r225786
2015-07-14 18:54:35 +00:00

62 lines
1 KiB
C

/* { dg-do run } */
/* { dg-additional-options "-msse2" { target sse2_runtime } } */
/* { dg-additional-options "-mavx" { target avx_runtime } } */
#define N 100
#define EPS 0.0000000000000001
#include <stdlib.h>
void init(double *a, double *a_ref, double *b, int n)
{
int i, s = -1;
for ( i = 0; i < n; i++ )
{
a[i] = i*i*s;
a_ref[i] = a[i];
b[i] = i+i;
s = -s;
}
}
double work( double *a, double *b, int n )
{
int i;
double tmp, sum;
sum = 0.0;
#pragma omp simd private(tmp) reduction(+:sum)
for (i = 0; i < n; i++) {
tmp = a[i] + b[i];
sum += tmp;
}
return sum;
}
double work_ref( double *a, double *b, int n )
{
int i;
double tmp, sum;
sum = 0.0;
for (i = 0; i < n; i++) {
tmp = a[i] + b[i];
sum += tmp;
}
return sum;
}
int main ()
{
double a[N], a_ref[N], b[N], res, ref, diff;
init(a, a_ref, b, N);
res = work(a, b, N);
ref = work_ref(a_ref, b, N);
diff = res - ref;
if (diff > EPS || -diff > EPS)
abort ();
return 0;
}