Skip to content

Commit

Permalink
openmp: Fix OpenMP support
Browse files Browse the repository at this point in the history
* Add OPENMP_CXXFLAGS for ccmain.
* Replace OPENMP_CFLAGS by OPENMP_CXXFLAGS.
* Always use _OPENMP for conditional compilation.
* Remove OPENMP as there is already _OPENMP.
* Include omp.h conditionally.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Dec 11, 2016
1 parent 71269e7 commit 8af3629
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
5 changes: 1 addition & 4 deletions api/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ tesseract_LDADD = libtesseract.la

tesseract_LDFLAGS = $(OPENCL_LDFLAGS)

if OPENMP
tesseract_LDADD += $(OPENMP_CFLAGS)
endif
tesseract_LDADD += $(OPENMP_CXXFLAGS)

if T_WIN
tesseract_LDADD += -lws2_32
Expand All @@ -92,4 +90,3 @@ endif
if ADD_RT
tesseract_LDADD += -lrt
endif

1 change: 1 addition & 0 deletions ccmain/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AM_CPPFLAGS += \
-I$(top_srcdir)/textord -I$(top_srcdir)/opencl

AM_CPPFLAGS += $(OPENCL_CPPFLAGS)
AM_CPPFLAGS += $(OPENMP_CXXFLAGS)

if VISIBILITY
AM_CPPFLAGS += -DTESS_EXPORTS \
Expand Down
6 changes: 4 additions & 2 deletions ccmain/par_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
///////////////////////////////////////////////////////////////////////

#include "tesseractclass.h"
#ifdef OPENMP
#ifdef _OPENMP
#include <omp.h>
#endif // OPENMP
#endif // _OPENMP

namespace tesseract {

Expand Down Expand Up @@ -53,7 +53,9 @@ void Tesseract::PrerecAllWordsPar(const GenericVector<WordData>& words) {
}
// Pre-classify all the blobs.
if (tessedit_parallelize > 1) {
#ifdef _OPENMP
#pragma omp parallel for num_threads(10)
#endif // _OPENMP
for (int b = 0; b < blobs.size(); ++b) {
*blobs[b].choices =
blobs[b].tesseract->classify_blob(blobs[b].blob, "par", White, NULL);
Expand Down
7 changes: 0 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,7 @@ if test "$enable_embedded" = "yes"; then
fi
# check whether to build OpenMP support
AM_CONDITIONAL([OPENMP], false)
AC_OPENMP
AS_IF([test "x$OPENMP_CFLAGS" != "x"],
[AM_CONDITIONAL([OPENMP], true)
AM_CPPFLAGS="$OPENMP_CXXFLAGS $AM_CPPFLAGS"
AC_DEFINE([OPENMP], [], [Defined when compiled with OpenMP support])]
)
# check whether to build opencl version
AC_MSG_CHECKING([--enable-opencl argument])
Expand Down

0 comments on commit 8af3629

Please sign in to comment.