mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 13:19:18 -08:00
When libomptarget reads/detects `OMP_TARGET_OFFLOAD=disabled`, it skips invoking `olInit()`, so subsequent calls to liboffload functions return errors in most cases. This change adds minimal tracking of liboffload to avoid such type of errors. Assisted by Claude
26 lines
621 B
C
26 lines
621 B
C
// Check that no liboffload function is invoked without liboffload being
|
|
// initialized when offloading is disabled.
|
|
|
|
// RUN: %libomptarget-compile-generic
|
|
// RUN: env OMP_TARGET_OFFLOAD=disabled %libomptarget-run-generic 2>&1 | \
|
|
// RUN: %fcheck-generic --implicit-check-not="omptarget error"
|
|
|
|
#include <omp.h>
|
|
#include <stdio.h>
|
|
|
|
int main() {
|
|
int IsHost = 0;
|
|
|
|
#pragma omp target map(from : IsHost)
|
|
IsHost = omp_is_initial_device();
|
|
|
|
// CHECK: number of devices 0
|
|
printf("number of devices %d\n", omp_get_num_devices());
|
|
// CHECK: PASS
|
|
if (IsHost) {
|
|
printf("PASS\n");
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|