PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / reduction-2.c
blobd19b1c825ca4fe2df4c0b50edaa35d3e5fffdee2
1 /* { dg-do run } */
3 /* Ignore vector_length warnings for offloaded (nvptx) targets. */
4 /* { dg-additional-options "-foffload=-w" } */
6 /* float 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 float array[n];
22 for (i = 0; i < n; i++)
23 array[i] = i+1;
25 /* Gang reductions. */
26 check_reduction_op (float, +, 0, array[i], num_gangs (ng), gang);
27 check_reduction_op (float, *, 1, array[i], num_gangs (ng), gang);
29 /* Worker reductions. */
30 check_reduction_op (float, +, 0, array[i], num_workers (nw), worker);
31 check_reduction_op (float, *, 1, array[i], num_workers (nw), worker);
33 /* Vector reductions. */
34 check_reduction_op (float, +, 0, array[i], vector_length (vl), vector);
35 check_reduction_op (float, *, 1, array[i], vector_length (vl), vector);
37 /* Combined reductions. */
38 check_reduction_op (float, +, 0, array[i], num_gangs (ng) num_workers (nw)
39 vector_length (vl), gang worker vector);
40 check_reduction_op (float, *, 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 float array[n];
51 for (i = 0; i < n; i++)
52 array[i] = i;
54 /* Gang reductions. */
55 check_reduction_macro (float, min, n + 1, array[i], num_gangs (ng), gang);
56 check_reduction_macro (float, max, -1, array[i], num_gangs (ng), gang);
58 /* Worker reductions. */
59 check_reduction_macro (float, min, n + 1, array[i], num_workers (nw),
60 worker);
61 check_reduction_macro (float, max, -1, array[i], num_workers (nw), worker);
63 /* Vector reductions. */
64 check_reduction_macro (float, min, n + 1, array[i], vector_length (vl),
65 vector);
66 check_reduction_macro (float, max, -1, array[i], vector_length (vl), vector);
68 /* Combined reductions. */
69 check_reduction_macro (float, min, n + 1, array[i], num_gangs (ng)
70 num_workers (nw) vector_length (vl), gang worker
71 vector);
72 check_reduction_macro (float, max, -1, array[i], num_gangs (ng)
73 num_workers (nw)vector_length (vl), gang worker
74 vector);
77 int
78 main (void)
80 test_reductions ();
81 test_reductions_minmax ();
82 return 0;