2017-04-10 11:32:00 +00:00
|
|
|
/* { dg-do run } */
|
|
|
|
/* { dg-additional-options "-w" } */
|
|
|
|
|
|
|
|
/* Multiple reductions. */
|
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2019-06-02 15:48:37 +00:00
|
|
|
#define ng 8
|
|
|
|
#define nw 4
|
|
|
|
#define vl 32
|
2017-04-10 11:32:00 +00:00
|
|
|
|
|
|
|
const int n = 100;
|
|
|
|
|
|
|
|
#define DO_PRAGMA(x) _Pragma (#x)
|
|
|
|
|
|
|
|
#define check_reduction(gwv_par, gwv_loop) \
|
|
|
|
{ \
|
|
|
|
s1 = 2; s2 = 5; \
|
|
|
|
DO_PRAGMA (acc parallel gwv_par copy (s1, s2)) \
|
|
|
|
DO_PRAGMA (acc loop gwv_loop reduction (+:s1, s2)) \
|
|
|
|
for (i = 0; i < n; i++) \
|
|
|
|
{ \
|
|
|
|
s1 = s1 + 3; \
|
|
|
|
s2 = s2 + 5; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
if (s1 != v1 && s2 != v2) \
|
|
|
|
abort (); \
|
|
|
|
}
|
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
int s1 = 2, s2 = 5, v1 = 2, v2 = 5;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
v1 = v1 + 3;
|
|
|
|
v2 = v2 + 2;
|
|
|
|
}
|
2017-04-10 11:32:00 +00:00
|
|
|
|
|
|
|
check_reduction (num_gangs (ng), gang);
|
|
|
|
|
|
|
|
/* Nvptx targets require a vector_length or 32 in to allow spinlocks with
|
|
|
|
gangs. */
|
|
|
|
check_reduction (num_workers (nw) vector_length (vl), worker);
|
|
|
|
check_reduction (vector_length (vl), vector);
|
|
|
|
check_reduction (num_gangs (ng) num_workers (nw) vector_length (vl), gang
|
|
|
|
worker vector);
|
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
return 0;
|
2017-04-10 11:32:00 +00:00
|
|
|
}
|