1 // RUN: %libomptarget-compile-generic -fopenmp-version=51
2 // RUN: %libomptarget-run-generic 2>&1 \
3 // RUN: | %fcheck-generic
5 // UNSUPPORTED: amdgcn-amd-amdhsa
16 const int device_id
= omp_get_default_device();
18 A
= (float *)omp_target_alloc((FROM
+ LENGTH
) * sizeof(float), device_id
);
21 #pragma omp target has_device_addr(A[FROM : LENGTH]) map(A_dev)
24 if (A_dev
== NULL
|| A_dev
!= A
)
25 fprintf(stderr
, "Failure %p %p \n", A_dev
, A
);
27 fprintf(stderr
, "Success\n");
35 #pragma omp target data map(tofrom : xp[0 : 2]) use_device_addr(xp[0 : 2])
36 #pragma omp target has_device_addr(xp[0 : 2])
40 printf("%d %p\n", xp
[1], &xp
[1]);
43 printf("%d %p\n", xp
[1], &xp
[1]);
47 short *b
= malloc(sizeof(short));
51 #pragma omp target data map(tofrom : b[1]) use_device_addr(b[1])
52 #pragma omp target has_device_addr(b[1])
56 printf("%hd %p %p %p\n", b
[1], b
, &b
[1], &b
);
59 printf("%hd %p %p %p\n", b
[1], b
, &b
[1], &b
);
69 #pragma omp target data map(tofrom : xpp[1][1]) use_device_addr(xpp[1][1])
70 #pragma omp target has_device_addr(xpp[1][1])
74 printf("%d %p %p\n", xpp
[1][1], xpp
[1], &xpp
[1][1]);
77 printf("%d %p %p\n", xpp
[1][1], xpp
[1], &xpp
[1][1]);
83 #pragma omp target data map(to : a[0 : 2], b[0 : 2]) use_device_addr(a, b)
84 #pragma omp target has_device_addr(a) has_device_addr(b[0])
89 printf("%hd %hd %p %p %p\n", a
[1], b
[1], &a
, b
, &b
);
92 printf("%hd %hd %p %p %p\n", a
[1], b
[1], &a
, b
, &b
); // 111 111 p1d p2d p3d