1 /* { dg-additional-options "-foffload-options=nvptx-none=-latomic" { target { offload_target_nvptx } } } */
2 /* C / C++'s logical AND and OR operators take any scalar argument
3 which compares (un)equal to 0 - the result 1 or 0 and of type int.
5 In this testcase, the int result is again converted to a floating-poing
8 While having a floating-point/complex array element with || and && can make
9 sense, having a non-integer/non-bool reduction variable is odd but valid.
11 Test: FP reduction variable + FP array - as reduction-1.c but with target */
14 _Complex
float rcf
[N
];
15 _Complex
double rcd
[N
];
24 _Complex
float orfc
= 0;
25 _Complex
double ordc
= 0;
27 #pragma omp target parallel reduction(||: orf) map(orf)
28 for (int i
=0; i
< N
; ++i
)
31 #pragma omp target parallel for reduction(||: ord) map(ord)
32 for (int i
=0; i
< N
; ++i
)
35 #pragma omp target parallel for simd reduction(||: orfc) map(orfc)
36 for (int i
=0; i
< N
; ++i
)
37 orfc
= orfc
|| rcf
[i
];
39 #pragma omp target parallel loop reduction(||: ordc) map(ordc)
40 for (int i
=0; i
< N
; ++i
)
41 ordc
= ordc
|| rcd
[i
];
43 return orf
+ ord
+ __real__ orfc
+ __real__ ordc
;
51 _Complex
float orfc
= 0;
52 _Complex
double ordc
= 0;
54 #pragma omp target teams distribute parallel for reduction(||: orf) map(orf)
55 for (int i
=0; i
< N
; ++i
)
58 #pragma omp target teams distribute parallel for simd reduction(||: ord) map(ord)
59 for (int i
=0; i
< N
; ++i
)
62 #pragma omp target teams distribute parallel for reduction(||: orfc) map(orfc)
63 for (int i
=0; i
< N
; ++i
)
64 orfc
= orfc
|| rcf
[i
];
66 #pragma omp target teams distribute parallel for simd reduction(||: ordc) map(ordc)
67 for (int i
=0; i
< N
; ++i
)
68 ordc
= ordc
|| rcd
[i
];
70 return orf
+ ord
+ __real__ orfc
+ __real__ ordc
;
78 _Complex
float andfc
= 1;
79 _Complex
double anddc
= 1;
81 #pragma omp target parallel reduction(&&: andf) map(andf)
82 for (int i
=0; i
< N
; ++i
)
85 #pragma omp target parallel for reduction(&&: andd) map(andd)
86 for (int i
=0; i
< N
; ++i
)
87 andd
= andd
&& rcd
[i
];
89 #pragma omp target parallel for simd reduction(&&: andfc) map(andfc)
90 for (int i
=0; i
< N
; ++i
)
91 andfc
= andfc
&& rcf
[i
];
93 #pragma omp target parallel loop reduction(&&: anddc) map(anddc)
94 for (int i
=0; i
< N
; ++i
)
95 anddc
= anddc
&& rcd
[i
];
97 return andf
+ andd
+ __real__ andfc
+ __real__ anddc
;
101 reduction_and_teams ()
105 _Complex
float andfc
= 1;
106 _Complex
double anddc
= 1;
108 #pragma omp target teams distribute parallel for reduction(&&: andf) map(andf)
109 for (int i
=0; i
< N
; ++i
)
110 andf
= andf
&& rf
[i
];
112 #pragma omp target teams distribute parallel for simd reduction(&&: andd) map(andd)
113 for (int i
=0; i
< N
; ++i
)
114 andd
= andd
&& rcd
[i
];
116 #pragma omp target teams distribute parallel for reduction(&&: andfc) map(andfc)
117 for (int i
=0; i
< N
; ++i
)
118 andfc
= andfc
&& rcf
[i
];
120 #pragma omp target teams distribute parallel for simd reduction(&&: anddc) map(anddc)
121 for (int i
=0; i
< N
; ++i
)
122 anddc
= anddc
&& rcd
[i
];
124 return andf
+ andd
+ __real__ andfc
+ __real__ anddc
;
130 for (int i
= 0; i
< N
; ++i
)
138 if (reduction_or () != 0)
140 if (reduction_or_teams () != 0)
142 if (reduction_and () != 0)
144 if (reduction_and_teams () != 0)
152 if (reduction_or () != 4)
154 if (reduction_or_teams () != 4)
156 if (reduction_and () != 0)
158 if (reduction_and_teams () != 0)
161 for (int i
= 0; i
< N
; ++i
)
169 if (reduction_or () != 4)
171 if (reduction_or_teams () != 4)
173 if (reduction_and () != 4)
175 if (reduction_and_teams () != 4)
183 if (reduction_or () != 4)
185 if (reduction_or_teams () != 4)
187 if (reduction_and () != 0)
189 if (reduction_and_teams () != 0)