| 1 | // RUN: %libomptarget-compile-generic -fopenmp-version=51 |
| 2 | // RUN: %libomptarget-run-generic | %fcheck-generic |
| 3 | // RUN: %libomptarget-compileopt-generic -fopenmp-version=51 |
| 4 | // RUN: %libomptarget-run-generic | %fcheck-generic |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | |
| 8 | int square(int x) { return x * x; } |
| 9 | #pragma omp declare target indirect to(square) |
| 10 | |
| 11 | typedef int (*fp_t)(int); |
| 12 | |
| 13 | int main() { |
| 14 | int i = 17, r; |
| 15 | |
| 16 | fp_t fp = □ |
| 17 | // CHECK: host: &square = |
| 18 | printf(format: "host: &square = %p\n" , fp); |
| 19 | |
| 20 | #pragma omp target map(from : fp) |
| 21 | fp = □ |
| 22 | // CHECK: device: &square = [[DEV_FP:.*]] |
| 23 | printf(format: "device: &square = %p\n" , fp); |
| 24 | |
| 25 | fp_t fp1 = square; |
| 26 | fp_t fp2 = 0; |
| 27 | #pragma omp target map(from : fp2) |
| 28 | fp2 = fp1; |
| 29 | // CHECK: device: fp2 = [[DEV_FP]] |
| 30 | printf(format: "device: fp2 = %p\n" , fp2); |
| 31 | |
| 32 | #pragma omp target map(from : r) |
| 33 | { r = fp1(i); } |
| 34 | |
| 35 | // CHECK: 17*17 = 289 |
| 36 | printf(format: "%i*%i = %i\n" , i, i, r); |
| 37 | } |
| 38 | |