Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / declare_mapper_target_data_enter_exit.cpp
blobf5fad8b8fe332043db91a914d6afd7c0db843662
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 enter data map(mapper(id), to : c)
22 #pragma omp target teams distribute parallel for
23 for (int i = 0; i < NUM; i++) {
24 ++c.a[i];
26 #pragma omp target exit data map(mapper(id), from : c)
27 int sum = 0;
28 for (int i = 0; i < NUM; i++) {
29 sum += c.a[i];
31 // CHECK: Sum = 2048
32 printf("Sum = %d\n", sum);
33 return 0;