xref: /llvm-project/offload/test/offloading/offloading_success.cpp (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compilexx-run-and-check-generic
2 
3 #include <omp.h>
4 #include <stdio.h>
5 
main(void)6 int main(void) {
7   int isHost = 0;
8 
9 #pragma omp target map(from : isHost)
10   { isHost = omp_is_initial_device(); }
11 
12   if (isHost < 0) {
13     printf("Runtime error, isHost=%d\n", isHost);
14   }
15 
16   // CHECK: Target region executed on the device
17   printf("Target region executed on the %s\n", isHost ? "host" : "device");
18 
19   return isHost;
20 }
21