[llvm] [openmp] [OpenMP][Runtime] Handling crash with OMP_TARGET_OFFLOAD=DISABLED and invalid default device (PR #173630)
Julian Brown via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 29 06:25:13 PST 2025
================
@@ -3295,30 +3295,43 @@ static kmp_internal_control_t __kmp_get_global_icvs(void) {
KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.used > 0);
+ // When offload is disabled, default_device should be the initial device
+ // regardless of OMP_DEFAULT_DEVICE environment variable or explicit set
+ int default_device_icv = __kmp_default_device;
+ if (__kmp_target_offload == tgt_disabled) {
+ // Initial device is same as num_devices when offload is disabled
+ int (*fptr)();
+ if ((*(void **)(&fptr) = KMP_DLSYM("__tgt_get_num_devices"))) {
+ default_device_icv = (*fptr)();
+ } else {
+ default_device_icv = 0;
+ }
+ }
+
kmp_internal_control_t g_icvs = {
- 0, // int serial_nesting_level; //corresponds to value of th_team_serialized
- (kmp_int8)__kmp_global.g.g_dynamic, // internal control for dynamic
- // adjustment of threads (per thread)
- (kmp_int8)__kmp_env_blocktime, // int bt_set; //internal control for
- // whether blocktime is explicitly set
- __kmp_dflt_blocktime, // int blocktime; //internal control for blocktime
+ 0, // int serial_nesting_level; //corresponds to value of
+ // th_team_serialized
+ (kmp_int8)__kmp_global.g.g_dynamic, // internal control for dynamic
+ // adjustment of threads (per thread)
+ (kmp_int8)__kmp_env_blocktime, // int bt_set; //internal control for
+ // whether blocktime is explicitly set
+ __kmp_dflt_blocktime, // int blocktime; //internal control for blocktime
#if KMP_USE_MONITOR
- __kmp_bt_intervals, // int bt_intervals; //internal control for blocktime
+ __kmp_bt_intervals, // int bt_intervals; //internal control for blocktime
----------------
jtb20 wrote:
Same here...
https://github.com/llvm/llvm-project/pull/173630
More information about the llvm-commits
mailing list