| 1 |
/* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting |
| 2 |
aspects of that functionality. */ |
| 3 |
|
| 4 |
const int n = 100; |
| 5 |
|
| 6 |
int |
| 7 |
private_reduction () |
| 8 |
{ |
| 9 |
int i, r; |
| 10 |
|
| 11 |
#pragma acc parallel |
| 12 |
#pragma acc loop private (r) reduction (+:r) |
| 13 |
for (i = 0; i < 100; i++) |
| 14 |
r += 10; |
| 15 |
|
| 16 |
return r; |
| 17 |
} |
| 18 |
|
| 19 |
int |
| 20 |
parallel_reduction () |
| 21 |
{ |
| 22 |
int sum = 0; |
| 23 |
int dummy = 0; |
| 24 |
|
| 25 |
#pragma acc data copy (dummy) |
| 26 |
{ |
| 27 |
#pragma acc parallel num_gangs (10) copy (sum) reduction (+:sum) |
| 28 |
/* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction'" { xfail *-*-* } .-1 } */ |
| 29 |
{ |
| 30 |
int v = 5; |
| 31 |
sum += 10 + v; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
return sum; |
| 36 |
} |
| 37 |
|
| 38 |
int |
| 39 |
main () |
| 40 |
{ |
| 41 |
int i, s = 0; |
| 42 |
|
| 43 |
#pragma acc parallel num_gangs (10) copy (s) reduction (+:s) |
| 44 |
/* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction'" { xfail *-*-* } .-1 } */ |
| 45 |
for (i = 0; i < n; i++) |
| 46 |
s += i+1; |
| 47 |
|
| 48 |
#pragma acc parallel num_gangs (10) reduction (+:s) copy (s) |
| 49 |
/* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction'" { xfail *-*-* } .-1 } */ |
| 50 |
for (i = 0; i < n; i++) |
| 51 |
s += i+1; |
| 52 |
|
| 53 |
return 0; |
| 54 |
} |