34 lines · c
1// RUN: %libomptarget-compile-run-and-check-x86_64-unknown-linux-gnu2// RUN: %libomptarget-compile-x86_64-unknown-linux-gnu -DUNUSED -Wall -Werror3 4// only run for x86_64 host offloading:5// REQUIRES: x86_64-unknown-linux-gnu6 7#include <omp.h>8#include <stdio.h>9 10int main() {11 int errors = 0;12#ifdef UNUSED13// Test if it is OK to leave the variants unused in the header14#else // UNUSED15 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("omp_is_initial_device() returned false on host\n");21 errors++;22 }23 if (device) {24 printf("omp_is_initial_device() returned true on device\n");25 errors++;26 }27#endif // UNUSED28 29 // CHECK: PASS30 printf("%s\n", errors ? "FAIL" : "PASS");31 32 return errors;33}34