1 // RUN: %libomptarget-compilexx-and-run-generic
9 bool almost_equal(float x
, float gold
, float tol
) {
10 if (std::signbit(x
) != std::signbit(gold
))
11 x
= std::abs(gold
) - std::abs(x
);
13 return std::abs(gold
) * (1 - tol
) <= std::abs(x
) &&
14 std::abs(x
) <= std::abs(gold
) * (1 + tol
);
17 int main(int argc
, char *argv
[]) {
18 constexpr const int N0
{2};
19 constexpr const int N1
{182};
20 constexpr const float expected_value
{N0
* N1
};
23 #pragma omp target data map(tofrom : counter_N0)
25 #pragma omp taskloop shared(counter_N0)
26 for (int i0
= 0; i0
< N0
; i0
++) {
27 #pragma omp target teams distribute parallel for map(tofrom : counter_N0) nowait
28 for (int i1
= 0; i1
< N1
; i1
++) {
29 #pragma omp atomic update
30 counter_N0
= counter_N0
+ 1.;
35 if (!almost_equal(counter_N0
, expected_value
, 0.1)) {
36 std::cerr
<< "Expected: " << expected_value
<< " Got: " << counter_N0