Skip to content

Commit

Permalink
Tweak architecture specific SIMD files for ease of compilation.
Browse files Browse the repository at this point in the history
This won't affect anything using the supplied build system. For
other projects that include tesseract within them, however, this
may make their life easier.

For example, I have an integration of Tesseract with Ghostscript,
in which tesseract is built as part of the Ghostscript build,
without using the tesseract build system.

The Ghostscript build system is makefile based, and has to work
on a range of make systems, including unix make, gnu make and
nmake. As such we have to avoid conditionals in the common
makefiles. It therefore becomes hard to build one set of files on
x86 systems, and another on (say) ARM systems.

Accordingly, this commit makes small tweaks to the architecture
specific files, so that they compile on EVERY platform; just they
only compile to anything useful on the appropriate platform.

Thus the makefiles can build all the files on all the systems, and
the preprocessor flags mean that the correct functions are actually
built.
  • Loading branch information
robinwatts committed May 12, 2020
1 parent cdebe13 commit a9b44ee
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/arch/dotproductavx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
///////////////////////////////////////////////////////////////////////

#if !defined(__AVX__)
#error Implementation only for AVX capable architectures
#endif
#if defined(__i686__) || defined(__x86_64__)
#error Implementation only for AVX capable architectures
#endif
#else

#include <immintrin.h>
#include <cstdint>
Expand Down Expand Up @@ -57,3 +59,5 @@ double DotProductAVX(const double* u, const double* v, int n) {
}

} // namespace tesseract.

#endif
8 changes: 6 additions & 2 deletions src/arch/dotproductfma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
///////////////////////////////////////////////////////////////////////

#if !defined(__FMA__)
#error Implementation only for FMA capable architectures
#endif
#if defined(__i686__) || defined(__x86_64__)
#error Implementation only for FMA capable architectures
#endif
#else

#include <immintrin.h>
#include <cstdint>
Expand Down Expand Up @@ -55,3 +57,5 @@ double DotProductFMA(const double* u, const double* v, int n) {
}

} // namespace tesseract.

#endif
8 changes: 6 additions & 2 deletions src/arch/dotproductsse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
///////////////////////////////////////////////////////////////////////

#if !defined(__SSE4_1__)
#error Implementation only for SSE 4.1 capable architectures
#endif
#if defined(__i686__) || defined(__x86_64__)
#error Implementation only for SSE 4.1 capable architectures
#endif
#else

#include <emmintrin.h>
#include <smmintrin.h>
Expand Down Expand Up @@ -79,3 +81,5 @@ double DotProductSSE(const double* u, const double* v, int n) {
}

} // namespace tesseract.

#endif
8 changes: 6 additions & 2 deletions src/arch/intsimdmatrixavx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
///////////////////////////////////////////////////////////////////////

#if !defined(__AVX2__)
#error Implementation only for AVX2 capable architectures
#endif
#if defined(__i686__) || defined(__x86_64__)
#error Implementation only for AVX2 capable architectures
#endif
#else

#include "intsimdmatrix.h"

Expand Down Expand Up @@ -340,3 +342,5 @@ const IntSimdMatrix IntSimdMatrix::intSimdMatrixAVX2 = {
};

} // namespace tesseract.

#endif
8 changes: 6 additions & 2 deletions src/arch/intsimdmatrixsse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
///////////////////////////////////////////////////////////////////////

#if !defined(__SSE4_1__)
#error Implementation only for SSE 4.1 capable architectures
#endif
#if defined(__i686__) || defined(__x86_64__)
#error Implementation only for SSE 4.1 capable architectures
#endif
#else

#include "intsimdmatrix.h"

Expand Down Expand Up @@ -102,3 +104,5 @@ const IntSimdMatrix IntSimdMatrix::intSimdMatrixSSE = {
};

} // namespace tesseract.

#endif

0 comments on commit a9b44ee

Please sign in to comment.