| 1 | // RUN: %libomptarget-compile-run-and-check-x86_64-unknown-linux-gnu |
| 2 | // RUN: %libomptarget-compile-x86_64-unknown-linux-gnu -DUNUSED -Wall -Werror |
| 3 | |
| 4 | // only run for x86_64 host offloading: |
| 5 | // REQUIRES: x86_64-unknown-linux-gnu |
| 6 | |
| 7 | #include <omp.h> |
| 8 | #include <stdio.h> |
| 9 | |
| 10 | int main() { |
| 11 | int errors = 0; |
| 12 | #ifdef UNUSED |
| 13 | // Test if it is OK to leave the variants unused in the header |
| 14 | #else // UNUSED |
| 15 | int host = omp_is_initial_device(); |
| 16 | int device = 1; |
| 17 | #pragma omp target map(tofrom : device) |
| 18 | { device = omp_is_initial_device(); } |
| 19 | if (!host) { |
| 20 | printf(format: "omp_is_initial_device() returned false on host\n" ); |
| 21 | errors++; |
| 22 | } |
| 23 | if (device) { |
| 24 | printf(format: "omp_is_initial_device() returned true on device\n" ); |
| 25 | errors++; |
| 26 | } |
| 27 | #endif // UNUSED |
| 28 | |
| 29 | // CHECK: PASS |
| 30 | printf(format: "%s\n" , errors ? "FAIL" : "PASS" ); |
| 31 | |
| 32 | return errors; |
| 33 | } |
| 34 | |