Remove dg-options -O2 in libgomp.c
[official-gcc.git] / libgomp / testsuite / libgomp.c / examples-4 / e.53.5.c
blobb550f1ff5407c3f6e5fd7c0d1040b1e713ac0b4c
1 /* { dg-do run { target vect_simd_clones } } */
2 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
3 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 #include <stdlib.h>
7 #define EPS 0.00001
8 #define N 10000
9 #define M 1024
11 #pragma omp declare target
12 float Q[N][N];
13 #pragma omp declare simd uniform(i) linear(k) notinbranch
14 float Pfun (const int i, const int k)
16 return Q[i][k] * Q[k][i];
18 #pragma omp end declare target
20 void init ()
22 int i, j;
23 for (i = 0; i < N; i++)
24 for (j = 0; j < N; j++)
25 Q[i][j] = 0.001 * i * j;
28 float accum_ref ()
30 int i, k;
31 float tmp = 0.0;
33 for (i = 0; i < N; i++)
35 float tmp1 = 0.0;
37 for (k = 0; k < M; k++)
38 tmp1 += Pfun(i,k);
40 tmp += tmp1;
43 return tmp;
46 float accum ()
48 int i, k;
49 float tmp = 0.0;
51 #pragma omp target
52 #pragma omp parallel for reduction(+:tmp)
53 for (i = 0; i < N; i++)
55 float tmp1 = 0.0;
57 #pragma omp simd reduction(+:tmp1)
58 for (k = 0; k < M; k++)
59 tmp1 += Pfun(i,k);
61 tmp += tmp1;
64 return tmp;
67 void check (float a, float b)
69 float err = (b == 0.0) ? a : (a - b) / b;
70 if (((err > 0) ? err : -err) > EPS)
71 abort ();
74 int main ()
76 init ();
78 #pragma omp target update to(Q)
80 check (accum (), accum_ref ());
82 return 0;