1 /* C / C++'s logical AND and OR operators take any scalar argument
2 which compares (un)equal to 0 - the result 1 or 0 and of type int.
4 In this testcase, the int result is again converted to a floating-poing
7 While having a floating-point/complex array element with || and && can make
8 sense, having a non-integer/non-bool reduction variable is odd but valid.
10 Test: FP reduction variable + FP array. */
13 _Complex
float rcf
[N
];
14 _Complex
double rcd
[N
];
23 _Complex
float orfc
= 0;
24 _Complex
double ordc
= 0;
26 #pragma omp parallel reduction(||: orf)
27 for (int i
=0; i
< N
; ++i
)
30 #pragma omp parallel for reduction(||: ord)
31 for (int i
=0; i
< N
; ++i
)
34 #pragma omp parallel for simd reduction(||: orfc)
35 for (int i
=0; i
< N
; ++i
)
36 orfc
= orfc
|| rcf
[i
];
38 #pragma omp parallel loop reduction(||: ordc)
39 for (int i
=0; i
< N
; ++i
)
40 ordc
= ordc
|| rcd
[i
];
42 return orf
+ ord
+ __real__ orfc
+ __real__ ordc
;
50 _Complex
float orfc
= 0;
51 _Complex
double ordc
= 0;
53 #pragma omp teams distribute parallel for reduction(||: orf)
54 for (int i
=0; i
< N
; ++i
)
57 #pragma omp teams distribute parallel for simd reduction(||: ord)
58 for (int i
=0; i
< N
; ++i
)
61 #pragma omp teams distribute parallel for reduction(||: orfc)
62 for (int i
=0; i
< N
; ++i
)
63 orfc
= orfc
|| rcf
[i
];
65 #pragma omp teams distribute parallel for simd reduction(||: ordc)
66 for (int i
=0; i
< N
; ++i
)
67 ordc
= ordc
|| rcd
[i
];
69 return orf
+ ord
+ __real__ orfc
+ __real__ ordc
;
77 _Complex
float andfc
= 1;
78 _Complex
double anddc
= 1;
80 #pragma omp parallel reduction(&&: andf)
81 for (int i
=0; i
< N
; ++i
)
84 #pragma omp parallel for reduction(&&: andd)
85 for (int i
=0; i
< N
; ++i
)
86 andd
= andd
&& rcd
[i
];
88 #pragma omp parallel for simd reduction(&&: andfc)
89 for (int i
=0; i
< N
; ++i
)
90 andfc
= andfc
&& rcf
[i
];
92 #pragma omp parallel loop reduction(&&: anddc)
93 for (int i
=0; i
< N
; ++i
)
94 anddc
= anddc
&& rcd
[i
];
96 return andf
+ andd
+ __real__ andfc
+ __real__ anddc
;
100 reduction_and_teams ()
104 _Complex
float andfc
= 1;
105 _Complex
double anddc
= 1;
107 #pragma omp teams distribute parallel for reduction(&&: andf)
108 for (int i
=0; i
< N
; ++i
)
109 andf
= andf
&& rf
[i
];
111 #pragma omp teams distribute parallel for simd reduction(&&: andd)
112 for (int i
=0; i
< N
; ++i
)
113 andd
= andd
&& rcd
[i
];
115 #pragma omp teams distribute parallel for reduction(&&: andfc)
116 for (int i
=0; i
< N
; ++i
)
117 andfc
= andfc
&& rcf
[i
];
119 #pragma omp teams distribute parallel for simd reduction(&&: anddc)
120 for (int i
=0; i
< N
; ++i
)
121 anddc
= anddc
&& rcd
[i
];
123 return andf
+ andd
+ __real__ andfc
+ __real__ anddc
;
129 for (int i
= 0; i
< N
; ++i
)
137 if (reduction_or () != 0)
139 if (reduction_or_teams () != 0)
141 if (reduction_and () != 0)
143 if (reduction_and_teams () != 0)
151 if (reduction_or () != 4)
153 if (reduction_or_teams () != 4)
155 if (reduction_and () != 0)
157 if (reduction_and_teams () != 0)
160 for (int i
= 0; i
< N
; ++i
)
168 if (reduction_or () != 4)
170 if (reduction_or_teams () != 4)
172 if (reduction_and () != 4)
174 if (reduction_and_teams () != 4)
182 if (reduction_or () != 4)
184 if (reduction_or_teams () != 4)
186 if (reduction_and () != 0)
188 if (reduction_and_teams () != 0)