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