gcc/libgomp/testsuite/libgomp.c/examples-4/simd-8.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

54 lines
782 B
C

/* { dg-do run } */
/* { dg-additional-options "-msse2" { target sse2_runtime } } */
/* { dg-additional-options "-mavx" { target avx_runtime } } */
#include <stdlib.h>
#include <math.h>
#define EPS 0.005
int P[1000];
float A[1000];
float do_work(float *arr)
{
float pri;
#pragma omp simd lastprivate(pri)
for (int i = 0; i < 999; ++i)
{
int j = P[i];
pri = 0.5f;
if (j % 2 == 0)
{
pri = A[j+1] + arr[i];
}
A[j] = pri * 1.5f;
pri = pri + A[j];
}
return pri;
}
int main(void)
{
float pri, arr[1000], diff;
for (int i = 0; i < 1000; ++i)
{
P[i] = i;
A[i] = i * 1.5f;
arr[i] = i * 1.8f;
}
pri = do_work(&arr[0]);
diff = pri - 8237.25;
if (diff > EPS || -diff > EPS)
abort ();
return 0;
}