[Instrumentation] Fix a warning
[llvm-project.git] / offload / test / offloading / indirect_fp_mapping.c
bloba400349c4114eb9cec8f2d131004cd31ba0805c7
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
6 #include <stdio.h>
8 int square(int x) { return x * x; }
9 #pragma omp declare target indirect to(square)
11 typedef int (*fp_t)(int);
13 int main() {
14 int i = 17, r;
16 fp_t fp = &square;
17 // CHECK: host: &square =
18 printf("host: &square = %p\n", fp);
20 #pragma omp target map(from : fp)
21 fp = &square;
22 // CHECK: device: &square = [[DEV_FP:.*]]
23 printf("device: &square = %p\n", fp);
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("device: fp2 = %p\n", fp2);
32 #pragma omp target map(from : r)
33 { r = fp1(i); }
35 // CHECK: 17*17 = 289
36 printf("%i*%i = %i\n", i, i, r);