diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -1206,6 +1206,12 @@ kmp_uint32 edx; } kmp_cpuid_t; +typedef struct kmp_cpuinfo_flags_t { + unsigned sse2 : 1; // 0 if SSE2 instructions are not supported, 1 otherwise. + unsigned rtm : 1; // 0 if RTM instructions are not supported, 1 otherwise. + unsigned reserved : 30; // Ensure size of 32 bits +} kmp_cpuinfo_flags_t; + typedef struct kmp_cpuinfo { int initialized; // If 0, other fields are not initialized. int signature; // CPUID(1).EAX @@ -1213,8 +1219,7 @@ int model; // ( CPUID(1).EAX[19:16] << 4 ) + CPUID(1).EAX[7:4] ( ( Extended // Model << 4 ) + Model) int stepping; // CPUID(1).EAX[3:0] ( Stepping ) - int sse2; // 0 if SSE2 instructions are not supported, 1 otherwise. - int rtm; // 0 if RTM instructions are not supported, 1 otherwise. + kmp_cpuinfo_flags_t flags; int apic_id; int physical_id; int logical_id; diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -683,7 +683,7 @@ if (!__kmp_cpuinfo.initialized) { __kmp_query_cpuid(&__kmp_cpuinfo); } - if (!__kmp_cpuinfo.sse2) { + if (!__kmp_cpuinfo.flags.sse2) { // CPU cannot execute SSE2 instructions. } else { #if KMP_COMPILER_ICC @@ -1356,7 +1356,7 @@ #endif #if KMP_ARCH_X86 || KMP_ARCH_X86_64 -#define KMP_CPUINFO_RTM (__kmp_cpuinfo.rtm) +#define KMP_CPUINFO_RTM (__kmp_cpuinfo.flags.rtm) #else #define KMP_CPUINFO_RTM 0 #endif diff --git a/openmp/runtime/src/kmp_lock.cpp b/openmp/runtime/src/kmp_lock.cpp --- a/openmp/runtime/src/kmp_lock.cpp +++ b/openmp/runtime/src/kmp_lock.cpp @@ -3202,13 +3202,13 @@ static void __kmp_init_indirect_lock(kmp_dyna_lock_t *lock, kmp_dyna_lockseq_t seq) { #if KMP_USE_ADAPTIVE_LOCKS - if (seq == lockseq_adaptive && !__kmp_cpuinfo.rtm) { + if (seq == lockseq_adaptive && !__kmp_cpuinfo.flags.rtm) { KMP_WARNING(AdaptiveNotSupported, "kmp_lockseq_t", "adaptive"); seq = lockseq_queuing; } #endif #if KMP_USE_TSX - if (seq == lockseq_rtm_queuing && !__kmp_cpuinfo.rtm) { + if (seq == lockseq_rtm_queuing && !__kmp_cpuinfo.flags.rtm) { seq = lockseq_queuing; } #endif diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h --- a/openmp/runtime/src/kmp_os.h +++ b/openmp/runtime/src/kmp_os.h @@ -1040,7 +1040,7 @@ if (UNLIKELY(!__kmp_cpuinfo.initialized)) { \ __kmp_query_cpuid(&__kmp_cpuinfo); \ } \ - if (__kmp_cpuinfo.sse2) { \ + if (__kmp_cpuinfo.flags.sse2) { \ KMP_MFENCE_(); \ } #define KMP_SFENCE() KMP_SFENCE_() diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp --- a/openmp/runtime/src/kmp_settings.cpp +++ b/openmp/runtime/src/kmp_settings.cpp @@ -4467,7 +4467,7 @@ } #if KMP_USE_ADAPTIVE_LOCKS else if (__kmp_str_match("adaptive", 1, value)) { - if (__kmp_cpuinfo.rtm) { // ??? Is cpuinfo available here? + if (__kmp_cpuinfo.flags.rtm) { // ??? Is cpuinfo available here? __kmp_user_lock_kind = lk_adaptive; KMP_STORE_LOCK_SEQ(adaptive); } else { @@ -4479,7 +4479,7 @@ #endif // KMP_USE_ADAPTIVE_LOCKS #if KMP_USE_DYNAMIC_LOCK && KMP_USE_TSX else if (__kmp_str_match("rtm_queuing", 1, value)) { - if (__kmp_cpuinfo.rtm) { + if (__kmp_cpuinfo.flags.rtm) { __kmp_user_lock_kind = lk_rtm_queuing; KMP_STORE_LOCK_SEQ(rtm_queuing); } else { @@ -4488,7 +4488,7 @@ KMP_STORE_LOCK_SEQ(queuing); } } else if (__kmp_str_match("rtm_spin", 1, value)) { - if (__kmp_cpuinfo.rtm) { + if (__kmp_cpuinfo.flags.rtm) { __kmp_user_lock_kind = lk_rtm_spin; KMP_STORE_LOCK_SEQ(rtm_spin); } else { diff --git a/openmp/runtime/src/kmp_utility.cpp b/openmp/runtime/src/kmp_utility.cpp --- a/openmp/runtime/src/kmp_utility.cpp +++ b/openmp/runtime/src/kmp_utility.cpp @@ -129,7 +129,7 @@ p->initialized = 1; - p->sse2 = 1; // Assume SSE2 by default. + p->flags.sse2 = 1; // Assume SSE2 by default. __kmp_x86_cpuid(0, 0, &buf); @@ -169,7 +169,7 @@ data[i] = (t & 0xff); } - p->sse2 = (buf.edx >> 26) & 1; + p->flags.sse2 = (buf.edx >> 26) & 1; #ifdef KMP_DEBUG @@ -248,11 +248,11 @@ } #endif #if KMP_USE_ADAPTIVE_LOCKS - p->rtm = 0; + p->flags.rtm = 0; if (max_arg > 7) { /* RTM bit CPUID.07:EBX, bit 11 */ __kmp_x86_cpuid(7, 0, &buf); - p->rtm = (buf.ebx >> 11) & 1; + p->flags.rtm = (buf.ebx >> 11) & 1; KA_TRACE(trace_level, (" RTM")); } #endif