1 // RUN: %libomptarget-compilexx-generic
2 // RUN: %libomptarget-run-generic %fcheck-generic
5 // UNSUPPORTED: nvidiagpu
13 void *llvm_omp_target_lock_mem(void *ptr
, size_t size
, int device_num
);
14 void llvm_omp_target_unlock_mem(void *ptr
, int device_num
);
19 int *unlocked
= new int[n
];
21 for (int i
= 0; i
< n
; i
++)
24 int *locked
= (int *)llvm_omp_target_lock_mem(unlocked
, n
* sizeof(int),
25 omp_get_default_device());
29 #pragma omp target teams distribute parallel for map(tofrom : unlocked[ : n])
30 for (int i
= 0; i
< n
; i
++)
33 #pragma omp target teams distribute parallel for map(tofrom : unlocked[10 : 10])
34 for (int i
= 10; i
< 20; i
++)
37 #pragma omp target teams distribute parallel for map(tofrom : locked[ : n])
38 for (int i
= 0; i
< n
; i
++)
41 #pragma omp target teams distribute parallel for map(tofrom : locked[10 : 10])
42 for (int i
= 10; i
< 20; i
++)
45 llvm_omp_target_unlock_mem(unlocked
, omp_get_default_device());
48 for (int i
= 0; i
< n
; i
++) {
49 if (i
< 10 || i
> 19) {
50 if (unlocked
[i
] != i
+ 2) {
51 printf("Err at %d, got %d, expected %d\n", i
, unlocked
[i
], i
+ 1);
54 } else if (unlocked
[i
] != i
+ 4) {
55 printf("Err at %d, got %d, expected %d\n", i
, unlocked
[i
], i
+ 2);