-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace DOS line endings (CRLF) by standard (LF only). Signed-off-by: Stefan Weil <[email protected]>
- Loading branch information
Showing
146 changed files
with
35,442 additions
and
35,442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: dotproductavx.h | ||
// Description: Architecture-specific dot-product function. | ||
// Author: Ray Smith | ||
// Created: Wed Jul 22 10:51:05 PDT 2015 | ||
// | ||
// (C) Copyright 2015, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef TESSERACT_ARCH_DOTPRODUCTAVX_H_ | ||
#define TESSERACT_ARCH_DOTPRODUCTAVX_H_ | ||
|
||
namespace tesseract { | ||
|
||
// Computes and returns the dot product of the n-vectors u and v. | ||
// Uses Intel AVX intrinsics to access the SIMD instruction set. | ||
double DotProductAVX(const double* u, const double* v, int n); | ||
|
||
} // namespace tesseract. | ||
|
||
#endif // TESSERACT_ARCH_DOTPRODUCTAVX_H_ | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: dotproductavx.h | ||
// Description: Architecture-specific dot-product function. | ||
// Author: Ray Smith | ||
// Created: Wed Jul 22 10:51:05 PDT 2015 | ||
// | ||
// (C) Copyright 2015, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef TESSERACT_ARCH_DOTPRODUCTAVX_H_ | ||
#define TESSERACT_ARCH_DOTPRODUCTAVX_H_ | ||
|
||
namespace tesseract { | ||
|
||
// Computes and returns the dot product of the n-vectors u and v. | ||
// Uses Intel AVX intrinsics to access the SIMD instruction set. | ||
double DotProductAVX(const double* u, const double* v, int n); | ||
|
||
} // namespace tesseract. | ||
|
||
#endif // TESSERACT_ARCH_DOTPRODUCTAVX_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: dotproductsse.h | ||
// Description: Architecture-specific dot-product function. | ||
// Author: Ray Smith | ||
// Created: Wed Jul 22 10:57:05 PDT 2015 | ||
// | ||
// (C) Copyright 2015, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef TESSERACT_ARCH_DOTPRODUCTSSE_H_ | ||
#define TESSERACT_ARCH_DOTPRODUCTSSE_H_ | ||
|
||
#include "host.h" | ||
|
||
namespace tesseract { | ||
|
||
// Computes and returns the dot product of the n-vectors u and v. | ||
// Uses Intel SSE intrinsics to access the SIMD instruction set. | ||
double DotProductSSE(const double* u, const double* v, int n); | ||
// Computes and returns the dot product of the n-vectors u and v. | ||
// Uses Intel SSE intrinsics to access the SIMD instruction set. | ||
int32_t IntDotProductSSE(const int8_t* u, const int8_t* v, int n); | ||
|
||
} // namespace tesseract. | ||
|
||
#endif // TESSERACT_ARCH_DOTPRODUCTSSE_H_ | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: dotproductsse.h | ||
// Description: Architecture-specific dot-product function. | ||
// Author: Ray Smith | ||
// Created: Wed Jul 22 10:57:05 PDT 2015 | ||
// | ||
// (C) Copyright 2015, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef TESSERACT_ARCH_DOTPRODUCTSSE_H_ | ||
#define TESSERACT_ARCH_DOTPRODUCTSSE_H_ | ||
|
||
#include "host.h" | ||
|
||
namespace tesseract { | ||
|
||
// Computes and returns the dot product of the n-vectors u and v. | ||
// Uses Intel SSE intrinsics to access the SIMD instruction set. | ||
double DotProductSSE(const double* u, const double* v, int n); | ||
// Computes and returns the dot product of the n-vectors u and v. | ||
// Uses Intel SSE intrinsics to access the SIMD instruction set. | ||
int32_t IntDotProductSSE(const int8_t* u, const int8_t* v, int n); | ||
|
||
} // namespace tesseract. | ||
|
||
#endif // TESSERACT_ARCH_DOTPRODUCTSSE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,82 @@ | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: simddetect.cpp | ||
// Description: Architecture detector. | ||
// Author: Stefan Weil (based on code from Ray Smith) | ||
// | ||
// (C) Copyright 2014, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#include "simddetect.h" | ||
#include "tprintf.h" | ||
|
||
#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(X86_BUILD) | ||
#if defined(__GNUC__) | ||
#include <cpuid.h> | ||
#elif defined(_WIN32) | ||
#include <intrin.h> | ||
#endif | ||
#endif | ||
|
||
SIMDDetect SIMDDetect::detector; | ||
|
||
// If true, then AVX has been detected. | ||
bool SIMDDetect::avx_available_; | ||
bool SIMDDetect::avx2_available_; | ||
bool SIMDDetect::avx512F_available_; | ||
bool SIMDDetect::avx512BW_available_; | ||
// If true, then SSe4.1 has been detected. | ||
bool SIMDDetect::sse_available_; | ||
|
||
// Constructor. | ||
// Tests the architecture in a system-dependent way to detect AVX, SSE and | ||
// any other available SIMD equipment. | ||
// __GNUC__ is also defined by compilers that include GNU extensions such as | ||
// clang. | ||
SIMDDetect::SIMDDetect() { | ||
#if defined(X86_BUILD) | ||
#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 | ||
// the newer flags. | ||
sse_available_ = (ecx & 0x00080000) != 0; | ||
avx_available_ = (ecx & 0x10000000) != 0; | ||
if (avx_available_) { | ||
// There is supposed to be a __get_cpuid_count function, but this is all | ||
// there is in my cpuid.h. It is a macro for an asm statement and cannot | ||
// be used inside an if. | ||
__cpuid_count(7, 0, eax, ebx, ecx, edx); | ||
avx2_available_ = (ebx & 0x00000020) != 0; | ||
avx512F_available_ = (ebx & 0x00010000) != 0; | ||
avx512BW_available_ = (ebx & 0x40000000) != 0; | ||
} | ||
} | ||
#elif defined(_WIN32) | ||
int cpuInfo[4]; | ||
__cpuid(cpuInfo, 0); | ||
if (cpuInfo[0] >= 1) { | ||
__cpuid(cpuInfo, 1); | ||
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 | ||
#endif // X86_BUILD | ||
} | ||
/////////////////////////////////////////////////////////////////////// | ||
// File: simddetect.cpp | ||
// Description: Architecture detector. | ||
// Author: Stefan Weil (based on code from Ray Smith) | ||
// | ||
// (C) Copyright 2014, Google Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
#include "simddetect.h" | ||
#include "tprintf.h" | ||
|
||
#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(X86_BUILD) | ||
#if defined(__GNUC__) | ||
#include <cpuid.h> | ||
#elif defined(_WIN32) | ||
#include <intrin.h> | ||
#endif | ||
#endif | ||
|
||
SIMDDetect SIMDDetect::detector; | ||
|
||
// If true, then AVX has been detected. | ||
bool SIMDDetect::avx_available_; | ||
bool SIMDDetect::avx2_available_; | ||
bool SIMDDetect::avx512F_available_; | ||
bool SIMDDetect::avx512BW_available_; | ||
// If true, then SSe4.1 has been detected. | ||
bool SIMDDetect::sse_available_; | ||
|
||
// Constructor. | ||
// Tests the architecture in a system-dependent way to detect AVX, SSE and | ||
// any other available SIMD equipment. | ||
// __GNUC__ is also defined by compilers that include GNU extensions such as | ||
// clang. | ||
SIMDDetect::SIMDDetect() { | ||
#if defined(X86_BUILD) | ||
#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 | ||
// the newer flags. | ||
sse_available_ = (ecx & 0x00080000) != 0; | ||
avx_available_ = (ecx & 0x10000000) != 0; | ||
if (avx_available_) { | ||
// There is supposed to be a __get_cpuid_count function, but this is all | ||
// there is in my cpuid.h. It is a macro for an asm statement and cannot | ||
// be used inside an if. | ||
__cpuid_count(7, 0, eax, ebx, ecx, edx); | ||
avx2_available_ = (ebx & 0x00000020) != 0; | ||
avx512F_available_ = (ebx & 0x00010000) != 0; | ||
avx512BW_available_ = (ebx & 0x40000000) != 0; | ||
} | ||
} | ||
#elif defined(_WIN32) | ||
int cpuInfo[4]; | ||
__cpuid(cpuInfo, 0); | ||
if (cpuInfo[0] >= 1) { | ||
__cpuid(cpuInfo, 1); | ||
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 | ||
#endif // X86_BUILD | ||
} |
Oops, something went wrong.