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 _MSC_VER>=1600 && (!__INTEL_COMPILER || __INTEL_COMPILER>=1310) 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 ); \ 69 __TBB_MACHINE_DEFINE_ATOMICS(1,8,
char,__int8)
70 __TBB_MACHINE_DEFINE_ATOMICS(2,16,
short,__int16)
71 __TBB_MACHINE_DEFINE_ATOMICS(4,,
long,__int32)
74 __TBB_MACHINE_DEFINE_ATOMICS(8,64,__int64,__int64)
77 #undef __TBB_MACHINE_DEFINE_ATOMICS 78 #define __TBB_ATOMIC_PRIMITIVES_DEFINED 81 #if _MSC_VER>=1300 || __INTEL_COMPILER>=1100 82 #pragma intrinsic(_ReadWriteBarrier) 83 #pragma intrinsic(_mm_mfence) 84 #define __TBB_compiler_fence() _ReadWriteBarrier() 85 #define __TBB_full_memory_fence() _mm_mfence() 86 #elif __TBB_X86_MSVC_INLINE_ASM_AVAILABLE 87 #define __TBB_compiler_fence() __asm { __asm nop } 88 #define __TBB_full_memory_fence() __asm { __asm mfence } 90 #error Unsupported compiler; define __TBB_{control,acquire,release}_consistency_helper to support it 93 #define __TBB_control_consistency_helper() __TBB_compiler_fence() 94 #define __TBB_acquire_consistency_helper() __TBB_compiler_fence() 95 #define __TBB_release_consistency_helper() __TBB_compiler_fence() 97 #if (_MSC_VER>=1300) || (__INTEL_COMPILER) 98 #pragma intrinsic(_mm_pause) 99 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
100 static inline void pause (uintptr_t delay ) {
101 for (;delay>0; --delay )
105 #define __TBB_Pause(V) tbb::internal::msvc_intrinsics::pause(V) 106 #define __TBB_SINGLE_PAUSE _mm_pause() 108 #if !__TBB_X86_MSVC_INLINE_ASM_AVAILABLE 109 #error __TBB_NO_X86_MSVC_INLINE_ASM_MSG 111 namespace tbb {
namespace internal {
namespace msvc_inline_asm
112 static inline void pause (uintptr_t delay ) {
115 mov __TBB_r(ax), delay
124 #define __TBB_Pause(V) tbb::internal::msvc_inline_asm::pause(V) 125 #define __TBB_SINGLE_PAUSE __asm pause 128 #if (_MSC_VER>=1400 && !__INTEL_COMPILER) || (__INTEL_COMPILER>=1200) 131 #pragma intrinsic(__TBB_W(_BitScanReverse)) 132 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
133 static inline uintptr_t lg_bsr( uintptr_t i ){
135 __TBB_W(_BitScanReverse)( &j, i );
139 #define __TBB_Log2(V) tbb::internal::msvc_intrinsics::lg_bsr(V) 141 #if !__TBB_X86_MSVC_INLINE_ASM_AVAILABLE 142 #error __TBB_NO_X86_MSVC_INLINE_ASM_MSG 144 namespace tbb {
namespace internal {
namespace msvc_inline_asm {
145 static inline uintptr_t lg_bsr( uintptr_t i ){
155 #define __TBB_Log2(V) tbb::internal::msvc_inline_asm::lg_bsr(V) 159 #pragma intrinsic(__TBB_W(_InterlockedOr)) 160 #pragma intrinsic(__TBB_W(_InterlockedAnd)) 161 namespace tbb {
namespace internal {
namespace msvc_intrinsics {
162 static inline void lock_or(
volatile void *operand, intptr_t addend ){
163 __TBB_W(_InterlockedOr)((
volatile word*)operand, addend);
165 static inline void lock_and(
volatile void *operand, intptr_t addend ){
166 __TBB_W(_InterlockedAnd)((
volatile word*)operand, addend);
169 #define __TBB_AtomicOR(P,V) tbb::internal::msvc_intrinsics::lock_or(P,V) 170 #define __TBB_AtomicAND(P,V) tbb::internal::msvc_intrinsics::lock_and(P,V) 172 #if !__TBB_X86_MSVC_INLINE_ASM_AVAILABLE 173 #error __TBB_NO_X86_MSVC_INLINE_ASM_MSG 175 namespace tbb {
namespace internal {
namespace msvc_inline_asm {
176 static inline void lock_or(
volatile void *operand, __int32 addend ) {
184 static inline void lock_and(
volatile void *operand, __int32 addend ) {
193 #define __TBB_AtomicOR(P,V) tbb::internal::msvc_inline_asm::lock_or(P,V) 194 #define __TBB_AtomicAND(P,V) tbb::internal::msvc_inline_asm::lock_and(P,V) 197 #pragma intrinsic(__rdtsc) 198 namespace tbb {
namespace internal {
typedef uint64_t machine_tsc_t; } }
199 static inline tbb::internal::machine_tsc_t __TBB_machine_time_stamp() {
202 #define __TBB_time_stamp() __TBB_machine_time_stamp() 205 #define __TBB_CPU_CTL_ENV_PRESENT 1 207 namespace tbb {
namespace internal {
class cpu_ctl_env; } }
208 #if __TBB_X86_MSVC_INLINE_ASM_AVAILABLE 211 __asm mov __TBB_r(ax), ctl
212 __asm stmxcsr [__TBB_r(ax)]
213 __asm fstcw [__TBB_r(ax)+4]
218 __asm mov __TBB_r(ax), ctl
219 __asm ldmxcsr [__TBB_r(ax)]
220 __asm fldcw [__TBB_r(ax)+4]
236 static const int MXCSR_CONTROL_MASK = ~0x3f;
238 bool operator!=(
const cpu_ctl_env& ctl )
const {
return mxcsr != ctl.mxcsr || x87cw != ctl.x87cw; }
240 __TBB_get_cpu_ctl_env(
this );
241 mxcsr &= MXCSR_CONTROL_MASK;
243 void set_env()
const { __TBB_set_cpu_ctl_env(
this ); }
248 #if !__TBB_WIN8UI_SUPPORT 249 extern "C" __declspec(dllimport) int __stdcall SwitchToThread(
void );
250 #define __TBB_Yield() SwitchToThread() 253 #define __TBB_Yield() std::this_thread::yield() 261 __int8 __TBB_EXPORTED_FUNC __TBB_machine_try_lock_elided (
volatile void* ptr);
262 void __TBB_EXPORTED_FUNC __TBB_machine_unlock_elided (
volatile void* ptr);
265 inline static void __TBB_machine_try_lock_elided_cancel() { __TBB_SINGLE_PAUSE; }
267 #if __TBB_TSX_INTRINSICS_PRESENT 268 #define __TBB_machine_is_in_transaction _xtest 269 #define __TBB_machine_begin_transaction _xbegin 270 #define __TBB_machine_end_transaction _xend 273 #define __TBB_machine_transaction_conflict_abort() _xabort(0xFF) 275 __int8 __TBB_EXPORTED_FUNC __TBB_machine_is_in_transaction();
276 unsigned __int32 __TBB_EXPORTED_FUNC __TBB_machine_begin_transaction();
277 void __TBB_EXPORTED_FUNC __TBB_machine_end_transaction();
278 void __TBB_EXPORTED_FUNC __TBB_machine_transaction_conflict_abort();
Definition: _flow_graph_async_msg_impl.h:32
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
Definition: gcc_ia32_common.h:73