1 // RUN: %libomptarget-compilexx-generic
2 // RUN: %libomptarget-run-generic %fcheck-generic
4 // UNSUPPORTED: aarch64-unknown-linux-gnu
5 // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
6 // UNSUPPORTED: nvptx64-nvidia-cuda
7 // UNSUPPORTED: nvptx64-nvidia-cuda-LTO
8 // UNSUPPORTED: x86_64-pc-linux-gnu
9 // UNSUPPORTED: x86_64-pc-linux-gnu-LTO
10 // UNSUPPORTED: amdgcn-amd-amdhsa
17 void *llvm_omp_target_lock_mem(void *ptr
, size_t size
, int device_num
);
18 void llvm_omp_target_unlock_mem(void *ptr
, int device_num
);
23 int *unlocked
= new int[n
];
25 for (int i
= 0; i
< n
; i
++)
28 int *locked
= (int *)llvm_omp_target_lock_mem(unlocked
, n
* sizeof(int),
29 omp_get_default_device());
33 #pragma omp target teams distribute parallel for map(tofrom : unlocked[ : n])
34 for (int i
= 0; i
< n
; i
++)
37 #pragma omp target teams distribute parallel for map(tofrom : unlocked[10 : 10])
38 for (int i
= 10; i
< 20; i
++)
41 #pragma omp target teams distribute parallel for map(tofrom : locked[ : n])
42 for (int i
= 0; i
< n
; i
++)
45 #pragma omp target teams distribute parallel for map(tofrom : locked[10 : 10])
46 for (int i
= 10; i
< 20; i
++)
49 llvm_omp_target_unlock_mem(unlocked
, omp_get_default_device());
52 for (int i
= 0; i
< n
; i
++) {
53 if (i
< 10 || i
> 19) {
54 if (unlocked
[i
] != i
+ 2) {
55 printf("Err at %d, got %d, expected %d\n", i
, unlocked
[i
], i
+ 1);
58 } else if (unlocked
[i
] != i
+ 4) {
59 printf("Err at %d, got %d, expected %d\n", i
, unlocked
[i
], i
+ 2);