1 | // RUN: %libomptarget-compilexx-run-and-check-generic |
2 | |
3 | #include <stdint.h> |
4 | #include <stdio.h> |
5 | |
6 | // CHECK: before: [[V1:111]] [[V2:222]] [[PX:0x[^ ]+]] [[PY:0x[^ ]+]] |
7 | // CHECK: lambda: [[V1]] [[V2]] [[PX_TGT:0x[^ ]+]] 0x{{.*}} |
8 | // CHECK: tgt : [[V2]] [[PX_TGT]] 1 |
9 | // CHECK: out : [[V2]] [[V2]] [[PX]] [[PY]] |
10 | |
11 | #pragma omp begin declare target |
12 | int a = -1, *c; |
13 | long b = -1; |
14 | const long *d; |
15 | int e = -1, *f, g = -1; |
16 | #pragma omp end declare target |
17 | |
18 | int main() { |
19 | int x[10]; |
20 | long y[8]; |
21 | x[1] = 111; |
22 | y[1] = 222; |
23 | |
24 | auto lambda = [&x, y]() { |
25 | a = x[1]; |
26 | b = y[1]; |
27 | c = &x[0]; |
28 | d = &y[0]; |
29 | printf(format: "lambda: %d %ld %p %p\n" , x[1], y[1], &x[0], &y[0]); |
30 | x[1] = y[1]; |
31 | }; |
32 | printf(format: "before: %d %ld %p %p\n" , x[1], y[1], &x[0], &y[0]); |
33 | |
34 | intptr_t xp = (intptr_t)&x[0]; |
35 | #pragma omp target firstprivate(xp) |
36 | { |
37 | lambda(); |
38 | e = x[1]; |
39 | f = &x[0]; |
40 | g = (&x[0] != (int *)xp); |
41 | printf(format: "tgt : %d %p %d\n" , x[1], &x[0], (&x[0] != (int *)xp)); |
42 | } |
43 | #pragma omp target update from(a, b, c, d, e, f, g) |
44 | printf(format: "lambda: %d %ld %p %p\n" , a, b, c, d); |
45 | printf(format: "tgt : %d %p %d\n" , e, f, g); |
46 | printf(format: "out : %d %ld %p %p\n" , x[1], y[1], &x[0], &y[0]); |
47 | |
48 | return 0; |
49 | } |
50 | |