brintos

brintos / llvm-project-archived public Read only

0
0
Text · 877 B · d2ae02b Raw
41 lines · cpp
1// RUN: %libomptarget-compilexx-and-run-generic2// RUN: %libomptarget-compileoptxx-and-run-generic3 4#include <cassert>5#include <iostream>6#include <stdexcept>7 8int 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) nowait12  {13    int sum = 0;14    for (int i = 0; i < 100000; i++)15      sum++;16    a = 1;17  }18 19#pragma omp task depend(inout : a) shared(a)20  {21    std::cout << "a = " << a << " addr " << &a << std::endl;22    if (a != 1)23      throw std::runtime_error("wrong result!");24    a = 2;25  }26 27#pragma omp task depend(inout : a) shared(a)28  {29    std::cout << "a = " << a << " addr " << &a << std::endl;30    if (a != 2)31      throw std::runtime_error("wrong result!");32    a = 3;33  }34 35#pragma omp taskwait36 37  assert(a == 3 && "wrong result!");38 39  return 0;40}41