21 #if !defined(__TBB_machine_H) || defined(__TBB_machine_gcc_power_H) 22 #error Do not #include this internal file directly; use public TBB headers instead. 25 #define __TBB_machine_gcc_power_H 34 #if __powerpc64__ || __ppc64__ 37 #define __TBB_WORDSIZE 8 39 #define __TBB_WORDSIZE 4 46 #if __BIG_ENDIAN__ || (defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__) 47 #define __TBB_ENDIANNESS __TBB_ENDIAN_BIG 48 #elif __LITTLE_ENDIAN__ || (defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) 49 #define __TBB_ENDIANNESS __TBB_ENDIAN_LITTLE 50 #elif defined(__BYTE_ORDER__) 51 #define __TBB_ENDIANNESS __TBB_ENDIAN_UNSUPPORTED 53 #define __TBB_ENDIANNESS __TBB_ENDIAN_DETECT 59 #define __TBB_64BIT_ATOMICS 1 62 #define __TBB_64BIT_ATOMICS 0 72 #ifndef __TBB_64BIT_ATOMICS 73 #define __TBB_64BIT_ATOMICS 0 77 inline int32_t __TBB_machine_cmpswp4 (
volatile void *ptr, int32_t value, int32_t comparand )
81 __asm__ __volatile__(
"sync\n" 83 "lwarx %[res],0,%[ptr]\n\t" 84 "cmpw %[res],%[cmp]\n\t" 86 "stwcx. %[val],0,%[ptr]\n\t" 91 ,
"+m"(* (int32_t*) ptr)
101 #if __TBB_WORDSIZE==8 103 inline int64_t __TBB_machine_cmpswp8 (
volatile void *ptr, int64_t value, int64_t comparand )
106 __asm__ __volatile__(
"sync\n" 108 "ldarx %[res],0,%[ptr]\n\t" 109 "cmpd %[res],%[cmp]\n\t" 111 "stdcx. %[val],0,%[ptr]\n\t" 116 ,
"+m"(* (int64_t*) ptr)
119 , [cmp]
"r"(comparand)
126 #elif __TBB_64BIT_ATOMICS 128 inline int64_t __TBB_machine_cmpswp8 (
volatile void *ptr, int64_t value, int64_t comparand )
131 int64_t value_register, comparand_register, result_register;
132 __asm__ __volatile__(
"sync\n\t" 133 "ld %[val],%[valm]\n\t" 134 "ld %[cmp],%[cmpm]\n" 136 "ldarx %[res],0,%[ptr]\n\t" 137 "cmpd %[res],%[cmp]\n\t" 139 "stdcx. %[val],0,%[ptr]\n\t" 142 "std %[res],%[resm]\n\t" 145 , [res]
"=&r"( result_register)
146 , [val]
"=&r"( value_register)
147 , [cmp]
"=&r"(comparand_register)
148 ,
"+m"(* (int64_t*) ptr)
151 , [cmpm]
"m"(comparand)
160 #define __TBB_MACHINE_DEFINE_LOAD_STORE(S,ldx,stx,cmpx) \ 161 template <typename T> \ 162 struct machine_load_store<T,S> { \ 163 static inline T load_with_acquire(const volatile T& location) { \ 165 __asm__ __volatile__(ldx " %[res],0(%[ptr])\n" \ 167 cmpx " %[res],%[res]\n\t" \ 170 : [res]"=r"(result) \ 171 : [ptr]"b"(&location) \ 177 static inline void store_with_release(volatile T &location, T value) { \ 178 __asm__ __volatile__("lwsync\n\t" \ 179 stx " %[val],0(%[ptr])" \ 181 : [ptr]"b"(&location) \ 187 template <typename T> \ 188 struct machine_load_store_relaxed<T,S> { \ 189 static inline T load (const __TBB_atomic T& location) { \ 191 __asm__ __volatile__(ldx " %[res],0(%[ptr])" \ 192 : [res]"=r"(result) \ 193 : [ptr]"b"(&location) \ 198 static inline void store (__TBB_atomic T &location, T value) { \ 199 __asm__ __volatile__(stx " %[val],0(%[ptr])" \ 201 : [ptr]"b"(&location) \ 209 __TBB_MACHINE_DEFINE_LOAD_STORE(1,
"lbz",
"stb",
"cmpw")
210 __TBB_MACHINE_DEFINE_LOAD_STORE(2,"lhz","sth","cmpw")
211 __TBB_MACHINE_DEFINE_LOAD_STORE(4,"lwz","stw","cmpw")
213 #if __TBB_WORDSIZE==8 215 __TBB_MACHINE_DEFINE_LOAD_STORE(8,
"ld" ,
"std",
"cmpd")
217 #elif __TBB_64BIT_ATOMICS 219 template <
typename T>
220 struct machine_load_store<T,8> {
221 static inline T load_with_acquire(
const volatile T& location) {
224 __asm__ __volatile__(
"ld %[res],0(%[ptr])\n\t" 225 "std %[res],%[resm]\n" 227 "cmpd %[res],%[res]\n\t" 231 , [res]
"=&r"(result_register)
232 : [ptr]
"b"(&location)
239 static inline void store_with_release(
volatile T &location, T value) {
241 __asm__ __volatile__(
"lwsync\n\t" 242 "ld %[val],%[valm]\n\t" 243 "std %[val],0(%[ptr])" 245 , [val]
"=&r"(value_register)
246 : [ptr]
"b"(&location)
252 struct machine_load_store_relaxed<T,8> {
253 static inline T load (
const volatile T& location) {
256 __asm__ __volatile__(
"ld %[res],0(%[ptr])\n\t" 259 , [res]
"=&r"(result_register)
260 : [ptr]
"b"(&location)
266 static inline void store (
volatile T &location, T value) {
268 __asm__ __volatile__(
"ld %[val],%[valm]\n\t" 269 "std %[val],0(%[ptr])" 271 , [val]
"=&r"(value_register)
272 : [ptr]
"b"(&location)
277 #define __TBB_machine_load_store_relaxed_8 283 #undef __TBB_MACHINE_DEFINE_LOAD_STORE 285 #define __TBB_USE_GENERIC_PART_WORD_CAS 1 286 #define __TBB_USE_GENERIC_FETCH_ADD 1 287 #define __TBB_USE_GENERIC_FETCH_STORE 1 288 #define __TBB_USE_GENERIC_SEQUENTIAL_CONSISTENCY_LOAD_STORE 1 290 #define __TBB_control_consistency_helper() __asm__ __volatile__("isync": : :"memory") 291 #define __TBB_full_memory_fence() __asm__ __volatile__( "sync": : :"memory") 293 static inline intptr_t __TBB_machine_lg( uintptr_t x ) {
294 __TBB_ASSERT(x,
"__TBB_Log2(0) undefined");
296 #if __TBB_WORDSIZE==8 297 __asm__ __volatile__ (
"cntlzd %0,%0" :
"+r"(x));
298 return 63-
static_cast<intptr_t
>(x);
300 __asm__ __volatile__ (
"cntlzw %0,%0" :
"+r"(x));
301 return 31-
static_cast<intptr_t
>(x);
304 #define __TBB_Log2(V) __TBB_machine_lg(V) 307 typedef uint32_t __TBB_Flag;
308 #define __TBB_Flag __TBB_Flag 310 inline bool __TBB_machine_trylockbyte( __TBB_atomic __TBB_Flag &flag ) {
311 return __TBB_machine_cmpswp4(&flag,1,0)==0;
313 #define __TBB_TryLockByte(P) __TBB_machine_trylockbyte(P) Definition: _flow_graph_async_msg_impl.h:32
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44