tesseract  5.0.0
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 264 of file simddetect.cpp.

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