[llvm] [openmp] [OpenMP][Runtime] Handling crash with `OMP_TARGET_OFFLOAD=DISABLED` and invoking `omp_get_default_device()` (PR #171789)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 07:13:15 PST 2025


================
@@ -0,0 +1,45 @@
+// RUN: %libomptarget-compile-generic
+// RUN: env OMP_TARGET_OFFLOAD=disabled %libomptarget-run-generic 2>&1 |
+// %fcheck-generic
+//
+// Test that setting default device before disabling offload doesn't crash
+
+#include <omp.h>
+#include <stdio.h>
+
+int main() {
+  // Set high default device number
+  omp_set_default_device(5);
+
+  // This simulates OMP_TARGET_OFFLOAD=disabled being set after device is chosen
+  // In practice, the environment variable is read at runtime init
----------------
jprotze wrote:

How is this simulated here?

https://github.com/llvm/llvm-project/pull/171789


More information about the llvm-commits mailing list