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