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 an integer complex
7 While having a floating-point/complex array element with || and && can make
8 sense, having a complex reduction variable is odd but valid.
10 Test: int complex reduction variable + int complex array. */
14 _Complex
short rcs
[N
];
16 _Complex
long long rcl
[N
];
21 _Complex
char orc
= 0;
22 _Complex
short ors
= 0;
24 _Complex
long orl
= 0;
26 #pragma omp parallel reduction(||: orc)
27 for (int i
=0; i
< N
; ++i
)
30 #pragma omp parallel for reduction(||: ors)
31 for (int i
=0; i
< N
; ++i
)
34 #pragma omp parallel for simd reduction(||: ori)
35 for (int i
=0; i
< N
; ++i
)
38 #pragma omp parallel loop reduction(||: orl)
39 for (int i
=0; i
< N
; ++i
)
42 return __real__ (orc
+ ors
+ ori
+ orl
) + __imag__ (orc
+ ors
+ ori
+ orl
);
48 _Complex
char orc
= 0;
49 _Complex
short ors
= 0;
51 _Complex
long orl
= 0;
53 #pragma omp teams distribute parallel for reduction(||: orc)
54 for (int i
=0; i
< N
; ++i
)
57 #pragma omp teams distribute parallel for simd reduction(||: ors)
58 for (int i
=0; i
< N
; ++i
)
61 #pragma omp teams distribute parallel for reduction(||: ori)
62 for (int i
=0; i
< N
; ++i
)
65 #pragma omp teams distribute parallel for simd reduction(||: orl)
66 for (int i
=0; i
< N
; ++i
)
69 return __real__ (orc
+ ors
+ ori
+ orl
) + __imag__ (orc
+ ors
+ ori
+ orl
);
75 _Complex
char andc
= 1;
76 _Complex
short ands
= 1;
77 _Complex
int andi
= 1;
78 _Complex
long andl
= 1;
80 #pragma omp parallel reduction(&&: andc)
81 for (int i
=0; i
< N
; ++i
)
82 andc
= andc
&& rcc
[i
];
84 #pragma omp parallel for reduction(&&: ands)
85 for (int i
=0; i
< N
; ++i
)
86 ands
= ands
&& rcs
[i
];
88 #pragma omp parallel for simd reduction(&&: andi)
89 for (int i
=0; i
< N
; ++i
)
90 andi
= andi
&& rci
[i
];
92 #pragma omp parallel loop reduction(&&: andl)
93 for (int i
=0; i
< N
; ++i
)
94 andl
= andl
&& rcl
[i
];
96 return __real__ (andc
+ ands
+ andi
+ andl
)
97 + __imag__ (andc
+ ands
+ andi
+ andl
);
101 reduction_and_teams ()
103 _Complex
char andc
= 1;
104 _Complex
short ands
= 1;
105 _Complex
int andi
= 1;
106 _Complex
long andl
= 1;
108 #pragma omp teams distribute parallel for reduction(&&: andc)
109 for (int i
=0; i
< N
; ++i
)
110 andc
= andc
&& rcl
[i
];
112 #pragma omp teams distribute parallel for simd reduction(&&: ands)
113 for (int i
=0; i
< N
; ++i
)
114 ands
= ands
&& rci
[i
];
116 #pragma omp teams distribute parallel for reduction(&&: andi)
117 for (int i
=0; i
< N
; ++i
)
118 andi
= andi
&& rcs
[i
];
120 #pragma omp teams distribute parallel for simd reduction(&&: andl)
121 for (int i
=0; i
< N
; ++i
)
122 andl
= andl
&& rcc
[i
];
124 return __real__ (andc
+ ands
+ andi
+ andl
)
125 + __imag__ (andc
+ ands
+ andi
+ andl
);
131 for (int i
= 0; i
< N
; ++i
)
139 if (reduction_or () != 0)
141 if (reduction_or_teams () != 0)
143 if (reduction_and () != 0)
145 if (reduction_and_teams () != 0)
153 if (reduction_or () != 4)
155 if (reduction_or_teams () != 4)
157 if (reduction_and () != 0)
159 if (reduction_and_teams () != 0)
162 for (int i
= 0; i
< N
; ++i
)
170 if (reduction_or () != 4)
172 if (reduction_or_teams () != 4)
174 if (reduction_and () != 4)
176 if (reduction_and_teams () != 4)
184 if (reduction_or () != 4)
186 if (reduction_or_teams () != 4)
188 if (reduction_and () != 0)
190 if (reduction_and_teams () != 0)