mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-20 15:59:11 +08:00
Use SIMD instructions for DotProductNative
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
12e0fb4e01
commit
f0fb6809e3
@ -144,6 +144,9 @@ noinst_HEADERS += src/arch/simddetect.h
|
||||
noinst_LTLIBRARIES += libtesseract_native.la
|
||||
|
||||
libtesseract_native_la_CXXFLAGS = -O3 -ffast-math
|
||||
if OPENMP_SIMD
|
||||
libtesseract_native_la_CXXFLAGS += -fopenmp-simd -DOPENMP_SIMD
|
||||
endif
|
||||
if MARCH_NATIVE_OPT
|
||||
libtesseract_native_la_CXXFLAGS += -march=native -mtune=native
|
||||
endif
|
||||
|
@ -186,6 +186,8 @@ esac
|
||||
|
||||
AX_CHECK_COMPILE_FLAG([-march=native], [arch_native=true], [arch_native=false], [$WERROR])
|
||||
AM_CONDITIONAL([MARCH_NATIVE_OPT], $arch_native)
|
||||
AX_CHECK_COMPILE_FLAG([-fopenmp-simd], [openmp_simd=true], [openmp_simd=false], [$WERROR])
|
||||
AM_CONDITIONAL([OPENMP_SIMD], $openmp_simd)
|
||||
|
||||
AC_ARG_WITH([extra-includes],
|
||||
[AS_HELP_STRING([--with-extra-includes=DIR],
|
||||
@ -284,7 +286,7 @@ m4_define([MY_CHECK_FRAMEWORK],
|
||||
])
|
||||
if test "$my_cv_framework_$1"="yes"; then
|
||||
AC_DEFINE(AS_TR_CPP([HAVE_FRAMEWORK_$1]), 1,
|
||||
[Define if you have the $1 framework])
|
||||
[Define if you have the $1 framework])
|
||||
AS_TR_CPP([FRAMEWORK_$1])="-framework $1"
|
||||
AC_SUBST(AS_TR_CPP([FRAMEWORK_$1]))
|
||||
fi]
|
||||
|
@ -21,6 +21,9 @@ namespace tesseract {
|
||||
// Computes and returns the dot product of the two n-vectors u and v.
|
||||
double DotProductNative(const double *u, const double *v, int n) {
|
||||
double total = 0.0;
|
||||
#if defined(OPENMP_SIMD)
|
||||
#pragma omp simd reduction(+:total)
|
||||
#endif
|
||||
for (int k = 0; k < n; ++k) {
|
||||
total += u[k] * v[k];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user