Commit Graph

86 Commits

Author SHA1 Message Date
amitdo
a905548ed6 Autotools build: Remove the option 'USING_MULTIPLELIBS'
Libtool's convenience libraries should never be installed. Fixes #985.
2017-09-11 15:03:53 +03:00
Ray Smith
da03e4e910 Fixes from pull of cleanups: clang tidied, reviewed, fixed new bugs, undeleted needed code. Probably breaks the build, due to some inclusion of changes in utf8/32 conversion 2017-07-14 09:30:14 -07:00
Stefan Weil
1bbcbd89d0 opencl: Fix some compiler warnings
Remove several unused variables and fix some signed / unsigned mismatches.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-06-03 17:21:58 +02:00
Stefan Weil
1cf098dc2c opencl: Remove unused code
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-06-03 16:52:02 +02:00
Stefan Weil
df36c85f26 opencl: Remove more unused code
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-05-19 10:11:14 +02:00
Stefan Weil
5e3665c6ae Remove most libtiff dependencies
libtiff is no longer needed for OpenCL, so remove that dependency.

It is still suggested for Windows to redirect warning messages
from the tesseract executable to the console.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-05-12 10:15:35 +02:00
Stefan Weil
d53254e2f0 opencl: Add 'static' attributes for local functions and variables
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-05-04 19:32:36 +02:00
Stefan Weil
1c59914b61 Use Leptonica struct names L_Compressed_Data, Pix
The Tesseract project prefers that names, so fix the remaining exceptions.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-04-30 10:50:12 +02:00
Ray Smith
7a116ce8bb More formatting fixes from clang tidy 2017-04-28 13:38:32 -07:00
zdenop
10e04ffe99 Merge pull request #849 from stweil/opencl
opencl: Remove more unused functions and related code
2017-04-27 09:02:56 +02:00
Stefan Weil
582eaeba7d opencl: Remove more unused functions and related code
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-04-27 08:32:43 +02:00
Stefan Weil
1e11b16d73 opencl: Fix crash on hosts with no OpenCL platform
A Tesseract binary with OpenCL support can also run on a host without
any OpenCL platform, as it simply uses the normal CPU based code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-04-27 07:50:05 +02:00
Stefan Weil
e8ca29fb17 opencl: Remove unused function selectedDeviceIsNativeCPU
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-04-26 07:55:54 +02:00
Stefan Weil
bf9160cede opencl: Remove unused function pixConvertRGBToGray
Remove also the related OpenCL kernel code kernel_RGBToGray.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-04-26 07:55:54 +02:00
Stefan Weil
a3e0c10dc7 Remove unneeded code for old Leptonica versions
Tesseract requires Leptonica 1.74 or newer,
so that code is no longer needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-04-22 18:22:13 +02:00
Stefan Weil
c1a01d0c51 opencl: Fix some compiler warnings [-Wunused-function]
opencl_device_selection.h contains lots of code which is only used in
openclwrapper.cpp. This results in several compiler warnings:

opencl/opencl_device_selection.h:396:18: warning:
 ‘ds_status readProfileFromFile(ds_profile*, ds_score_deserializer, const char*)’ defined but not used [-Wunused-function]
opencl/opencl_device_selection.h:257:18: warning:
 ‘ds_status writeProfileToFile(ds_profile*, ds_score_serializer, const char*)’ defined but not used [-Wunused-function]
opencl/opencl_device_selection.h:196:18: warning:
 ‘ds_status profileDevices(ds_profile*, ds_evaluation_type, ds_perf_evaluator, void*, unsigned int*)’ defined but not used [-Wunused-function]
opencl/opencl_device_selection.h:90:18: warning:
 ‘ds_status initDSProfile(ds_profile**, const char*)’ defined but not used [-Wunused-function]
opencl/opencl_device_selection.h:70:18: warning:
 ‘ds_status releaseDSProfile(ds_profile*, ds_score_release)’ defined but not used [-Wunused-function]

Move that functions and all related code to openclwrapper.cpp.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-04-01 12:34:27 +02:00
Ray Smith
f566a45b30 clang-tidy changes from sync 2017-01-25 16:20:19 -08:00
zdenop
cb886a04ad Merge pull request #568 from stweil/opencl
opencl: Fix runtime crash when no device was found
2016-12-15 22:00:25 +01:00
zdenop
da4c064c2e Merge pull request #531 from stweil/guards
Fix header file guards and replace reserved identifiers
2016-12-15 08:29:32 +01:00
Stefan Weil
aa964b548a opencl: Fix runtime crash when no device was found
The native CPU is always available and needs an initialized profile.

Signed-off-by: Stefan Weil <stefan.weil@bib.uni-mannheim.de>
2016-12-12 20:16:08 +01:00
Ray Smith
d55f462c9c More clang-tidy from previous commits 2016-12-06 13:45:49 -08:00
Stefan Weil
70c6f1624c Fix #define guards in header files
Some guards were missing, others were not the first statement.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-04 15:43:03 +01:00
Stefan Weil
4897796d57 Replace reserved identifiers used in #define guards header files
Use macro names as suggested by the Google C++ Style Guide
(https://google.github.io/styleguide/cppguide.html#The__define_Guard).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-04 15:43:03 +01:00
Stefan Weil
2bb0d9a0bf opencl: Add missing checks for OpenCL failures
Fix also text for an existing check.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-03 22:34:02 +01:00
Stefan Weil
a389b7c8e9 opencl: Remove unneeded and potentially bad type casts
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-02 00:02:35 +01:00
Stefan Weil
dc066213c7 opencl: Replace NULL by nullptr
Remove also some unneeded nullptr assignments.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-01 14:50:20 +01:00
Stefan Weil
397bcc66d5 opencl: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-12-01 14:49:27 +01:00
Ray Smith
53003f9074 Formatting changes from clang_tidy on latest pull 2016-11-30 15:44:25 -08:00
Egor Pugin
7b5b16779a Merge pull request #494 from stweil/free
Simplify delete / free usage
2016-11-26 13:25:41 +03:00
Stefan Weil
ba6961e0f4 opencl: Fix OpenCL kernel code assertion for newer versions
With Debian package beignet-opencl-icd 1.2.1-1, Tesseract + OpenCL fails:

[DS] Profile file not available (tesseract_opencl_profile_devices.dat); performing profiling.

[DS] Device: "Intel(R) HD Graphics IvyBridge M GT2" (OpenCL) evaluation...
ASSERTION FAILED: sel.hasDoubleType()
  at file /home/geier/beignet/backend/src/backend/gen_insn_selection.cpp, function void gbe::ConvertInstructionPattern::convertDoubleToSmallInts(gbe::Selection::Opaque&, const gbe::ir::ConvertInstruction&, bool&) const, line 5269
Trace/breakpoint trap

Using a pure float expression (instead of double) fixes this issue.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-25 17:41:30 +01:00
Stefan Weil
786b482ef8 opencl: Format OpenCL kernel code
* Remove some empty lines to get a more uniform code
* Fix #endif handling at end of file

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-25 17:39:06 +01:00
Stefan Weil
0020fbc0bd opencl: Clean whitespace issues in OpenCL kernel code
* Remove whitespace at line endings
* Replace tabs by spaces

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-25 17:36:05 +01:00
Stefan Weil
6158f7eae2 Simplify calls of free
It is not necessary to check for null pointers.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-24 17:59:13 +01:00
Egor Pugin
644469595c Fix windows build. 2016-11-24 17:32:23 +03:00
zdenop
cdc2863b48 Merge pull request #466 from stweil/opencl
Fix some typos (found by codespell)
2016-11-22 09:11:24 +01:00
Stefan Weil
a7d2758876 opencl: Fix typo in name of local variable
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-22 08:25:43 +01:00
Stefan Weil
a0fc4320b7 Fix an unfixed merge conflict
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-22 08:24:44 +01:00
Ray Smith
9c7e99b041 Merged with commit 4ca6ba985b 2016-11-21 08:27:02 -08:00
Ray Smith
5913d7344f Added missing license headers 2016-11-18 15:53:11 -08:00
Stefan Weil
4ca6ba985b opencl: Fix type of parameter for clGetProgramInfo
CL_PROGRAM_NUM_DEVICES expects a cl_uint.

Passing size_t results in a wrong value for numDevices on hosts where
sizeof(cl_uint) != sizeof(size_t).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-12 22:12:54 +01:00
Stefan Weil
ec5b1bdfa3 opencl: Fix type of parameter for clGetContextInfo
CL_CONTEXT_NUM_DEVICES expects a cl_uint.

Passing size_t results in a wrong value for numDevices on hosts where
sizeof(cl_uint) != sizeof(size_t). This results in errors like these:

  Tesseract Open Source OCR Engine v3.05.00dev with Leptonica
  OpenCL error code is -44 at   when clCreateKernel kernel_HistogramRectAllChannels .
  OpenCL error code is -44 at   when clCreateKernel kernel_HistogramRectAllChannelsReduction .
  OpenCL error code is -48 at   when clSetKernelArg imageBuffer .
  ...

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-12 22:12:49 +01:00
Ray Smith
2c837dffc3 Result of clang tidy on recent merge 2016-11-07 10:46:33 -08:00
Stefan Weil
a1b9e98df5 opencl: Remove unused function getNumDeviceWithEmptyScore
This fixes compiler warnings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-07 09:41:05 +01:00
Stefan Weil
10886d3f91 opencl: Add missing argument for L_WARNING
gcc report:

In file included from /usr/include/leptonica/alltypes.h:36:0,
                 from /usr/include/leptonica/allheaders.h:34,
                 from openclwrapper.h:2,
                 from openclwrapper.cpp:11:
openclwrapper.cpp: In static member function 'static PIX* OpenclDevice::pixReadMemTiffCl(const l_uint8*, size_t, l_int32)':
/usr/include/leptonica/environ.h:442:68: warning: format '%d' expects a matching 'int' argument [-Wformat=]
              (void)fprintf(stderr, "Warning in %s: " a, __VA_ARGS__), \
                                                                    ^
/usr/include/leptonica/environ.h:427:61: note: in definition of macro 'IF_SEV'
       ((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))
                                                             ^
opencl/openclwrapper.cpp:1162:3: note: in expansion of macro 'L_WARNING'
   L_WARNING("tiff page %d not found", procName);
   ^

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-05 20:57:30 +01:00
Stefan Weil
90dad1f2ae opencl: Fix wrong implementation of function getNumDeviceWithEmptyScore
gcc report:

opencl_device_selection.h: In function 'ds_status getNumDeviceWithEmptyScore(ds_profile*, unsigned int*)':
opencl_device_selection.h:589:13: warning: value computed is not used [-Wunused-value]
       *num++;
             ^

This is caused by a buggy implementation which increases the value of num
instead of *num.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-05 20:57:30 +01:00
Stefan Weil
1a0aadabd3 opencl: Move declaration of MORPH_BC from .h to .cpp file
It is only used locally in opencl/openclwrapper.cpp.

For all other files which include openclwrapper.h, the compiler
complained about an unused static variable:

opencl/openclwrapper.h:175:16: warning:
 ‘MORPH_BC’ defined but not used [-Wunused-variable]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-01 20:15:29 +01:00
Stefan Weil
aea20224a1 opencl: Clean handling of lmask32, rmask32
Both arrays are only used in openclwrapper.cpp, so move them into that
file.

The first element of both arrays was unused. Remove it and fix the code
which reads the array elements accordingly. Sort this code, too.

These changes reduce the code size a little bit:

   text	   data	    bss	    dec	    hex	filename
2461743	   6676	2742784	5211203	 4f8443	1/api/tesseract (old)
2461599	   6676	2742784	5211059	 4f83b3	2/api/tesseract (new)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-31 09:56:59 +01:00
Stefan Weil
ab8209cbcb opencl: Fix mismatched new[] / free
valgrind report: Mismatched free() / delete / delete []

gpuInfo->mpArryDevsID is created by "new cl_device_id[1]",
so it must be destroyed by delete[].

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-29 16:51:48 +02:00
Stefan Weil
f67381a707 opencl: Fix compiler warning [-Wwrite-strings]
gcc report:

opencl/openclwrapper.cpp:3245:22: warning:
 deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-28 20:04:36 +02:00
Stefan Weil
bccf1c10f1 opencl: Fix delete operation
gcc report:

opencl/openclwrapper.cpp:3169:12: warning: deleting 'void*' is undefined

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-28 20:04:36 +02:00