Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / declare_mapper_target_data.cpp
blob7f098440140052773e0cdd4b9174f759737e03c6
1 // RUN: %libomptarget-compile-run-and-check-generic
3 #include <cstdio>
4 #include <cstdlib>
6 #define NUM 1024
8 class C {
9 public:
10 int *a;
13 #pragma omp declare mapper(id : C s) map(s.a[0 : NUM])
15 int main() {
16 C c;
17 c.a = (int *)malloc(sizeof(int) * NUM);
18 for (int i = 0; i < NUM; i++) {
19 c.a[i] = 1;
21 #pragma omp target data map(mapper(id), tofrom : c)
23 #pragma omp target teams distribute parallel for
24 for (int i = 0; i < NUM; i++) {
25 ++c.a[i];
28 int sum = 0;
29 for (int i = 0; i < NUM; i++) {
30 sum += c.a[i];
32 // CHECK: Sum = 2048
33 printf("Sum = %d\n", sum);
34 return 0;