1 // RUN: %libomptarget-compilexx-and-run-generic
3 // Taken from https://github.com/llvm/llvm-project/issues/54216
9 bool almost_equal(float x
, float gold
, float rel_tol
= 1e-09,
10 float abs_tol
= 0.0) {
11 return std::abs(x
- gold
) <=
12 std::max(rel_tol
* std::max(std::abs(x
), std::abs(gold
)), abs_tol
);
14 void test_parallel_for__target() {
16 const float expected_value
{N0
};
18 #pragma omp parallel for
19 for (int i0
= 0; i0
< N0
; i0
++) {
20 #pragma omp target map(tofrom : counter_N0)
22 #pragma omp atomic update
23 counter_N0
= counter_N0
+ 1.;
26 if (!almost_equal(counter_N0
, expected_value
, 0.01)) {
27 std::cerr
<< "Expected: " << expected_value
<< " Got: " << counter_N0
32 int main() { test_parallel_for__target(); }