1 | // RUN: %libomptarget-compile-run-and-check-generic |
2 | |
3 | #include <stdio.h> |
4 | |
5 | typedef struct { |
6 | double *dataptr; |
7 | int dummy1; |
8 | int dummy2; |
9 | } DV; |
10 | |
11 | void init(double vertexx[]) { |
12 | #pragma omp target map(vertexx[0 : 100]) |
13 | { |
14 | printf(format: "In init: %lf, expected 100.0\n" , vertexx[77]); |
15 | vertexx[77] = 77.0; |
16 | } |
17 | } |
18 | |
19 | void change(DV *dvptr) { |
20 | #pragma omp target map(dvptr->dataptr[0 : 100]) |
21 | { |
22 | printf(format: "In change: %lf, expected 77.0\n" , dvptr->dataptr[77]); |
23 | dvptr->dataptr[77] += 1.0; |
24 | } |
25 | } |
26 | |
27 | int main() { |
28 | double vertexx[100]; |
29 | vertexx[77] = 100.0; |
30 | |
31 | DV dv; |
32 | dv.dataptr = &vertexx[0]; |
33 | |
34 | #pragma omp target enter data map(to : vertexx[0 : 100]) |
35 | |
36 | init(vertexx); |
37 | change(dvptr: &dv); |
38 | |
39 | #pragma omp target exit data map(from : vertexx[0 : 100]) |
40 | |
41 | // CHECK: Final: 78.0 |
42 | printf(format: "Final: %lf\n" , vertexx[77]); |
43 | } |
44 | |