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