[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 07:47:03 PST 2025


================
@@ -1197,6 +1189,17 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)(void) {
   return KMP_EXPAND_NAME(FTN_GET_NUM_DEVICES)();
 }
 
+int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_DEFAULT_DEVICE)(void) {
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+  return 0;
+#else
+  // When offloading is disabled, return the initial device (host)
+  if (__kmp_target_offload == tgt_disabled)
+    return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();
----------------
amitamd7 wrote:

I see, the concern is more at the design level. Let me know if I'm wrong. Are you pointing that the `omp_set_default_device()` or the FLAG "should" be the first point of concern? and not the getter.  

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


More information about the Openmp-commits mailing list