EstervQrCode 1.1.1
Library for qr code manipulation
cv_cpu_dispatch.h
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 
5 #if defined __OPENCV_BUILD \
6 
7 #include "cv_cpu_config.h"
8 #include "cv_cpu_helper.h"
9 
10 #ifdef CV_CPU_DISPATCH_MODE
11 #define CV_CPU_OPTIMIZATION_NAMESPACE __CV_CAT(opt_, CV_CPU_DISPATCH_MODE)
12 #define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) {
13 #define CV_CPU_OPTIMIZATION_NAMESPACE_END }
14 #else
15 #define CV_CPU_OPTIMIZATION_NAMESPACE cpu_baseline
16 #define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace cpu_baseline {
17 #define CV_CPU_OPTIMIZATION_NAMESPACE_END }
18 #define CV_CPU_BASELINE_MODE 1
19 #endif
20 
21 
22 #define __CV_CPU_DISPATCH_CHAIN_END(fn, args, mode, ...) /* done */
23 #define __CV_CPU_DISPATCH(fn, args, mode, ...) __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
24 #define __CV_CPU_DISPATCH_EXPAND(fn, args, ...) __CV_EXPAND(__CV_CPU_DISPATCH(fn, args, __VA_ARGS__))
25 #define CV_CPU_DISPATCH(fn, args, ...) __CV_CPU_DISPATCH_EXPAND(fn, args, __VA_ARGS__, END) // expand macros
26 
27 
28 #if defined CV_ENABLE_INTRINSICS \
29  && !defined CV_DISABLE_OPTIMIZATION \
30  && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ \
31 
32 #ifdef CV_CPU_COMPILE_SSE2
33 # include <emmintrin.h>
34 # define CV_MMX 1
35 # define CV_SSE 1
36 # define CV_SSE2 1
37 #endif
38 #ifdef CV_CPU_COMPILE_SSE3
39 # include <pmmintrin.h>
40 # define CV_SSE3 1
41 #endif
42 #ifdef CV_CPU_COMPILE_SSSE3
43 # include <tmmintrin.h>
44 # define CV_SSSE3 1
45 #endif
46 #ifdef CV_CPU_COMPILE_SSE4_1
47 # include <smmintrin.h>
48 # define CV_SSE4_1 1
49 #endif
50 #ifdef CV_CPU_COMPILE_SSE4_2
51 # include <nmmintrin.h>
52 # define CV_SSE4_2 1
53 #endif
54 #ifdef CV_CPU_COMPILE_POPCNT
55 # ifdef _MSC_VER
56 # include <nmmintrin.h>
57 # if defined(_M_X64)
58 # define CV_POPCNT_U64 (int)_mm_popcnt_u64
59 # endif
60 # define CV_POPCNT_U32 _mm_popcnt_u32
61 # else
62 # include <popcntintrin.h>
63 # if defined(__x86_64__)
64 # define CV_POPCNT_U64 __builtin_popcountll
65 # endif
66 # define CV_POPCNT_U32 __builtin_popcount
67 # endif
68 # define CV_POPCNT 1
69 #endif
70 #ifdef CV_CPU_COMPILE_AVX
71 # include <immintrin.h>
72 # define CV_AVX 1
73 #endif
74 #ifdef CV_CPU_COMPILE_FP16
75 # if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
76 # include <arm_neon.h>
77 # else
78 # include <immintrin.h>
79 # endif
80 # define CV_FP16 1
81 #endif
82 #ifdef CV_CPU_COMPILE_NEON_DOTPROD
83 # include <arm_neon.h>
84 # define CV_NEON_DOT 1
85 #endif
86 #ifdef CV_CPU_COMPILE_AVX2
87 # include <immintrin.h>
88 # define CV_AVX2 1
89 #endif
90 #ifdef CV_CPU_COMPILE_AVX_512F
91 # include <immintrin.h>
92 # define CV_AVX_512F 1
93 #endif
94 #ifdef CV_CPU_COMPILE_AVX512_COMMON
95 # define CV_AVX512_COMMON 1
96 # define CV_AVX_512CD 1
97 #endif
98 #ifdef CV_CPU_COMPILE_AVX512_KNL
99 # define CV_AVX512_KNL 1
100 # define CV_AVX_512ER 1
101 # define CV_AVX_512PF 1
102 #endif
103 #ifdef CV_CPU_COMPILE_AVX512_KNM
104 # define CV_AVX512_KNM 1
105 # define CV_AVX_5124FMAPS 1
106 # define CV_AVX_5124VNNIW 1
107 # define CV_AVX_512VPOPCNTDQ 1
108 #endif
109 #ifdef CV_CPU_COMPILE_AVX512_SKX
110 # define CV_AVX512_SKX 1
111 # define CV_AVX_512VL 1
112 # define CV_AVX_512BW 1
113 # define CV_AVX_512DQ 1
114 #endif
115 #ifdef CV_CPU_COMPILE_AVX512_CNL
116 # define CV_AVX512_CNL 1
117 # define CV_AVX_512IFMA 1
118 # define CV_AVX_512VBMI 1
119 #endif
120 #ifdef CV_CPU_COMPILE_AVX512_CLX
121 # define CV_AVX512_CLX 1
122 # define CV_AVX_512VNNI 1
123 #endif
124 #ifdef CV_CPU_COMPILE_AVX512_ICL
125 # define CV_AVX512_ICL 1
126 # undef CV_AVX_512IFMA
127 # define CV_AVX_512IFMA 1
128 # undef CV_AVX_512VBMI
129 # define CV_AVX_512VBMI 1
130 # undef CV_AVX_512VNNI
131 # define CV_AVX_512VNNI 1
132 # define CV_AVX_512VBMI2 1
133 # define CV_AVX_512BITALG 1
134 # define CV_AVX_512VPOPCNTDQ 1
135 #endif
136 #ifdef CV_CPU_COMPILE_FMA3
137 # define CV_FMA3 1
138 #endif
139 
140 #if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER))
141 # include <Intrin.h>
142 # include <arm_neon.h>
143 # define CV_NEON 1
144 #elif defined(__ARM_NEON)
145 # include <arm_neon.h>
146 # define CV_NEON 1
147 #endif
148 
149 #if defined(__riscv) && defined(__riscv_vector) && defined(__riscv_vector_071)
150 # include<riscv_vector.h>
151 # define CV_RVV071 1
152 #endif
153 
154 #ifdef CV_CPU_COMPILE_VSX
155 # include <altivec.h>
156 # undef vector
157 # undef pixel
158 # undef bool
159 # define CV_VSX 1
160 #endif
161 
162 #ifdef CV_CPU_COMPILE_VSX3
163 # define CV_VSX3 1
164 #endif
165 
166 #ifdef CV_CPU_COMPILE_MSA
167 # include "hal/msa_macros.h"
168 # define CV_MSA 1
169 #endif
170 
171 #ifdef CV_CPU_COMPILE_LSX
172 # include <lsxintrin.h>
173 # define CV_LSX 1
174 #endif
175 
176 #ifdef CV_CPU_COMPILE_LASX
177 # include <lasxintrin.h>
178 # define CV_LASX 1
179 #endif
180 
181 #ifdef __EMSCRIPTEN__
182 # define CV_WASM_SIMD 1
183 # include <wasm_simd128.h>
184 #endif
185 
186 #if defined CV_CPU_COMPILE_RVV
187 # define CV_RVV 1
188 # include <riscv_vector.h>
189 #endif
190 
191 #endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__
192 
193 #if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX
194 struct VZeroUpperGuard {
195 #ifdef __GNUC__
196  __attribute__((always_inline))
197 #endif
198  inline VZeroUpperGuard() { _mm256_zeroupper(); }
199 #ifdef __GNUC__
200  __attribute__((always_inline))
201 #endif
202  inline ~VZeroUpperGuard() { _mm256_zeroupper(); }
203 };
204 #define __CV_AVX_GUARD VZeroUpperGuard __vzeroupper_guard; CV_UNUSED(__vzeroupper_guard);
205 #endif
206 
207 #ifdef __CV_AVX_GUARD
208 #define CV_AVX_GUARD __CV_AVX_GUARD
209 #else
210 #define CV_AVX_GUARD
211 #endif
212 
213 #endif // __OPENCV_BUILD
214 
215 
216 
217 #if !defined __OPENCV_BUILD /* Compatibility code */ \
218  && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */
219 #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
220 # include <emmintrin.h>
221 # define CV_MMX 1
222 # define CV_SSE 1
223 # define CV_SSE2 1
224 #elif defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER))
225 # include <Intrin.h>
226 # include <arm_neon.h>
227 # define CV_NEON 1
228 #elif defined(__ARM_NEON)
229 # include <arm_neon.h>
230 # define CV_NEON 1
231 #elif defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
232 # include <altivec.h>
233 # undef vector
234 # undef pixel
235 # undef bool
236 # define CV_VSX 1
237 #endif
238 
239 #ifdef __F16C__
240 # include <immintrin.h>
241 # define CV_FP16 1
242 #endif
243 
244 #endif // !__OPENCV_BUILD && !__CUDACC (Compatibility code)
245 
246 
247 
248 #ifndef CV_MMX
249 # define CV_MMX 0
250 #endif
251 #ifndef CV_SSE
252 # define CV_SSE 0
253 #endif
254 #ifndef CV_SSE2
255 # define CV_SSE2 0
256 #endif
257 #ifndef CV_SSE3
258 # define CV_SSE3 0
259 #endif
260 #ifndef CV_SSSE3
261 # define CV_SSSE3 0
262 #endif
263 #ifndef CV_SSE4_1
264 # define CV_SSE4_1 0
265 #endif
266 #ifndef CV_SSE4_2
267 # define CV_SSE4_2 0
268 #endif
269 #ifndef CV_POPCNT
270 # define CV_POPCNT 0
271 #endif
272 #ifndef CV_AVX
273 # define CV_AVX 0
274 #endif
275 #ifndef CV_FP16
276 # define CV_FP16 0
277 #endif
278 #ifndef CV_AVX2
279 # define CV_AVX2 0
280 #endif
281 #ifndef CV_FMA3
282 # define CV_FMA3 0
283 #endif
284 #ifndef CV_AVX_512F
285 # define CV_AVX_512F 0
286 #endif
287 #ifndef CV_AVX_512BW
288 # define CV_AVX_512BW 0
289 #endif
290 #ifndef CV_AVX_512CD
291 # define CV_AVX_512CD 0
292 #endif
293 #ifndef CV_AVX_512DQ
294 # define CV_AVX_512DQ 0
295 #endif
296 #ifndef CV_AVX_512ER
297 # define CV_AVX_512ER 0
298 #endif
299 #ifndef CV_AVX_512IFMA
300 # define CV_AVX_512IFMA 0
301 #endif
302 #define CV_AVX_512IFMA512 CV_AVX_512IFMA // deprecated
303 #ifndef CV_AVX_512PF
304 # define CV_AVX_512PF 0
305 #endif
306 #ifndef CV_AVX_512VBMI
307 # define CV_AVX_512VBMI 0
308 #endif
309 #ifndef CV_AVX_512VL
310 # define CV_AVX_512VL 0
311 #endif
312 #ifndef CV_AVX_5124FMAPS
313 # define CV_AVX_5124FMAPS 0
314 #endif
315 #ifndef CV_AVX_5124VNNIW
316 # define CV_AVX_5124VNNIW 0
317 #endif
318 #ifndef CV_AVX_512VPOPCNTDQ
319 # define CV_AVX_512VPOPCNTDQ 0
320 #endif
321 #ifndef CV_AVX_512VNNI
322 # define CV_AVX_512VNNI 0
323 #endif
324 #ifndef CV_AVX_512VBMI2
325 # define CV_AVX_512VBMI2 0
326 #endif
327 #ifndef CV_AVX_512BITALG
328 # define CV_AVX_512BITALG 0
329 #endif
330 #ifndef CV_AVX512_COMMON
331 # define CV_AVX512_COMMON 0
332 #endif
333 #ifndef CV_AVX512_KNL
334 # define CV_AVX512_KNL 0
335 #endif
336 #ifndef CV_AVX512_KNM
337 # define CV_AVX512_KNM 0
338 #endif
339 #ifndef CV_AVX512_SKX
340 # define CV_AVX512_SKX 0
341 #endif
342 #ifndef CV_AVX512_CNL
343 # define CV_AVX512_CNL 0
344 #endif
345 #ifndef CV_AVX512_CLX
346 # define CV_AVX512_CLX 0
347 #endif
348 #ifndef CV_AVX512_ICL
349 # define CV_AVX512_ICL 0
350 #endif
351 
352 #ifndef CV_NEON
353 # define CV_NEON 0
354 #endif
355 
356 #ifndef CV_RVV071
357 # define CV_RVV071 0
358 #endif
359 
360 #ifndef CV_VSX
361 # define CV_VSX 0
362 #endif
363 
364 #ifndef CV_VSX3
365 # define CV_VSX3 0
366 #endif
367 
368 #ifndef CV_MSA
369 # define CV_MSA 0
370 #endif
371 
372 #ifndef CV_WASM_SIMD
373 # define CV_WASM_SIMD 0
374 #endif
375 
376 #ifndef CV_RVV
377 # define CV_RVV 0
378 #endif
379 
380 #ifndef CV_LSX
381 # define CV_LSX 0
382 #endif
383 
384 #ifndef CV_LASX
385 # define CV_LASX 0
386 #endif