PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / reduction-5.c
blob46b553a61ff6d37f45398e0893c2da3e5c76faad
1 /* { dg-do run } */
2 /* { dg-additional-options "-w" } */
4 /* Ignore vector_length warnings for offloaded (nvptx) targets. */
5 /* { dg-additional-options "-foffload=-w" } */
7 /* Multiple reductions. */
9 #include <stdio.h>
10 #include <stdlib.h>
12 const int ng = 8;
13 const int nw = 4;
14 const int vl = 32;
16 const int n = 100;
18 #define DO_PRAGMA(x) _Pragma (#x)
20 #define check_reduction(gwv_par, gwv_loop) \
21 { \
22 s1 = 2; s2 = 5; \
23 DO_PRAGMA (acc parallel gwv_par copy (s1, s2)) \
24 DO_PRAGMA (acc loop gwv_loop reduction (+:s1, s2)) \
25 for (i = 0; i < n; i++) \
26 { \
27 s1 = s1 + 3; \
28 s2 = s2 + 5; \
29 } \
31 if (s1 != v1 && s2 != v2) \
32 abort (); \
35 int
36 main (void)
38 int s1 = 2, s2 = 5, v1 = 2, v2 = 5;
39 int i;
41 for (i = 0; i < n; i++)
43 v1 = v1 + 3;
44 v2 = v2 + 2;
47 check_reduction (num_gangs (ng), gang);
49 /* Nvptx targets require a vector_length or 32 in to allow spinlocks with
50 gangs. */
51 check_reduction (num_workers (nw) vector_length (vl), worker);
52 check_reduction (vector_length (vl), vector);
53 check_reduction (num_gangs (ng) num_workers (nw) vector_length (vl), gang
54 worker vector);
56 return 0;