| 1 |
/* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting |
| 2 |
aspects of that functionality. */ |
| 3 |
|
| 4 |
/* Multiple reductions. */ |
| 5 |
|
| 6 |
#include <stdio.h> |
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
#define ng 8 |
| 10 |
#define nw 4 |
| 11 |
#define vl 32 |
| 12 |
|
| 13 |
const int n = 100; |
| 14 |
|
| 15 |
#define DO_PRAGMA(x) _Pragma (#x) /* { dg-line pragma_loc } */ |
| 16 |
|
| 17 |
#define check_reduction(gwv_par, gwv_loop) \ |
| 18 |
{ \ |
| 19 |
s1 = 2; s2 = 5; \ |
| 20 |
DO_PRAGMA (acc parallel gwv_par copy (s1, s2)) /* { dg-line DO_PRAGMA_loc } */ \ |
| 21 |
DO_PRAGMA (acc loop gwv_loop reduction (+:s1, s2)) \ |
| 22 |
for (i = 0; i < n; i++) \ |
| 23 |
{ \ |
| 24 |
s1 = s1 + 3; \ |
| 25 |
s2 = s2 + 5; \ |
| 26 |
} \ |
| 27 |
\ |
| 28 |
if (s1 != v1 && s2 != v2) \ |
| 29 |
abort (); \ |
| 30 |
} |
| 31 |
|
| 32 |
int |
| 33 |
main (void) |
| 34 |
{ |
| 35 |
int s1 = 2, s2 = 5, v1 = 2, v2 = 5; |
| 36 |
int i; |
| 37 |
|
| 38 |
for (i = 0; i < n; i++) |
| 39 |
{ |
| 40 |
v1 = v1 + 3; |
| 41 |
v2 = v2 + 2; |
| 42 |
} |
| 43 |
|
| 44 |
check_reduction (num_gangs (ng), gang); |
| 45 |
|
| 46 |
/* Nvptx targets require a vector_length or 32 in to allow spinlocks with |
| 47 |
gangs. */ |
| 48 |
check_reduction (num_workers (nw) vector_length (vl), worker); /* { dg-line check_reduction_loc } */ |
| 49 |
/* { dg-warning "22:region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } pragma_loc } |
| 50 |
{ dg-note "1:in expansion of macro 'DO_PRAGMA'" "" { target *-*-* xfail offloading_enabled } DO_PRAGMA_loc } |
| 51 |
{ dg-note "3:in expansion of macro 'check_reduction'" "" { target *-*-* xfail offloading_enabled } check_reduction_loc } |
| 52 |
TODO See PR101551 for 'offloading_enabled' XFAILs. */ |
| 53 |
check_reduction (vector_length (vl), vector); |
| 54 |
check_reduction (num_gangs (ng) num_workers (nw) vector_length (vl), gang |
| 55 |
worker vector); |
| 56 |
|
| 57 |
return 0; |
| 58 |
} |