From 8af3629e9fef121ffca70f19120eb795b00383b3 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 11 Dec 2016 22:43:37 +0100 Subject: [PATCH] openmp: Fix OpenMP support * 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 --- api/Makefile.am | 5 +---- ccmain/Makefile.am | 1 + ccmain/par_control.cpp | 6 ++++-- configure.ac | 7 ------- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/api/Makefile.am b/api/Makefile.am index 9d20919b2..3bca53ba8 100644 --- a/api/Makefile.am +++ b/api/Makefile.am @@ -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 @@ -92,4 +90,3 @@ endif if ADD_RT tesseract_LDADD += -lrt endif - diff --git a/ccmain/Makefile.am b/ccmain/Makefile.am index e82c0031a..ac6cddcf3 100644 --- a/ccmain/Makefile.am +++ b/ccmain/Makefile.am @@ -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 \ diff --git a/ccmain/par_control.cpp b/ccmain/par_control.cpp index 7a7d0415d..82cd55c9a 100644 --- a/ccmain/par_control.cpp +++ b/ccmain/par_control.cpp @@ -18,9 +18,9 @@ /////////////////////////////////////////////////////////////////////// #include "tesseractclass.h" -#ifdef OPENMP +#ifdef _OPENMP #include -#endif // OPENMP +#endif // _OPENMP namespace tesseract { @@ -53,7 +53,9 @@ void Tesseract::PrerecAllWordsPar(const GenericVector& 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); diff --git a/configure.ac b/configure.ac index 2e8883d05..be08e538e 100644 --- a/configure.ac +++ b/configure.ac @@ -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])