[flang][cuda] Do not register global constants (#118582)
[llvm-project.git] / offload / test / offloading / bug50022.cpp
blobd2ae02b7054b9f9e310af3e88b338a8a8179ff77
1 // RUN: %libomptarget-compilexx-and-run-generic
2 // RUN: %libomptarget-compileoptxx-and-run-generic
4 #include <cassert>
5 #include <iostream>
6 #include <stdexcept>
8 int main(int argc, char *argv[]) {
9 int a = 0;
10 std::cout << "outside a = " << a << " addr " << &a << std::endl;
11 #pragma omp target map(tofrom : a) depend(out : a) nowait
13 int sum = 0;
14 for (int i = 0; i < 100000; i++)
15 sum++;
16 a = 1;
19 #pragma omp task depend(inout : a) shared(a)
21 std::cout << "a = " << a << " addr " << &a << std::endl;
22 if (a != 1)
23 throw std::runtime_error("wrong result!");
24 a = 2;
27 #pragma omp task depend(inout : a) shared(a)
29 std::cout << "a = " << a << " addr " << &a << std::endl;
30 if (a != 2)
31 throw std::runtime_error("wrong result!");
32 a = 3;
35 #pragma omp taskwait
37 assert(a == 3 && "wrong result!");
39 return 0;