[Openmp-commits] [llvm] [openmp] [OpenMP][Runtime] Handling crash with `OMP_TARGET_OFFLOAD=DISABLED` and invoking `omp_get_default_device()` (PR #171789)
Amit Tiwari via Openmp-commits
openmp-commits at lists.llvm.org
Thu Dec 18 05:40:32 PST 2025
================
@@ -0,0 +1,89 @@
+// RUN: %libomp-compile-and-run
+// REQUIRES: ompt
+//
+// Test that device operations using omp_get_default_device() don't crash
+// when OMP_TARGET_OFFLOAD=DISABLED. This simulates real-world usage where
+// the default device is used for device-specific operations.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <omp.h>
+
+extern void kmp_set_defaults(char const *str);
+
+int main() {
+ // Simulate the problematic scenario: high default device number + disabled
+ // offload Use API call instead of env var to ensure ICV is set
+ omp_set_default_device(10);
----------------
amitamd7 wrote:
Yes, you are right. It is making subsequent kmp_set_defaults() calls ineffective. I have fixed this.
https://github.com/llvm/llvm-project/pull/171789
More information about the Openmp-commits
mailing list