Update 'Q' constraint documentation.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / parallel-reduction.c
blob077571f29f0aadbb7673e8124d000830cf6e5c51
1 /* { dg-do run } */
2 /* { dg-additional-options "-w" } */
4 #include <stdlib.h>
5 #include <openacc.h>
7 #define N 10
9 int
10 main ()
12 int s1 = 0, s2 = 0;
13 int i;
14 int dummy = 0;
16 #pragma acc data copy (dummy)
18 #pragma acc parallel num_gangs (N) reduction (+:s1) copy(s1)
20 s1++;
24 if (acc_get_device_type () == acc_device_host)
26 if (s1 != 1)
27 abort ();
29 else
31 if (s1 != N)
32 abort ();
35 s1 = 0;
36 s2 = 0;
38 #pragma acc parallel num_gangs (10) reduction (+:s1, s2) copy(s1, s2)
40 s1++;
41 s2 += N;
44 if (acc_get_device_type () == acc_device_host)
46 if (s1 != 1)
47 abort ();
48 if (s2 != N)
49 abort ();
51 else
53 if (s1 != N)
54 abort ();
55 if (s2 != N*N)
56 abort ();
59 s1 = 0;
61 #pragma acc parallel num_gangs (10) reduction (+:s1) copy(s1)
63 #pragma acc loop gang reduction (+:s1)
64 for (i = 0; i < 10; i++)
65 s1++;
68 if (s1 != N)
69 abort ();
71 return 0;