llvm-project/offload/test/api/is_initial_device.c
Jan Patrick Lehr 1a0cf245ac
[Offload] Change x86_64-pc-linux to x86_64-unknown-linux (#107023)
It appears that the RUNTIMES build prefers the x86-64-unknown-linux-gnu
triple notation for the host. This fixes runtime / test breakages when
compiler-rt is used as the CLANG_DEFAULT_RTLIB.
2024-09-03 14:25:33 +02:00

34 lines
819 B
C

// RUN: %libomptarget-compile-run-and-check-x86_64-unknown-linux-gnu
// RUN: %libomptarget-compile-x86_64-unknown-linux-gnu -DUNUSED -Wall -Werror
// only run for x86_64 host offloading:
// REQUIRES: x86_64-unknown-linux-gnu
#include <omp.h>
#include <stdio.h>
int main() {
int errors = 0;
#ifdef UNUSED
// Test if it is OK to leave the variants unused in the header
#else // UNUSED
int host = omp_is_initial_device();
int device = 1;
#pragma omp target map(tofrom : device)
{ device = omp_is_initial_device(); }
if (!host) {
printf("omp_is_initial_device() returned false on host\n");
errors++;
}
if (device) {
printf("omp_is_initial_device() returned true on device\n");
errors++;
}
#endif // UNUSED
// CHECK: PASS
printf("%s\n", errors ? "FAIL" : "PASS");
return errors;
}