linux_ia64.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. Copyright 2005-2013 Intel Corporation. All Rights Reserved.
  3. This file is part of Threading Building Blocks.
  4. Threading Building Blocks is free software; you can redistribute it
  5. and/or modify it under the terms of the GNU General Public License
  6. version 2 as published by the Free Software Foundation.
  7. Threading Building Blocks is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with Threading Building Blocks; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. As a special exception, you may use this file as part of a free software
  15. library without restriction. Specifically, if other files instantiate
  16. templates or use macros or inline functions from this file, or you compile
  17. this file and link it with other files to produce an executable, this
  18. file does not by itself cause the resulting executable to be covered by
  19. the GNU General Public License. This exception does not however
  20. invalidate any other reasons why the executable file might be covered by
  21. the GNU General Public License.
  22. */
  23. #if !defined(__TBB_machine_H) || defined(__TBB_machine_linux_ia64_H)
  24. #error Do not #include this internal file directly; use public TBB headers instead.
  25. #endif
  26. #define __TBB_machine_linux_ia64_H
  27. #include <stdint.h>
  28. #include <ia64intrin.h>
  29. #define __TBB_WORDSIZE 8
  30. #define __TBB_BIG_ENDIAN 0
  31. #if __INTEL_COMPILER
  32. #define __TBB_compiler_fence()
  33. #define __TBB_control_consistency_helper() __TBB_compiler_fence()
  34. #define __TBB_acquire_consistency_helper()
  35. #define __TBB_release_consistency_helper()
  36. #define __TBB_full_memory_fence() __mf()
  37. #else
  38. #define __TBB_compiler_fence() __asm__ __volatile__("": : :"memory")
  39. #define __TBB_control_consistency_helper() __TBB_compiler_fence()
  40. // Even though GCC imbues volatile loads with acquire semantics, it sometimes moves
  41. // loads over the acquire fence. The following helpers stop such incorrect code motion.
  42. #define __TBB_acquire_consistency_helper() __TBB_compiler_fence()
  43. #define __TBB_release_consistency_helper() __TBB_compiler_fence()
  44. #define __TBB_full_memory_fence() __asm__ __volatile__("mf": : :"memory")
  45. #endif /* !__INTEL_COMPILER */
  46. // Most of the functions will be in a .s file
  47. // TODO: revise dynamic_link, memory pools and etc. if the library dependency is removed.
  48. extern "C" {
  49. int8_t __TBB_machine_fetchadd1__TBB_full_fence (volatile void *ptr, int8_t addend);
  50. int8_t __TBB_machine_fetchadd1acquire(volatile void *ptr, int8_t addend);
  51. int8_t __TBB_machine_fetchadd1release(volatile void *ptr, int8_t addend);
  52. int16_t __TBB_machine_fetchadd2__TBB_full_fence (volatile void *ptr, int16_t addend);
  53. int16_t __TBB_machine_fetchadd2acquire(volatile void *ptr, int16_t addend);
  54. int16_t __TBB_machine_fetchadd2release(volatile void *ptr, int16_t addend);
  55. int32_t __TBB_machine_fetchadd4__TBB_full_fence (volatile void *ptr, int32_t value);
  56. int32_t __TBB_machine_fetchadd4acquire(volatile void *ptr, int32_t addend);
  57. int32_t __TBB_machine_fetchadd4release(volatile void *ptr, int32_t addend);
  58. int64_t __TBB_machine_fetchadd8__TBB_full_fence (volatile void *ptr, int64_t value);
  59. int64_t __TBB_machine_fetchadd8acquire(volatile void *ptr, int64_t addend);
  60. int64_t __TBB_machine_fetchadd8release(volatile void *ptr, int64_t addend);
  61. int8_t __TBB_machine_fetchstore1__TBB_full_fence (volatile void *ptr, int8_t value);
  62. int8_t __TBB_machine_fetchstore1acquire(volatile void *ptr, int8_t value);
  63. int8_t __TBB_machine_fetchstore1release(volatile void *ptr, int8_t value);
  64. int16_t __TBB_machine_fetchstore2__TBB_full_fence (volatile void *ptr, int16_t value);
  65. int16_t __TBB_machine_fetchstore2acquire(volatile void *ptr, int16_t value);
  66. int16_t __TBB_machine_fetchstore2release(volatile void *ptr, int16_t value);
  67. int32_t __TBB_machine_fetchstore4__TBB_full_fence (volatile void *ptr, int32_t value);
  68. int32_t __TBB_machine_fetchstore4acquire(volatile void *ptr, int32_t value);
  69. int32_t __TBB_machine_fetchstore4release(volatile void *ptr, int32_t value);
  70. int64_t __TBB_machine_fetchstore8__TBB_full_fence (volatile void *ptr, int64_t value);
  71. int64_t __TBB_machine_fetchstore8acquire(volatile void *ptr, int64_t value);
  72. int64_t __TBB_machine_fetchstore8release(volatile void *ptr, int64_t value);
  73. int8_t __TBB_machine_cmpswp1__TBB_full_fence (volatile void *ptr, int8_t value, int8_t comparand);
  74. int8_t __TBB_machine_cmpswp1acquire(volatile void *ptr, int8_t value, int8_t comparand);
  75. int8_t __TBB_machine_cmpswp1release(volatile void *ptr, int8_t value, int8_t comparand);
  76. int16_t __TBB_machine_cmpswp2__TBB_full_fence (volatile void *ptr, int16_t value, int16_t comparand);
  77. int16_t __TBB_machine_cmpswp2acquire(volatile void *ptr, int16_t value, int16_t comparand);
  78. int16_t __TBB_machine_cmpswp2release(volatile void *ptr, int16_t value, int16_t comparand);
  79. int32_t __TBB_machine_cmpswp4__TBB_full_fence (volatile void *ptr, int32_t value, int32_t comparand);
  80. int32_t __TBB_machine_cmpswp4acquire(volatile void *ptr, int32_t value, int32_t comparand);
  81. int32_t __TBB_machine_cmpswp4release(volatile void *ptr, int32_t value, int32_t comparand);
  82. int64_t __TBB_machine_cmpswp8__TBB_full_fence (volatile void *ptr, int64_t value, int64_t comparand);
  83. int64_t __TBB_machine_cmpswp8acquire(volatile void *ptr, int64_t value, int64_t comparand);
  84. int64_t __TBB_machine_cmpswp8release(volatile void *ptr, int64_t value, int64_t comparand);
  85. int64_t __TBB_machine_lg(uint64_t value);
  86. void __TBB_machine_pause(int32_t delay);
  87. bool __TBB_machine_trylockbyte( volatile unsigned char &ptr );
  88. int64_t __TBB_machine_lockbyte( volatile unsigned char &ptr );
  89. //! Retrieves the current RSE backing store pointer. IA64 specific.
  90. void* __TBB_get_bsp();
  91. int32_t __TBB_machine_load1_relaxed(const void *ptr);
  92. int32_t __TBB_machine_load2_relaxed(const void *ptr);
  93. int32_t __TBB_machine_load4_relaxed(const void *ptr);
  94. int64_t __TBB_machine_load8_relaxed(const void *ptr);
  95. void __TBB_machine_store1_relaxed(void *ptr, int32_t value);
  96. void __TBB_machine_store2_relaxed(void *ptr, int32_t value);
  97. void __TBB_machine_store4_relaxed(void *ptr, int32_t value);
  98. void __TBB_machine_store8_relaxed(void *ptr, int64_t value);
  99. } // extern "C"
  100. // Mapping old entry points to the names corresponding to the new full_fence identifier.
  101. #define __TBB_machine_fetchadd1full_fence __TBB_machine_fetchadd1__TBB_full_fence
  102. #define __TBB_machine_fetchadd2full_fence __TBB_machine_fetchadd2__TBB_full_fence
  103. #define __TBB_machine_fetchadd4full_fence __TBB_machine_fetchadd4__TBB_full_fence
  104. #define __TBB_machine_fetchadd8full_fence __TBB_machine_fetchadd8__TBB_full_fence
  105. #define __TBB_machine_fetchstore1full_fence __TBB_machine_fetchstore1__TBB_full_fence
  106. #define __TBB_machine_fetchstore2full_fence __TBB_machine_fetchstore2__TBB_full_fence
  107. #define __TBB_machine_fetchstore4full_fence __TBB_machine_fetchstore4__TBB_full_fence
  108. #define __TBB_machine_fetchstore8full_fence __TBB_machine_fetchstore8__TBB_full_fence
  109. #define __TBB_machine_cmpswp1full_fence __TBB_machine_cmpswp1__TBB_full_fence
  110. #define __TBB_machine_cmpswp2full_fence __TBB_machine_cmpswp2__TBB_full_fence
  111. #define __TBB_machine_cmpswp4full_fence __TBB_machine_cmpswp4__TBB_full_fence
  112. #define __TBB_machine_cmpswp8full_fence __TBB_machine_cmpswp8__TBB_full_fence
  113. // Mapping relaxed operations to the entry points implementing them.
  114. /** On IA64 RMW operations implicitly have acquire semantics. Thus one cannot
  115. actually have completely relaxed RMW operation here. **/
  116. #define __TBB_machine_fetchadd1relaxed __TBB_machine_fetchadd1acquire
  117. #define __TBB_machine_fetchadd2relaxed __TBB_machine_fetchadd2acquire
  118. #define __TBB_machine_fetchadd4relaxed __TBB_machine_fetchadd4acquire
  119. #define __TBB_machine_fetchadd8relaxed __TBB_machine_fetchadd8acquire
  120. #define __TBB_machine_fetchstore1relaxed __TBB_machine_fetchstore1acquire
  121. #define __TBB_machine_fetchstore2relaxed __TBB_machine_fetchstore2acquire
  122. #define __TBB_machine_fetchstore4relaxed __TBB_machine_fetchstore4acquire
  123. #define __TBB_machine_fetchstore8relaxed __TBB_machine_fetchstore8acquire
  124. #define __TBB_machine_cmpswp1relaxed __TBB_machine_cmpswp1acquire
  125. #define __TBB_machine_cmpswp2relaxed __TBB_machine_cmpswp2acquire
  126. #define __TBB_machine_cmpswp4relaxed __TBB_machine_cmpswp4acquire
  127. #define __TBB_machine_cmpswp8relaxed __TBB_machine_cmpswp8acquire
  128. #define __TBB_MACHINE_DEFINE_ATOMICS(S,V) \
  129. template <typename T> \
  130. struct machine_load_store_relaxed<T,S> { \
  131. static inline T load ( const T& location ) { \
  132. return (T)__TBB_machine_load##S##_relaxed(&location); \
  133. } \
  134. static inline void store ( T& location, T value ) { \
  135. __TBB_machine_store##S##_relaxed(&location, (V)value); \
  136. } \
  137. }
  138. namespace tbb {
  139. namespace internal {
  140. __TBB_MACHINE_DEFINE_ATOMICS(1,int8_t);
  141. __TBB_MACHINE_DEFINE_ATOMICS(2,int16_t);
  142. __TBB_MACHINE_DEFINE_ATOMICS(4,int32_t);
  143. __TBB_MACHINE_DEFINE_ATOMICS(8,int64_t);
  144. }} // namespaces internal, tbb
  145. #undef __TBB_MACHINE_DEFINE_ATOMICS
  146. #define __TBB_USE_FENCED_ATOMICS 1
  147. #define __TBB_USE_GENERIC_HALF_FENCED_LOAD_STORE 1
  148. #define __TBB_USE_GENERIC_SEQUENTIAL_CONSISTENCY_LOAD_STORE 1
  149. // Definition of Lock functions
  150. #define __TBB_TryLockByte(P) __TBB_machine_trylockbyte(P)
  151. #define __TBB_LockByte(P) __TBB_machine_lockbyte(P)
  152. // Definition of other utility functions
  153. #define __TBB_Pause(V) __TBB_machine_pause(V)
  154. #define __TBB_Log2(V) __TBB_machine_lg(V)