Files
clang-p2996/openmp/libomptarget/test/mapping/data_member_ref.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

70 lines
1.5 KiB
C++

// RUN: %libomptarget-compilexx-run-and-check-generic
// Wrong results on amdgpu
// XFAIL: amdgcn-amd-amdhsa
// XFAIL: amdgcn-amd-amdhsa-newRTL
#include <stdio.h>
struct View {
int Data;
};
struct ViewPtr {
int *Data;
};
template <typename T> struct Foo {
Foo(T &V) : VRef(V) {}
T &VRef;
};
int main() {
View V;
V.Data = 123456;
Foo<View> Bar(V);
ViewPtr V1;
int Data = 123456;
V1.Data = &Data;
Foo<ViewPtr> Baz(V1);
// CHECK: Host 123456.
printf("Host %d.\n", Bar.VRef.Data);
#pragma omp target map(Bar.VRef)
{
// CHECK: Device 123456.
printf("Device %d.\n", Bar.VRef.Data);
V.Data = 654321;
// CHECK: Device 654321.
printf("Device %d.\n", Bar.VRef.Data);
}
// CHECK: Host 654321 654321.
printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
V.Data = 123456;
// CHECK: Host 123456.
printf("Host %d.\n", Bar.VRef.Data);
#pragma omp target map(Bar) map(Bar.VRef)
{
// CHECK: Device 123456.
printf("Device %d.\n", Bar.VRef.Data);
V.Data = 654321;
// CHECK: Device 654321.
printf("Device %d.\n", Bar.VRef.Data);
}
// CHECK: Host 654321 654321.
printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
// CHECK: Host 123456.
printf("Host %d.\n", *Baz.VRef.Data);
#pragma omp target map(*Baz.VRef.Data)
{
// CHECK: Device 123456.
printf("Device %d.\n", *Baz.VRef.Data);
*V1.Data = 654321;
// CHECK: Device 654321.
printf("Device %d.\n", *Baz.VRef.Data);
}
// CHECK: Host 654321 654321 654321.
printf("Host %d %d %d.\n", *Baz.VRef.Data, *V1.Data, Data);
return 0;
}