llvm-project/openmp/libomptarget/test/api/is_initial_device.c
Joachim Protze 24f836e8fd [OpenMP][libomptarget] Separate lit tests for different offloading targets (2/2)
This patch fuses the RUN lines for most libomptarget tests. The previous patch
D101315 created separate test targets for each supported offloading triple.

This patch updates the RUN lines in libomptarget tests to use a generic run
line independent of the offloading target selected for the lit instance.

In cases, where no RUN line was defined for a specific offloading target,
the corresponding target is declared as XFAIL. If it turns out that a test
actually supports the target, the XFAIL line can be removed.

Differential Revision: https://reviews.llvm.org/D101326
2021-04-27 15:54:32 +02:00

34 lines
804 B
C

// RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu
// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -DUNUSED -Wall -Werror
// only run for x86_64 host offloading:
// REQUIRES: x86_64-pc-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;
}