diff --git a/src/api/tesseractmain.cpp b/src/api/tesseractmain.cpp index 93584231cd..efb8c5aaa7 100644 --- a/src/api/tesseractmain.cpp +++ b/src/api/tesseractmain.cpp @@ -108,13 +108,13 @@ static void PrintVersionInfo() { } } } - } + } #endif - if (SIMDDetect::IsAVX512BWAvailable()) printf(" Found AVX512BW\n"); - if (SIMDDetect::IsAVX512FAvailable()) printf(" Found AVX512F\n"); - if (SIMDDetect::IsAVX2Available()) printf(" Found AVX2\n"); - if (SIMDDetect::IsAVXAvailable()) printf(" Found AVX\n"); - if (SIMDDetect::IsSSEAvailable()) printf(" Found SSE\n"); + if (tesseract::SIMDDetect::IsAVX512BWAvailable()) printf(" Found AVX512BW\n"); + if (tesseract::SIMDDetect::IsAVX512FAvailable()) printf(" Found AVX512F\n"); + if (tesseract::SIMDDetect::IsAVX2Available()) printf(" Found AVX2\n"); + if (tesseract::SIMDDetect::IsAVXAvailable()) printf(" Found AVX\n"); + if (tesseract::SIMDDetect::IsSSEAvailable()) printf(" Found SSE\n"); } static void PrintHelpForPSM() { @@ -706,4 +706,3 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } - diff --git a/src/arch/simddetect.cpp b/src/arch/simddetect.cpp index 3a3990a5bd..09f742f262 100644 --- a/src/arch/simddetect.cpp +++ b/src/arch/simddetect.cpp @@ -19,19 +19,21 @@ #undef X86_BUILD #if defined(__x86_64__) || defined(__i386__) || defined(_WIN32) -#if !defined(ANDROID_BUILD) -#define X86_BUILD 1 -#endif // !ANDROID_BUILD -#endif // x86 target +# if !defined(ANDROID_BUILD) +# define X86_BUILD 1 +# endif // !ANDROID_BUILD +#endif // x86 target #if defined(X86_BUILD) -#if defined(__GNUC__) -#include -#elif defined(_WIN32) -#include -#endif +# if defined(__GNUC__) +# include +# elif defined(_WIN32) +# include +# endif #endif +namespace tesseract { + SIMDDetect SIMDDetect::detector; // If true, then AVX has been detected. @@ -49,7 +51,7 @@ bool SIMDDetect::sse_available_; // clang. SIMDDetect::SIMDDetect() { #if defined(X86_BUILD) -#if defined(__GNUC__) +# if defined(__GNUC__) unsigned int eax, ebx, ecx, edx; if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) != 0) { // Note that these tests all use hex because the older compilers don't have @@ -66,7 +68,7 @@ SIMDDetect::SIMDDetect() { avx512BW_available_ = (ebx & 0x40000000) != 0; } } -#elif defined(_WIN32) +# elif defined(_WIN32) int cpuInfo[4]; __cpuid(cpuInfo, 0); if (cpuInfo[0] >= 1) { @@ -74,8 +76,10 @@ SIMDDetect::SIMDDetect() { sse_available_ = (cpuInfo[2] & 0x00080000) != 0; avx_available_ = (cpuInfo[2] & 0x10000000) != 0; } -#else -#error "I don't know how to test for SIMD with this compiler" -#endif +# else +# error "I don't know how to test for SIMD with this compiler" +# endif #endif // X86_BUILD } + +} // namespace tesseract diff --git a/src/arch/simddetect.h b/src/arch/simddetect.h index 26b6920c3a..efb631938a 100644 --- a/src/arch/simddetect.h +++ b/src/arch/simddetect.h @@ -19,6 +19,8 @@ #include "platform.h" +namespace tesseract { + // Architecture detector. Add code here to detect any other architectures for // SIMD-based faster dot product functions. Intended to be a single static // object, but it does no real harm to have more than one. @@ -55,4 +57,6 @@ class SIMDDetect { static TESS_API bool sse_available_; }; +} // namespace tesseract + #endif // TESSERACT_ARCH_SIMDDETECT_H_