Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/tesseract/src/arch/simddetect.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /////////////////////////////////////////////////////////////////////// | |
| 2 // File: simddetect.h | |
| 3 // Description: Architecture detector. | |
| 4 // Author: Stefan Weil (based on code from Ray Smith) | |
| 5 // | |
| 6 // (C) Copyright 2014, Google Inc. | |
| 7 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 8 // you may not use this file except in compliance with the License. | |
| 9 // You may obtain a copy of the License at | |
| 10 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 // Unless required by applicable law or agreed to in writing, software | |
| 12 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 // See the License for the specific language governing permissions and | |
| 15 // limitations under the License. | |
| 16 /////////////////////////////////////////////////////////////////////// | |
| 17 #ifndef TESSERACT_ARCH_SIMDDETECT_H_ | |
| 18 #define TESSERACT_ARCH_SIMDDETECT_H_ | |
| 19 | |
| 20 #include <tesseract/export.h> | |
| 21 #include "tesstypes.h" | |
| 22 | |
| 23 namespace tesseract { | |
| 24 | |
| 25 // Function pointer for best calculation of dot product. | |
| 26 using DotProductFunction = TFloat (*)(const TFloat *, const TFloat *, int); | |
| 27 extern DotProductFunction DotProduct; | |
| 28 | |
| 29 // Architecture detector. Add code here to detect any other architectures for | |
| 30 // SIMD-based faster dot product functions. Intended to be a single static | |
| 31 // object, but it does no real harm to have more than one. | |
| 32 class SIMDDetect { | |
| 33 public: | |
| 34 // Returns true if AVX is available on this system. | |
| 35 static inline bool IsAVXAvailable() { | |
| 36 return detector.avx_available_; | |
| 37 } | |
| 38 // Returns true if AVX2 (integer support) is available on this system. | |
| 39 static inline bool IsAVX2Available() { | |
| 40 return detector.avx2_available_; | |
| 41 } | |
| 42 // Returns true if AVX512 Foundation (float) is available on this system. | |
| 43 static inline bool IsAVX512FAvailable() { | |
| 44 return detector.avx512F_available_; | |
| 45 } | |
| 46 // Returns true if AVX512 integer is available on this system. | |
| 47 static inline bool IsAVX512BWAvailable() { | |
| 48 return detector.avx512BW_available_; | |
| 49 } | |
| 50 // Returns true if AVX512 Vector Neural Network Instructions are available. | |
| 51 static inline bool IsAVX512VNNIAvailable() { | |
| 52 return detector.avx512VNNI_available_; | |
| 53 } | |
| 54 // Returns true if FMA is available on this system. | |
| 55 static inline bool IsFMAAvailable() { | |
| 56 return detector.fma_available_; | |
| 57 } | |
| 58 // Returns true if SSE4.1 is available on this system. | |
| 59 static inline bool IsSSEAvailable() { | |
| 60 return detector.sse_available_; | |
| 61 } | |
| 62 // Returns true if NEON is available on this system. | |
| 63 static inline bool IsNEONAvailable() { | |
| 64 return detector.neon_available_; | |
| 65 } | |
| 66 // Returns true if RVV is available on this system. | |
| 67 static inline bool IsRVVAvailable() { | |
| 68 return detector.rvv_available_; | |
| 69 } | |
| 70 | |
| 71 // Update settings after config variable was set. | |
| 72 static TESS_API void Update(); | |
| 73 | |
| 74 private: | |
| 75 // Constructor, must set all static member variables. | |
| 76 SIMDDetect(); | |
| 77 | |
| 78 private: | |
| 79 // Singleton. | |
| 80 static SIMDDetect detector; | |
| 81 // If true, then AVX has been detected. | |
| 82 static TESS_API bool avx_available_; | |
| 83 static TESS_API bool avx2_available_; | |
| 84 static TESS_API bool avx512F_available_; | |
| 85 static TESS_API bool avx512BW_available_; | |
| 86 static TESS_API bool avx512VNNI_available_; | |
| 87 // If true, then FMA has been detected. | |
| 88 static TESS_API bool fma_available_; | |
| 89 // If true, then SSe4.1 has been detected. | |
| 90 static TESS_API bool sse_available_; | |
| 91 // If true, then NEON has been detected. | |
| 92 static TESS_API bool neon_available_; | |
| 93 // If true, then RVV has been detected. | |
| 94 static TESS_API bool rvv_available_; | |
| 95 }; | |
| 96 | |
| 97 } // namespace tesseract | |
| 98 | |
| 99 #endif // TESSERACT_ARCH_SIMDDETECT_H_ |
