Files
clang-p2996/openmp/libomptarget/test/offloading/bug50022.cpp
Johannes Doerfert e5a3d5ba88 [OpenMP][NFC] Enable more runtime tests and also run them with O3
The test run fine on my AMD GPU machine, we should verify them on others
too and put them into our regular testing. Not testing O1/2/3 is really
bad and not testing all architecturs is similarly problematic.

Differential Revision: https://reviews.llvm.org/D148576
2023-07-31 15:45:53 -07:00

41 lines
877 B
C++

// RUN: %libomptarget-compilexx-and-run-generic
// RUN: %libomptarget-compileoptxx-and-run-generic
#include <cassert>
#include <iostream>
#include <stdexcept>
int main(int argc, char *argv[]) {
int a = 0;
std::cout << "outside a = " << a << " addr " << &a << std::endl;
#pragma omp target map(tofrom : a) depend(out : a) nowait
{
int sum = 0;
for (int i = 0; i < 100000; i++)
sum++;
a = 1;
}
#pragma omp task depend(inout : a) shared(a)
{
std::cout << "a = " << a << " addr " << &a << std::endl;
if (a != 1)
throw std::runtime_error("wrong result!");
a = 2;
}
#pragma omp task depend(inout : a) shared(a)
{
std::cout << "a = " << a << " addr " << &a << std::endl;
if (a != 2)
throw std::runtime_error("wrong result!");
a = 3;
}
#pragma omp taskwait
assert(a == 3 && "wrong result!");
return 0;
}