Remove xfail for hppa*-*-hpux* from stdatomic-flag.c and stdatomic-flag-2.c
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c++ / ref-1.C
blobb3aaf0ff5fb9b5f2af60d5e1683dc037d9e1676f
1 /* { dg-do run } */
3 #include <stdio.h>
5 #pragma acc routine vector
6 void __attribute__((noinline, noclone))
7 Vector (int *ptr, int n, const int &inc)
9 #pragma acc loop vector
10   for (unsigned ix = 0; ix < n; ix++)
11     ptr[ix] += inc;
14 #pragma acc routine worker
15 void __attribute__((noinline, noclone))
16 Worker (int *ptr, int m, int n, const int &inc)
18 #pragma acc loop worker
19   for (unsigned ix = 0; ix < m; ix++)
20     Vector(ptr + ix * n, n, inc);
23 int
24 main (void)
26   const int n = 32, m = 32;
28   int ary[m][n];
29   unsigned ix,  iy;
31   for (ix = m; ix--;)
32     for (iy = n; iy--;)
33       ary[ix][iy] = (ix << 8) + iy;
35 #pragma acc parallel copy(ary)
36   {
37     Worker (&ary[0][0], m, n, 1 << 16);
38   }
40   int err = 0;
42   for (ix = m; ix--;)
43     for (iy = n; iy--;)
44       if (ary[ix][iy] != ((1 << 16) + (ix << 8) + iy))
45         {
46           printf ("ary[%u][%u] = %x expected %x\n",
47                   ix, iy, ary[ix][iy], ((1 << 16) + (ix << 8) + iy));
48           err++;
49         }
51   if (err)
52     {
53       printf ("%d failed\n", err);
54       return 1;
55     }
57 #pragma acc parallel copy(ary)
58   {
59     Vector (&ary[0][0], m * n, (1 << 24) - (1 << 16));
60   }
62   for (ix = m; ix--;)
63     for (iy = n; iy--;)
64       if (ary[ix][iy] != ((1 << 24) + (ix << 8) + iy))
65         {
66           printf ("ary[%u][%u] = %x expected %x\n",
67                   ix, iy, ary[ix][iy], ((1 << 24) + (ix << 8) + iy));
68           err++;
69         }
71   if (err)
72     {
73       printf ("%d failed\n", err);
74       return 1;
75     }
77   return 0;