21 #if !defined(__TBB_machine_H) || defined(__TBB_machine_msvc_ia32_common_H) 22 #error Do not #include this internal file directly; use public TBB headers instead. 25 #define __TBB_machine_msvc_ia32_common_H 30 #if !_M_X64 || __INTEL_COMPILER 31 #define __TBB_X86_MSVC_INLINE_ASM_AVAILABLE 1 34 #define __TBB_X86_MSVC_INLINE_ASM_AVAILABLE 0 35 #define __TBB_NO_X86_MSVC_INLINE_ASM_MSG "The compiler being used is not supported (outdated?)" 39 #define __TBB_r(reg_name) r##reg_name 40 #define __TBB_W(name) name##64 41 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
45 #define __TBB_r(reg_name) e##reg_name 46 #define __TBB_W(name) name 47 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
52 #if __TBB_MSVC_PART_WORD_INTERLOCKED_INTRINSICS_PRESENT 54 #define __TBB_MACHINE_DEFINE_ATOMICS(S,B,T,U) \ 55 __pragma(intrinsic( _InterlockedCompareExchange##B )) \ 56 static inline T __TBB_machine_cmpswp##S ( volatile void * ptr, U value, U comparand ) { \ 57 return _InterlockedCompareExchange##B ( (T*)ptr, value, comparand ); \ 59 __pragma(intrinsic( _InterlockedExchangeAdd##B )) \ 60 static inline T __TBB_machine_fetchadd##S ( volatile void * ptr, U addend ) { \ 61 return _InterlockedExchangeAdd##B ( (T*)ptr, addend ); \ 63 __pragma(intrinsic( _InterlockedExchange##B )) \ 64 static inline T __TBB_machine_fetchstore##S ( volatile void * ptr, U value ) { \ 65 return _InterlockedExchange##B ( (T*)ptr, value ); \ 77 #undef __TBB_MACHINE_DEFINE_ATOMICS 80 #if _MSC_VER>=1300 || __INTEL_COMPILER>=1100 81 #pragma intrinsic(_ReadWriteBarrier) 82 #pragma intrinsic(_mm_mfence) 83 #define __TBB_compiler_fence() _ReadWriteBarrier() 84 #define __TBB_full_memory_fence() _mm_mfence() 85 #elif __TBB_X86_MSVC_INLINE_ASM_AVAILABLE 86 #define __TBB_compiler_fence() __asm { __asm nop } 87 #define __TBB_full_memory_fence() __asm { __asm mfence } 89 #error Unsupported compiler; define __TBB_{control,acquire,release}_consistency_helper to support it 92 #define __TBB_control_consistency_helper() __TBB_compiler_fence() 93 #define __TBB_acquire_consistency_helper() __TBB_compiler_fence() 94 #define __TBB_release_consistency_helper() __TBB_compiler_fence() 96 #if (_MSC_VER>=1300) || (__INTEL_COMPILER) 97 #pragma intrinsic(_mm_pause) 98 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
99 static inline void pause (uintptr_t delay ) {
100 for (;delay>0; --delay )
104 #define __TBB_Pause(V) tbb::internal::msvc_intrinsics::pause(V) 105 #define __TBB_SINGLE_PAUSE _mm_pause() 107 #if !__TBB_X86_MSVC_INLINE_ASM_AVAILABLE 108 #error __TBB_NO_X86_MSVC_INLINE_ASM_MSG 110 namespace tbb {
namespace internal {
namespace msvc_inline_asm
123 #define __TBB_Pause(V) tbb::internal::msvc_inline_asm::pause(V) 124 #define __TBB_SINGLE_PAUSE __asm pause 127 #if (_MSC_VER>=1400 && !__INTEL_COMPILER) || (__INTEL_COMPILER>=1200) 130 #pragma intrinsic(__TBB_W(_BitScanReverse)) 131 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
132 static inline uintptr_t
lg_bsr( uintptr_t i ){
134 __TBB_W(_BitScanReverse)( &j, i );
138 #define __TBB_Log2(V) tbb::internal::msvc_intrinsics::lg_bsr(V) 140 #if !__TBB_X86_MSVC_INLINE_ASM_AVAILABLE 141 #error __TBB_NO_X86_MSVC_INLINE_ASM_MSG 143 namespace tbb {
namespace internal {
namespace msvc_inline_asm {
144 static inline uintptr_t
lg_bsr( uintptr_t i ){
154 #define __TBB_Log2(V) tbb::internal::msvc_inline_asm::lg_bsr(V) 158 #pragma intrinsic(__TBB_W(_InterlockedOr)) 159 #pragma intrinsic(__TBB_W(_InterlockedAnd)) 160 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
161 static inline void lock_or(
volatile void *operand, intptr_t addend ){
162 __TBB_W(_InterlockedOr)((
volatile word*)operand, addend);
164 static inline void lock_and(
volatile void *operand, intptr_t addend ){
165 __TBB_W(_InterlockedAnd)((
volatile word*)operand, addend);
168 #define __TBB_AtomicOR(P,V) tbb::internal::msvc_intrinsics::lock_or(P,V) 169 #define __TBB_AtomicAND(P,V) tbb::internal::msvc_intrinsics::lock_and(P,V) 171 #if !__TBB_X86_MSVC_INLINE_ASM_AVAILABLE 172 #error __TBB_NO_X86_MSVC_INLINE_ASM_MSG 174 namespace tbb {
namespace internal {
namespace msvc_inline_asm {
175 static inline void lock_or(
volatile void *operand, __int32 addend ) {
183 static inline void lock_and(
volatile void *operand, __int32 addend ) {
192 #define __TBB_AtomicOR(P,V) tbb::internal::msvc_inline_asm::lock_or(P,V) 193 #define __TBB_AtomicAND(P,V) tbb::internal::msvc_inline_asm::lock_and(P,V) 196 #pragma intrinsic(__rdtsc) 201 #define __TBB_time_stamp() __TBB_machine_time_stamp() 204 #define __TBB_CPU_CTL_ENV_PRESENT 1 206 namespace tbb {
namespace internal {
class cpu_ctl_env; } }
207 #if __TBB_X86_MSVC_INLINE_ASM_AVAILABLE 247 #if !__TBB_WIN8UI_SUPPORT 248 extern "C" __declspec(dllimport)
int __stdcall SwitchToThread(
void );
249 #define __TBB_Yield() SwitchToThread() 252 #define __TBB_Yield() std::this_thread::yield() 266 #if __TBB_TSX_INTRINSICS_PRESENT 267 #define __TBB_machine_is_in_transaction _xtest 268 #define __TBB_machine_begin_transaction _xbegin 269 #define __TBB_machine_end_transaction _xend 272 #define __TBB_machine_transaction_conflict_abort() _xabort(0xFF) __int8 __TBB_EXPORTED_FUNC __TBB_machine_is_in_transaction()
static const int MXCSR_CONTROL_MASK
static void lock_or(volatile void *operand, __int32 addend)
static void __TBB_machine_try_lock_elided_cancel()
static uintptr_t lg_bsr(uintptr_t i)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
void __TBB_EXPORTED_FUNC __TBB_machine_end_transaction()
void __TBB_EXPORTED_FUNC __TBB_machine_unlock_elided(volatile void *ptr)
bool operator!=(const cpu_ctl_env &ctl) const
__declspec(dllimport) int __stdcall SwitchToThread(void)
namespace msvc_inline_asm static inline void pause(uintptr_t delay)
#define __TBB_EXPORTED_FUNC
#define __TBB_r(reg_name)
unsigned __int32 __TBB_EXPORTED_FUNC __TBB_machine_begin_transaction()
void __TBB_set_cpu_ctl_env(const tbb::internal::cpu_ctl_env *ctl)
void __TBB_get_cpu_ctl_env(tbb::internal::cpu_ctl_env *ctl)
static tbb::internal::machine_tsc_t __TBB_machine_time_stamp()
#define __TBB_MACHINE_DEFINE_ATOMICS(S, T)
void __TBB_EXPORTED_FUNC __TBB_machine_transaction_conflict_abort()
__int8 __TBB_EXPORTED_FUNC __TBB_machine_try_lock_elided(volatile void *ptr)
static void lock_and(volatile void *operand, __int32 addend)
#define __TBB_SINGLE_PAUSE