tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
simddetect.h
1 // 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.
17 #ifndef TESSERACT_ARCH_SIMDDETECT_H_
18 #define TESSERACT_ARCH_SIMDDETECT_H_
19 
20 #include "platform.h"
21 
22 // Architecture detector. Add code here to detect any other architectures for
23 // SIMD-based faster dot product functions. Intended to be a single static
24 // object, but it does no real harm to have more than one.
25 class SIMDDetect {
26  public:
27  // Returns true if AVX is available on this system.
28  static inline bool IsAVXAvailable() { return detector.avx_available_; }
29  // Returns true if AVX2 (integer support) is available on this system.
30  static inline bool IsAVX2Available() { return detector.avx2_available_; }
31  // Returns true if AVX512 Foundation (float) is available on this system.
32  static inline bool IsAVX512FAvailable() {
34  }
35  // Returns true if AVX512 integer is available on this system.
36  static inline bool IsAVX512BWAvailable() {
38  }
39  // Returns true if SSE4.1 is available on this system.
40  static inline bool IsSSEAvailable() { return detector.sse_available_; }
41 
42  private:
43  // Constructor, must set all static member variables.
44  SIMDDetect();
45 
46  private:
47  // Singleton.
49  // If true, then AVX has been detected.
50  static TESS_API bool avx_available_;
51  static TESS_API bool avx2_available_;
52  static TESS_API bool avx512F_available_;
53  static TESS_API bool avx512BW_available_;
54  // If true, then SSe4.1 has been detected.
55  static TESS_API bool sse_available_;
56 };
57 
58 #endif // TESSERACT_ARCH_SIMDDETECT_H_
Definition: simddetect.h:25
static bool IsAVX512FAvailable()
Definition: simddetect.h:32
static TESS_API bool avx512F_available_
Definition: simddetect.h:52
static bool IsAVX512BWAvailable()
Definition: simddetect.h:36
static TESS_API bool sse_available_
Definition: simddetect.h:55
static TESS_API bool avx2_available_
Definition: simddetect.h:51
static bool IsAVXAvailable()
Definition: simddetect.h:28
static TESS_API bool avx512BW_available_
Definition: simddetect.h:53
SIMDDetect()
Definition: simddetect.cpp:50
static SIMDDetect detector
Definition: simddetect.h:48
static bool IsAVX2Available()
Definition: simddetect.h:30
static TESS_API bool avx_available_
Definition: simddetect.h:50
static bool IsSSEAvailable()
Definition: simddetect.h:40