Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / reduction-1.c
blob4e76ccd5b5c250383bb3ced034248599b1fd128b
1 /* { dg-do run } */
3 /* Integer reductions. */
5 #include <stdlib.h>
6 #include "reduction.h"
8 #define ng 8
9 #define nw 4
10 #define vl 32
12 static void
13 test_reductions (void)
15 const int n = 10;
16 int i;
17 int array[n];
19 for (i = 0; i < n; i++)
20 array[i] = i+1;
22 /* Gang reductions. */
23 check_reduction_op (int, +, 0, array[i], num_gangs (ng), gang);
24 check_reduction_op (int, *, 1, array[i], num_gangs (ng), gang);
25 check_reduction_op (int, &, -1, array[i], num_gangs (ng), gang);
26 check_reduction_op (int, |, 0, array[i], num_gangs (ng), gang);
27 check_reduction_op (int, ^, 0, array[i], num_gangs (ng), gang);
29 /* Worker reductions. */
30 check_reduction_op (int, +, 0, array[i], num_workers (nw), worker);
31 check_reduction_op (int, *, 1, array[i], num_workers (nw), worker);
32 check_reduction_op (int, &, -1, array[i], num_workers (nw), worker);
33 check_reduction_op (int, |, 0, array[i], num_workers (nw), worker);
34 check_reduction_op (int, ^, 0, array[i], num_workers (nw), worker);
36 /* Vector reductions. */
37 check_reduction_op (int, +, 0, array[i], vector_length (vl), vector);
38 check_reduction_op (int, *, 1, array[i], vector_length (vl), vector);
39 check_reduction_op (int, &, -1, array[i], vector_length (vl), vector);
40 check_reduction_op (int, |, 0, array[i], vector_length (vl), vector);
41 check_reduction_op (int, ^, 0, array[i], vector_length (vl), vector);
43 /* Combined reductions. */
44 check_reduction_op (int, +, 0, array[i], num_gangs (ng) num_workers (nw)
45 vector_length (vl), gang worker vector);
46 check_reduction_op (int, *, 1, array[i], num_gangs (ng) num_workers (nw)
47 vector_length (vl), gang worker vector);
48 check_reduction_op (int, &, -1, array[i], num_gangs (ng) num_workers (nw)
49 vector_length (vl), gang worker vector);
50 check_reduction_op (int, |, 0, array[i], num_gangs (ng) num_workers (nw)
51 vector_length (vl), gang worker vector);
52 check_reduction_op (int, ^, 0, array[i], num_gangs (ng) num_workers (nw)
53 vector_length (vl), gang worker vector);
56 static void
57 test_reductions_bool (void)
59 const int n = 1000;
60 int i;
61 int array[n];
62 int cmp_val;
64 for (i = 0; i < n; i++)
65 array[i] = i;
67 cmp_val = 5;
69 /* Gang reductions. */
70 check_reduction_op (int, &&, 1, (cmp_val > array[i]), num_gangs (ng),
71 gang);
72 check_reduction_op (int, ||, 0, (cmp_val > array[i]), num_gangs (ng),
73 gang);
75 /* Worker reductions. */
76 check_reduction_op (int, &&, 1, (cmp_val > array[i]), num_workers (nw),
77 worker);
78 check_reduction_op (int, ||, 0, (cmp_val > array[i]), num_workers (nw),
79 worker);
81 /* Vector reductions. */
82 check_reduction_op (int, &&, 1, (cmp_val > array[i]), vector_length (vl),
83 vector);
84 check_reduction_op (int, ||, 0, (cmp_val > array[i]), vector_length (vl),
85 vector);
87 /* Combined reductions. */
88 check_reduction_op (int, &&, 1, (cmp_val > array[i]), num_gangs (ng)
89 num_workers (nw) vector_length (vl), gang worker vector);
90 check_reduction_op (int, ||, 0, (cmp_val > array[i]), num_gangs (ng)
91 num_workers (nw) vector_length (vl), gang worker vector);
94 static void
95 test_reductions_minmax (void)
97 const int n = 1000;
98 int i;
99 int array[n];
101 for (i = 0; i < n; i++)
102 array[i] = i;
104 /* Gang reductions. */
105 check_reduction_macro (int, min, n + 1, array[i], num_gangs (ng), gang);
106 check_reduction_macro (int, max, -1, array[i], num_gangs (ng), gang);
108 /* Worker reductions. */
109 check_reduction_macro (int, min, n + 1, array[i], num_workers (nw), worker);
110 check_reduction_macro (int, max, -1, array[i], num_workers (nw), worker);
112 /* Vector reductions. */
113 check_reduction_macro (int, min, n + 1, array[i], vector_length (vl),
114 vector);
115 check_reduction_macro (int, max, -1, array[i], vector_length (vl), vector);
117 /* Combined reductions. */
118 check_reduction_macro (int, min, n + 1, array[i], num_gangs (ng)
119 num_workers (nw) vector_length (vl), gang worker
120 vector);
121 check_reduction_macro (int, max, -1, array[i], num_gangs (ng)
122 num_workers (nw) vector_length (vl), gang worker
123 vector);
127 main (void)
129 test_reductions ();
130 test_reductions_bool ();
131 test_reductions_minmax ();
132 return 0;