Improve atomic store implementation on hppa-linux.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / par-reduction-1.c
blob8157cff109a724651d24a82b978c50b8d30f727a
1 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
2 aspects of that functionality. */
4 #include <assert.h>
6 /* Test of reduction on parallel directive. */
8 #define ACTUAL_GANGS 256
10 int
11 main (int argc, char *argv[])
13 int res, res1 = 0, res2 = 0;
15 #if defined(ACC_DEVICE_TYPE_host)
16 # define GANGS 1
17 #else
18 # define GANGS 256
19 #endif
20 #pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
21 reduction(+:res1) copy(res2, res1)
22 /* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction', 'atomic'" { xfail { ! openacc_host_selected } } .-2 } */
23 /* { dg-warning "region is worker partitioned but does not contain worker partitioned code" "" { target *-*-* } .-3 } */
24 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-4 } */
26 res1 += 5;
28 #pragma acc atomic
29 res2 += 5;
31 res = GANGS * 5;
33 assert (res == res1);
34 assert (res == res2);
35 #undef GANGS
37 res = res1 = res2 = 1;
39 #if defined(ACC_DEVICE_TYPE_host)
40 # define GANGS 1
41 #else
42 # define GANGS 8
43 #endif
44 #pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
45 reduction(*:res1) copy(res1, res2)
46 /* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction', 'atomic'" { xfail { ! openacc_host_selected } } .-2 } */
47 /* { dg-warning "region is worker partitioned but does not contain worker partitioned code" "" { target *-*-* } .-3 } */
48 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-4 } */
50 res1 *= 5;
52 #pragma acc atomic
53 res2 *= 5;
55 for (int i = 0; i < GANGS; ++i)
56 res *= 5;
58 assert (res == res1);
59 assert (res == res2);
60 #undef GANGS
62 return 0;