[RISC-V] add implied extension repeatly until stable
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / par-reduction-2.c
blob8b7900e66ffa43e0421919a60ae1f8701f55c7fc
1 /* Test of reduction on parallel directive (with async). */
2 /* See also Fortran variants in "../libgomp.oacc-fortran/par-reduction-2*". */
4 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
5 aspects of that functionality. */
7 #include <assert.h>
8 #include <openacc.h>
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(res1, res2) async(1)
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 acc_async_wait (1);
35 assert (res == res1);
36 assert (res == res2);
37 #undef GANGS
39 res = res1 = res2 = 1;
41 #if defined(ACC_DEVICE_TYPE_host)
42 # define GANGS 1
43 #else
44 # define GANGS 8
45 #endif
46 #pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
47 reduction(*:res1) copy(res1, res2) async(1)
48 /* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction', 'atomic'" { xfail { ! openacc_host_selected } } .-2 } */
49 /* { dg-warning "region is worker partitioned but does not contain worker partitioned code" "" { target *-*-* } .-3 } */
50 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-4 } */
52 res1 *= 5;
54 #pragma acc atomic
55 res2 *= 5;
57 for (int i = 0; i < GANGS; ++i)
58 res *= 5;
60 acc_async_wait_all ();
62 assert (res == res1);
63 assert (res == res2);
65 return 0;