tesseract v5.3.3.20231005
tesseract::SIMDDetect Class Reference

#include <simddetect.h>

Static Public Member Functions

static bool IsAVXAvailable ()
 
static bool IsAVX2Available ()
 
static bool IsAVX512FAvailable ()
 
static bool IsAVX512BWAvailable ()
 
static bool IsAVX512VNNIAvailable ()
 
static bool IsFMAAvailable ()
 
static bool IsSSEAvailable ()
 
static bool IsNEONAvailable ()
 
static TESS_API void Update ()
 

Detailed Description

Definition at line 32 of file simddetect.h.

Member Function Documentation

◆ IsAVX2Available()

static bool tesseract::SIMDDetect::IsAVX2Available ( )
inlinestatic

Definition at line 39 of file simddetect.h.

39 {
40 return detector.avx2_available_;
41 }

◆ IsAVX512BWAvailable()

static bool tesseract::SIMDDetect::IsAVX512BWAvailable ( )
inlinestatic

Definition at line 47 of file simddetect.h.

47 {
48 return detector.avx512BW_available_;
49 }

◆ IsAVX512FAvailable()

static bool tesseract::SIMDDetect::IsAVX512FAvailable ( )
inlinestatic

Definition at line 43 of file simddetect.h.

43 {
44 return detector.avx512F_available_;
45 }

◆ IsAVX512VNNIAvailable()

static bool tesseract::SIMDDetect::IsAVX512VNNIAvailable ( )
inlinestatic

Definition at line 51 of file simddetect.h.

51 {
52 return detector.avx512VNNI_available_;
53 }

◆ IsAVXAvailable()

static bool tesseract::SIMDDetect::IsAVXAvailable ( )
inlinestatic

Definition at line 35 of file simddetect.h.

35 {
36 return detector.avx_available_;
37 }

◆ IsFMAAvailable()

static bool tesseract::SIMDDetect::IsFMAAvailable ( )
inlinestatic

Definition at line 55 of file simddetect.h.

55 {
56 return detector.fma_available_;
57 }

◆ IsNEONAvailable()

static bool tesseract::SIMDDetect::IsNEONAvailable ( )
inlinestatic

Definition at line 63 of file simddetect.h.

63 {
64 return detector.neon_available_;
65 }

◆ IsSSEAvailable()

static bool tesseract::SIMDDetect::IsSSEAvailable ( )
inlinestatic

Definition at line 59 of file simddetect.h.

59 {
60 return detector.sse_available_;
61 }

◆ Update()

void tesseract::SIMDDetect::Update ( )
static

Definition at line 272 of file simddetect.cpp.

272 {
273 // Select code for calculation of dot product based on the
274 // value of the config variable if that value is not empty.
275 const char *dotproduct_method = "generic";
276 if (dotproduct == "auto") {
277 // Automatic detection. Nothing to be done.
278 } else if (dotproduct == "generic") {
279 // Generic code selected by config variable.
280 SetDotProduct(DotProductGeneric);
281 dotproduct_method = "generic";
282 } else if (dotproduct == "native") {
283 // Native optimized code selected by config variable.
285 dotproduct_method = "native";
286#if defined(HAVE_AVX2)
287 } else if (dotproduct == "avx2") {
288 // AVX2 selected by config variable.
290 dotproduct_method = "avx2";
291#endif
292#if defined(HAVE_AVX)
293 } else if (dotproduct == "avx") {
294 // AVX selected by config variable.
296 dotproduct_method = "avx";
297#endif
298#if defined(HAVE_FMA)
299 } else if (dotproduct == "fma") {
300 // FMA selected by config variable.
302 dotproduct_method = "fma";
303#endif
304#if defined(HAVE_SSE4_1)
305 } else if (dotproduct == "sse") {
306 // SSE selected by config variable.
308 dotproduct_method = "sse";
309#endif
310#if defined(HAVE_FRAMEWORK_ACCELERATE)
311 } else if (dotproduct == "accelerate") {
312 SetDotProduct(DotProductAccelerate, IntSimdMatrix::intSimdMatrix);
313#endif
314#if defined(HAVE_NEON) || defined(__aarch64__)
315 } else if (dotproduct == "neon" && neon_available_) {
316 // NEON selected by config variable.
318 dotproduct_method = "neon";
319#endif
320 } else if (dotproduct == "std::inner_product") {
321 // std::inner_product selected by config variable.
322 SetDotProduct(DotProductStdInnerProduct, IntSimdMatrix::intSimdMatrix);
323 dotproduct_method = "std::inner_product";
324 } else {
325 // Unsupported value of config variable.
326 tprintf("Warning, ignoring unsupported config variable value: dotproduct=%s\n",
327 dotproduct.c_str());
328 tprintf(
329 "Supported values for dotproduct: auto generic native"
330#if defined(HAVE_AVX2)
331 " avx2"
332#endif
333#if defined(HAVE_AVX)
334 " avx"
335#endif
336#if defined(HAVE_FMA)
337 " fma"
338#endif
339#if defined(HAVE_SSE4_1)
340 " sse"
341#endif
342#if defined(HAVE_FRAMEWORK_ACCELERATE)
343 " accelerate"
344#endif
345 " std::inner_product.\n");
346 }
347
348 dotproduct.set_value(dotproduct_method);
349}
void tprintf(const char *format,...)
Definition: tprintf.cpp:41
TFloat DotProductNEON(const TFloat *u, const TFloat *v, int n)
TFloat DotProductFMA(const TFloat *u, const TFloat *v, int n)
TFloat DotProductNative(const TFloat *u, const TFloat *v, int n)
Definition: dotproduct.cpp:22
TFloat DotProductAVX(const TFloat *u, const TFloat *v, int n)
TFloat DotProductSSE(const TFloat *u, const TFloat *v, int n)
static const IntSimdMatrix intSimdMatrixAVX2
static const IntSimdMatrix * intSimdMatrix
static const IntSimdMatrix intSimdMatrixSSE
static const IntSimdMatrix intSimdMatrixNEON

The documentation for this class was generated from the following files: