1 // RUN: %libomptarget-compile-run-and-check-generic
6 #pragma omp begin declare variant match(device = {kind(gpu)})
7 // Provided by the runtime.
8 void *__llvm_omp_indirect_call_lookup(void *host_ptr
);
9 #pragma omp declare target to(__llvm_omp_indirect_call_lookup) \
11 #pragma omp end declare variant
13 #pragma omp begin declare variant match(device = {kind(cpu)})
14 // We assume unified addressing on the CPU target.
15 void *__llvm_omp_indirect_call_lookup(void *host_ptr
) { return host_ptr
; }
16 #pragma omp end declare variant
18 #pragma omp begin declare target indirect
19 void foo(int *x
) { *x
= *x
+ 1; }
20 void bar(int *x
) { *x
= *x
+ 1; }
21 void baz(int *x
) { *x
= *x
+ 1; }
22 #pragma omp end declare target
33 #pragma omp target map(to : foo_ptr, bar_ptr, baz_ptr) map(tofrom : count)
35 foo_res
= __llvm_omp_indirect_call_lookup(foo_ptr
);
36 ((void (*)(int *))foo_res
)(&count
);
37 bar_res
= __llvm_omp_indirect_call_lookup(bar_ptr
);
38 ((void (*)(int *))bar_res
)(&count
);
39 baz_res
= __llvm_omp_indirect_call_lookup(baz_ptr
);
40 ((void (*)(int *))baz_res
)(&count
);
43 assert(count
== 3 && "Calling failed");