Stefan Weil
57ff90687d
simd: Check whether the OS supports FMA, AVX, ...
...
The previous check was only for the MS compiler, but not for gcc and clang.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2020-02-23 16:34:35 +01:00
Stefan Weil
a1a139cbd2
Replace AVX_OPT, ..., AVX macros by HAVE_AVX, ... and clean related code
...
- Replace AVX_OPT, AVX2_OPT, FMA_OPT, SSE41_OPT
- Replace AVX, AVX2, FMA, SSE4_1
- Write new HAVE_AVX, HAVE_AVX2, HAVE_FMA, HAVE_SSE4_1 into config_auto.h
- Put related conditionals in Makefile.am in one place
This makes the code clearer and fixes a log message in
IntSimdMatrixTest.AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-28 17:51:37 +01:00
Stefan Weil
a166efaad6
automake: Flat build for src/arch
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-26 16:20:46 +01:00
Egor Pugin
2a37f5dd62
Update includes to use <>.
2019-10-29 14:50:11 +03:00
amitdo
2f8884a64e
Fix autotools build
2019-10-28 21:23:58 +02:00
amitdo
e1bae15547
Fix #include path of public headers
2019-10-28 19:10:30 +02:00
Stefan Weil
994ec697d8
Remove member functions STRING::string and StringParam::string
...
They were redundant because there exist member functions 'c_str' which do the same.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-23 08:33:08 +02:00
Stefan Weil
408d6e8b72
simd: Check OSXSAVE bit before calling _xgetbv
...
Both checks are needed for AVX, AVX2 and FMA checks.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-09-15 19:35:37 +02:00
Stefan Weil
00cff79f7f
simd: Check whether the OS supports FMA, AVX, ...
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-08-16 22:51:17 +02:00
Stefan Weil
61eab60fe3
arch: Reduce number of include files for dot product functions
...
dotproductavx.h and dotproductsse.h declared only two functions.
Move those declarations to dotproduct.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-12 23:18:00 +02:00
Stefan Weil
2d5b166876
Add dot product implementation for Intel FMA (double = tessdata_best)
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-07-12 23:18:00 +02:00
Stefan Weil
fefd521a49
Add dot product implementation using std::inner_product
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-05-31 12:07:17 +02:00
zdenop
539673b503
fix '--enable-visibility' build
2019-05-25 11:13:33 +02:00
amitdo
fab9a54981
Remove unneeded 'SUBDIRS=' from 3 Makefile.am files
2019-04-04 19:31:39 +02:00
Stefan Weil
98346c2cd4
Modernize and format code
...
The code was modernized using clang-tidy with "modernize-use-using".
The modified files were then formatted using clang-tidy with
"google-readability-braces-around-statements", then clang-format
was applied.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-04-03 21:02:23 +02:00
Stefan Weil
b6bfb20f1d
Improve readability of conditional code
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-03-26 12:35:56 +01:00
Stefan Weil
a0fd90583b
Modernize C++ code using auto
...
The modifications were done using this command:
run-clang-tidy-8.py -header-filter='.*' -checks='-*,modernize-use-auto' -fix
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-03-26 07:55:08 +01:00
Stefan Weil
ef4d5b2e69
Optimize calculation of dot product for double vectors with AVX
...
This improves the performance with best models and should also
make training faster.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-02-20 17:45:38 +01:00
Stefan Weil
b49806766e
Fix AVX2 support for Windows builds with MSC
...
It was never detected, so the existing code for AVX2
was compiled but never used.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-30 11:40:17 +01:00
Stefan Weil
564482db30
Fix selection of IntSimdMatrix method
...
Commit d36231e3e4
did not distinguish
between AVX and AVX2, so AVX2 code was enabled for IntSimdMatrix
even when only AVX was supported.
This resulted in an illegal instruction.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-20 22:13:04 +01:00
Stefan Weil
502bb624c2
More optimisations for IntSimdMatrix
...
* Move IntDotProductSSE. That allows inlining of the code.
* Improve IntDotProductSSE by moving some instructions.
* Remove unused num_input_groups_ from IntSimdMatrix.
* Re-order elements in IntSimdMatrix to avoid padding.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
95606398f5
Clean code for IntSimdMatrix
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
7fc7d28dd0
Compile files for AVX, AVX2 or SSE only when needed
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
a9a1035e55
Move IntSimdMatrixNative from IntSimdMatrix to unittest
...
It is only used for the unit test.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
d36231e3e4
Set best or user selected IntSimdMatrix
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
605b4d66c7
Replace dynamically allocated IntSimdMatrix instances by constants
...
Two header files are no longer needed and could be removed.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
26be7c5d2e
Use constructor with parameters for IntSimdMatrix
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
e237a38405
Add const attributes to IntSimMatrix multiplier
...
IntSimMatrix no longer contains variable members.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
7c70147701
Move shaped weights from IntSimMatrix to WeightMatrix
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 21:34:37 +01:00
Stefan Weil
9adf6e442b
Revert 59fb3370bb
(-ffast-math)
...
It breaks intsimdmatrix_test.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-14 17:56:35 +01:00
Stefan Weil
8a6fa452dc
Fix build for architectures without CPUID
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-03 09:32:36 +01:00
Stefan Weil
d9600cd82e
Fix and simplify SIMD tests
...
The tests for SSE and AVX must only be done if the correct compiler
flags were used.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-01-01 11:19:17 +01:00
Stefan Weil
2ccc5810f3
Add check whether compiler supports -march=native flag
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-12-05 20:13:28 +01:00
Stefan Weil
f0a4d04187
Add config variable for selection of dot product function
...
All also a C++ implementation with more aggressive compiler options
which is optimized for the CPU where the software was built.
It is now possible to select the function used for the dot product
with -c dotproduct=FUNCTION where FUNCTION can be one of those values:
* auto selection based on detected hardware (default)
* generic C++ code with default compiler options
* native C++ code optimized for build host
* avx optimized code for AVX
* sse optimized code for SSE
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-12-01 00:19:28 +01:00
zdenop
b527b37825
Merge pull request #2097 from stweil/namespace
...
SIMDDetect: Use tesseract namespace and format code
2018-12-01 00:02:18 +01:00
Stefan Weil
1910b1a72b
SIMDDetect: Use tesseract namespace and format code
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-11-30 23:36:39 +01:00
Stefan Weil
66d3275d0b
IntSimdMatrixSSE: Remove unused include statement and simplify code
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-11-30 23:14:11 +01:00
Stefan Weil
048eb34934
Add missing static attribute to local inline functions
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-11-30 23:14:11 +01:00
Stefan Weil
b73370aac9
Remove unneeded test for nullptr
...
IntSimdMatrix::GetFastestMultiplier never returns a nullptr.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-11-30 23:14:11 +01:00
Stefan Weil
59fb3370bb
Use -ffast-math for calculation of dot product
...
This reduces the code size for intsimdmatrixavx2 from 2700 to 2668
and slightly improves the performance for fast models with AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-11-30 22:52:04 +01:00
Stefan Weil
fda3ba9009
IntSimdMatrixSSE: Fix comment
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-11-30 22:13:32 +01:00
Zdenko Podobný
01cf7402df
add header guard
2018-09-22 18:44:26 +02:00
Stefan Weil
20cd6d2328
dotproductsse: Fix include statements
...
The changes are based on an analysis done with include-what-you-use.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-06-25 19:15:37 +02:00
Stefan Weil
1a151781ea
Clean some include statements
...
The changes are based on an analysis done with include-what-you-use.
Replace also some standard header files by the corresponding
standard C++ header files.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-06-23 21:15:54 +02:00
Stefan Weil
11f2b12fda
Remove arch header files from public API
...
The arch header files are only used in the Tesseract code.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-06-21 21:46:48 +02:00
Stefan Weil
c1c87d73ee
Require tesseract/ for API header files (fixes potential name conflicts)
...
The tesseract/ subdirectory is no longer automatically added to the
include path of the compiler. Therefore old code which used code like
#include "capi.h"
must now change that to
#include "tesseract/capi.h"
This avoids name conflicts with header files from other projects.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-06-17 22:01:19 +02:00
Stefan Weil
fcdcba70f4
Remove some header files from public API
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-06-10 16:19:58 +02:00
Alexander Zaitsev
0248c7ff9d
Rename all C-style headers (e.g. <stdio.h>) to C++ style (<cstdio>).
2018-05-20 00:52:04 +03:00
Stefan Weil
4f9493c409
Partial fix for autotools configuration after source tree reorganisation
...
This should fix "make" and "make training".
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-04-25 21:33:28 +02:00
Stefan Weil
dabf3c299f
Fix file endings
...
Text files should end with a LF, but not additional empty lines.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-04-25 19:35:33 +02:00