Files
clang-p2996/openmp/libomptarget/test/offloading/bug50022.cpp
Jon Chesterfield 27177b82d4 [OpenMP] Lower printf to __llvm_omp_vprintf
Extension of D112504. Lower amdgpu printf to `__llvm_omp_vprintf`
which takes the same const char*, void* arguments as cuda vprintf and also
passes the size of the void* alloca which will be needed by a non-stub
implementation of `__llvm_omp_vprintf` for amdgpu.

This removes the amdgpu link error on any printf in a target region in favour
of silently compiling code that doesn't print anything to stdout.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D112680
2021-11-10 15:30:56 +00:00

40 lines
826 B
C++

// RUN: %libomptarget-compilexx-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;
}