| 1 | // RUN: %libomptarget-compilexx-run-and-check-generic |
| 2 | // RUN: %libomptarget-compileoptxx-run-and-check-generic |
| 3 | |
| 4 | #include <cstdio> |
| 5 | #include <omp.h> |
| 6 | |
| 7 | struct S { |
| 8 | S() : i(7) {} |
| 9 | int i; |
| 10 | }; |
| 11 | |
| 12 | S s; |
| 13 | #pragma omp declare target(s) |
| 14 | |
| 15 | int main() { |
| 16 | int r; |
| 17 | int Dev = omp_get_default_device(); |
| 18 | void *s_dev = omp_get_mapped_ptr(&s, Dev); |
| 19 | printf(format: "Host %p, Device: %p\n" , &s, s_dev); |
| 20 | omp_target_memcpy(&r, s_dev, sizeof(int), 0, offsetof(S, i), |
| 21 | omp_get_initial_device(), Dev); |
| 22 | // CHECK: 7 |
| 23 | printf(format: "%i\n" , r); |
| 24 | } |
| 25 | |