tesseract 5.2.0
Loading...
Searching...
No Matches
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 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 }

◆ 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 51 of file simddetect.h.

51 {
52 return detector.fma_available_;
53 }

◆ IsNEONAvailable()

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

Definition at line 59 of file simddetect.h.

59 {
60 return detector.neon_available_;
61 }

◆ IsSSEAvailable()

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

Definition at line 55 of file simddetect.h.

55 {
56 return detector.sse_available_;
57 }

◆ Update()

void tesseract::SIMDDetect::Update ( )
static

Definition at line 268 of file simddetect.cpp.

268 {
269 // Select code for calculation of dot product based on the
270 // value of the config variable if that value is not empty.
271 const char *dotproduct_method = "generic";
272 if (dotproduct == "auto") {
273 // Automatic detection. Nothing to be done.
274 } else if (dotproduct == "generic") {
275 // Generic code selected by config variable.
276 SetDotProduct(DotProductGeneric);
277 dotproduct_method = "generic";
278 } else if (dotproduct == "native") {
279 // Native optimized code selected by config variable.
281 dotproduct_method = "native";
282#if defined(HAVE_AVX2)
283 } else if (dotproduct == "avx2") {
284 // AVX2 selected by config variable.
286 dotproduct_method = "avx2";
287#endif
288#if defined(HAVE_AVX)
289 } else if (dotproduct == "avx") {
290 // AVX selected by config variable.
292 dotproduct_method = "avx";
293#endif
294#if defined(HAVE_FMA)
295 } else if (dotproduct == "fma") {
296 // FMA selected by config variable.
298 dotproduct_method = "fma";
299#endif
300#if defined(HAVE_SSE4_1)
301 } else if (dotproduct == "sse") {
302 // SSE selected by config variable.
304 dotproduct_method = "sse";
305#endif
306#if defined(HAVE_FRAMEWORK_ACCELERATE)
307 } else if (dotproduct == "accelerate") {
308 SetDotProduct(DotProductAccelerate, IntSimdMatrix::intSimdMatrix);
309#endif
310#if defined(HAVE_NEON) || defined(__aarch64__)
311 } else if (dotproduct == "neon" && neon_available_) {
312 // NEON selected by config variable.
314 dotproduct_method = "neon";
315#endif
316 } else if (dotproduct == "std::inner_product") {
317 // std::inner_product selected by config variable.
318 SetDotProduct(DotProductStdInnerProduct, IntSimdMatrix::intSimdMatrix);
319 dotproduct_method = "std::inner_product";
320 } else {
321 // Unsupported value of config variable.
322 tprintf("Warning, ignoring unsupported config variable value: dotproduct=%s\n",
323 dotproduct.c_str());
324 tprintf(
325 "Supported values for dotproduct: auto generic native"
326#if defined(HAVE_AVX2)
327 " avx2"
328#endif
329#if defined(HAVE_AVX)
330 " avx"
331#endif
332#if defined(HAVE_FMA)
333 " fma"
334#endif
335#if defined(HAVE_SSE4_1)
336 " sse"
337#endif
338#if defined(HAVE_FRAMEWORK_ACCELERATE)
339 " accelerate"
340#endif
341 " std::inner_product.\n");
342 }
343
344 dotproduct.set_value(dotproduct_method);
345}
#define HAVE_AVX2
Definition: config_auto.h:26
#define HAVE_SSE4_1
Definition: config_auto.h:74
#define HAVE_AVX
Definition: config_auto.h:23
#define HAVE_FMA
Definition: config_auto.h:44
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: