1 // RUN: %libomptarget-compilexx-and-run-generic 2 3 // UNSUPPORTED: amdgcn-amd-amdhsa 4 5 #include <cassert> 6 #include <iostream> 7 #include <stdexcept> 8 9 int main(int argc, char *argv[]) { 10 int a = 0; 11 std::cout << "outside a = " << a << " addr " << &a << std::endl; 12 #pragma omp target map(tofrom : a) depend(out : a) nowait 13 { 14 int sum = 0; 15 for (int i = 0; i < 100000; i++) 16 sum++; 17 a = 1; 18 } 19 20 #pragma omp task depend(inout : a) shared(a) 21 { 22 std::cout << "a = " << a << " addr " << &a << std::endl; 23 if (a != 1) 24 throw std::runtime_error("wrong result!"); 25 a = 2; 26 } 27 28 #pragma omp task depend(inout : a) shared(a) 29 { 30 std::cout << "a = " << a << " addr " << &a << std::endl; 31 if (a != 2) 32 throw std::runtime_error("wrong result!"); 33 a = 3; 34 } 35 36 #pragma omp taskwait 37 38 assert(a == 3 && "wrong result!"); 39 40 return 0; 41 } 42