Run testsuite/libgomp.c++/c++.exp at -O2 by default
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / target-2.C
blob35e910acc2e3da4c1b83dc8f4282eec22ec1a3cf
1 // { dg-additional-sources "target-2-aux.cc" }
3 extern "C" void abort (void);
5 void
6 fn1 (double *x, double *y, int z)
8   int i;
9   for (i = 0; i < z; i++)
10     {
11       x[i] = i & 31;
12       y[i] = (i & 63) - 30;
13     }
16 double b[1024];
17 double (&br) [1024] = b;
18 double cbuf[1024];
19 double *c = cbuf;
20 double *&cr = c;
21 extern double (&fr) [1024];
22 extern double *&gr;
24 double
25 fn2 (int x, double (&dr) [1024], double *&er)
27   double s = 0;
28   double h[1024];
29   double (&hr) [1024] = h;
30   double ibuf[1024];
31   double *i = ibuf;
32   double *&ir = i;
33   int j;
34   fn1 (hr + 2 * x, ir + 2 * x, x);
35   #pragma omp target map(to: br[:x], cr[0:x], dr[x:x], er[x:x]) \
36                      map(to: fr[0:x], gr[0:x], hr[2 * x:x], ir[2 * x:x])
37     #pragma omp parallel for reduction(+:s)
38       for (j = 0; j < x; j++)
39         s += br[j] * cr[j] + dr[x + j] + er[x + j]
40              + fr[j] + gr[j] + hr[2 * x + j] + ir[2 * x + j];
41   return s;
44 int
45 main ()
47   double d[1024];
48   double ebuf[1024];
49   double *e = ebuf;
50   fn1 (br, cr, 128);
51   fn1 (d + 128, e + 128, 128);
52   fn1 (fr, gr, 128);
53   double h = fn2 (128, d, e);
54   if (h != 20416.0)
55     abort ();
56   return 0;