1 // RUN: %libomptarget-compile-run-and-check-generic
2 
3 #include <stdio.h>
4 #include <omp.h>
5 
6 #pragma omp declare target
7 int isHost;
8 #pragma omp end declare target
9 
main(void)10 int main(void) {
11   isHost = -1;
12 
13 #pragma omp target enter data map(to: isHost)
14 
15 #pragma omp target
16   { isHost = omp_is_initial_device(); }
17 #pragma omp target update from(isHost)
18 
19   if (isHost < 0) {
20     printf("Runtime error, isHost=%d\n", isHost);
21   }
22 
23 #pragma omp target exit data map(delete: isHost)
24 
25   // CHECK: Target region executed on the device
26   printf("Target region executed on the %s\n", isHost ? "host" : "device");
27 
28   return isHost;
29 }
30