PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / reduction-3.c
blob1b948bef5a04bcba1ce81dfafb7d35b75021b607
1 /* { dg-do run } */
3 /* Ignore vector_length warnings for offloaded (nvptx) targets. */
4 /* { dg-additional-options "-foffload=-w" } */
6 /* double reductions. */
8 #include <stdlib.h>
9 #include "reduction.h"
11 const int ng = 8;
12 const int nw = 4;
13 const int vl = 32;
15 static void
16 test_reductions (void)
18 const int n = 10;
19 int i;
20 double array[n];
22 for (i = 0; i < n; i++)
23 array[i] = i+1;
25 /* Gang reductions. */
26 check_reduction_op (double, +, 0, array[i], num_gangs (ng), gang);
27 check_reduction_op (double, *, 1, array[i], num_gangs (ng), gang);
29 /* Worker reductions. */
30 check_reduction_op (double, +, 0, array[i], num_workers (nw), worker);
31 check_reduction_op (double, *, 1, array[i], num_workers (nw), worker);
33 /* Vector reductions. */
34 check_reduction_op (double, +, 0, array[i], vector_length (vl), vector);
35 check_reduction_op (double, *, 1, array[i], vector_length (vl), vector);
37 /* Combined reductions. */
38 check_reduction_op (double, +, 0, array[i], num_gangs (ng) num_workers (nw)
39 vector_length (vl), gang worker vector);
40 check_reduction_op (double, *, 1, array[i], num_gangs (ng) num_workers (nw)
41 vector_length (vl), gang worker vector);
44 static void
45 test_reductions_minmax (void)
47 const int n = 1000;
48 int i;
49 double array[n];
51 for (i = 0; i < n; i++)
52 array[i] = i;
54 /* Gang reductions. */
55 check_reduction_macro (double, min, n + 1, array[i], num_gangs (ng), gang);
56 check_reduction_macro (double, max, -1, array[i], num_gangs (ng), gang);
58 /* Worker reductions. */
59 check_reduction_macro (double, min, n + 1, array[i], num_workers (nw),
60 worker);
61 check_reduction_macro (double, max, -1, array[i], num_workers (nw), worker);
63 /* Vector reductions. */
64 check_reduction_macro (double, min, n + 1, array[i], vector_length (vl),
65 vector);
66 check_reduction_macro (double, max, -1, array[i], vector_length (vl),
67 vector);
69 /* Combined reductions. */
70 check_reduction_macro (double, min, n + 1, array[i], num_gangs (ng)
71 num_workers (nw) vector_length (vl), gang worker
72 vector);
73 check_reduction_macro (double, max, -1, array[i], num_gangs (ng)
74 num_workers (nw) vector_length (vl), gang worker
75 vector);
78 int
79 main (void)
81 test_reductions ();
82 test_reductions_minmax ();
83 return 0;