1 // RUN: %libomptarget-compile-run-and-check-generic
2 
3 #include <stdio.h>
4 #include <omp.h>
5 
6 int test_omp_get_device_num()
7 {
8   /* checks that omp_get_device_num() == omp_get_num_devices() in the host */
9   int device_num = omp_get_device_num();
10   printf("device_num = %d\n", device_num);
11 
12   #pragma omp target
13   {}
14 
15   return (device_num == omp_get_num_devices());
16 }
17 
18 int main()
19 {
20   int i;
21   int failed=0;
22 
23   if (!test_omp_get_device_num()) {
24     failed++;
25   }
26   if (failed)
27     printf("FAIL\n");
28   else
29     printf("PASS\n");
30   return failed;
31 }
32 
33 // CHECK: PASS
34