mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-23 18:49:08 +08:00
fix OpenCL build on OSX 10.9; add info about OpenCL to 'tesseract -v'
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@921 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
9de80e0a06
commit
8b3e590123
@ -50,6 +50,29 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, " %s\n", versionStrP);
|
||||
lept_free(versionStrP);
|
||||
|
||||
#ifdef USE_OPENCL
|
||||
cl_platform_id platform;
|
||||
cl_uint num_platforms;
|
||||
cl_device_id devices[2];
|
||||
cl_uint num_devices;
|
||||
cl_int err;
|
||||
char info[256];
|
||||
int i;
|
||||
|
||||
fprintf(stderr, " OpenCL info:\n");
|
||||
clGetPlatformIDs(1, &platform, &num_platforms);
|
||||
fprintf(stderr, " Found %d platforms.\n", num_platforms);
|
||||
clGetPlatformInfo(platform, CL_PLATFORM_NAME, 256, info, 0);
|
||||
fprintf(stderr, " Platform name: %s.\n", info);
|
||||
clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 256, info, 0);
|
||||
fprintf(stderr, " Version: %s.\n", info);
|
||||
clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 2, devices, &num_devices);
|
||||
fprintf(stderr, " Found %d devices.\n", num_devices);
|
||||
for (i = 0; i < num_devices; ++i) {
|
||||
clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 256, info, 0);
|
||||
fprintf(stderr, " Device %d name: %s.\n", i+1, info);
|
||||
}
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -194,7 +217,6 @@ int main(int argc, char **argv) {
|
||||
tprintf("Tesseract Open Source OCR Engine v%s with Leptonica\n",
|
||||
tesseract::TessBaseAPI::Version());
|
||||
|
||||
|
||||
FILE* fin = fopen(image, "rb");
|
||||
if (fin == NULL) {
|
||||
fprintf(stderr, "Cannot open input file: %s\n", image);
|
||||
|
18
configure.ac
18
configure.ac
@ -57,8 +57,8 @@ AC_SUBST(GENERIC_VERSION)
|
||||
AM_CONDITIONAL(MINGW, false)
|
||||
AM_CONDITIONAL(GRAPHICS_DISABLED, false)
|
||||
|
||||
OPENCL_HDR_PATH=""
|
||||
OPENCL_LIB=""
|
||||
OPENCL_INC="/opt/AMDAPP/include"
|
||||
OPENCL_LIBS="-lOpenCL"
|
||||
#############################
|
||||
#
|
||||
# Platform specific setup
|
||||
@ -74,6 +74,14 @@ case "${host_os}" in
|
||||
solaris*)
|
||||
LIBS="-lsocket -lnsl -lrt -lxnet"
|
||||
;;
|
||||
powerpc-*-darwin*)
|
||||
OPENCL_LIBS=""
|
||||
OPENCL_INC=""
|
||||
;;
|
||||
*-*-darwin*)
|
||||
OPENCL_LIBS="-framework OpenCL"
|
||||
OPENCL_INC=""
|
||||
;;
|
||||
*)
|
||||
# default
|
||||
;;
|
||||
@ -126,15 +134,15 @@ fi
|
||||
# check whether to build opencl version
|
||||
AC_MSG_CHECKING(--enable-opencl argument)
|
||||
AC_ARG_ENABLE([opencl],
|
||||
[ --enable-opencl enable opencl build (default=no)],
|
||||
[ --enable-opencl enable opencl build (default=no)],
|
||||
[enable_opencl=$enableval],
|
||||
[enable_opencl="no"])
|
||||
AC_MSG_RESULT($enable_opencl)
|
||||
AM_CONDITIONAL([USE_OPENCL], [test "$enable_opencl" = "yes"])
|
||||
if test "$enable_opencl" = "yes"; then
|
||||
AC_SUBST([AM_CPPFLAGS], [-DUSE_OPENCL])
|
||||
AC_SUBST([OPENCL_HDR_PATH],["/opt/AMDAPP/include"])
|
||||
AC_SUBST([OPENCL_LIB],["-lOpenCL"])
|
||||
AC_SUBST([OPENCL_HDR_PATH],[$OPENCL_INC])
|
||||
AC_SUBST([OPENCL_LIB],[$OPENCL_LIBS])
|
||||
fi
|
||||
|
||||
# check whether to build tesseract with -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
|
@ -11,7 +11,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#define DS_DEVICE_NAME_LENGTH 256
|
||||
|
||||
|
@ -2518,8 +2518,8 @@ PERF_COUNT_START("ThresholdRectToPixOCL")
|
||||
int requestedOccupancy = 10;
|
||||
int numWorkGroups = numCUs * requestedOccupancy;
|
||||
int numThreads = block_size*numWorkGroups;
|
||||
size_t local_work_size[] = {block_size};
|
||||
size_t global_work_size[] = {numThreads};
|
||||
size_t local_work_size[] = {(size_t) block_size};
|
||||
size_t global_work_size[] = {(size_t) numThreads};
|
||||
|
||||
/* map imagedata to device as read only */
|
||||
// USE_HOST_PTR uses onion+ bus which is slowest option; also happens to be coherent which we don't need.
|
||||
|
@ -138,7 +138,6 @@
|
||||
|
||||
#define USE_DEVICE_SELECTION 1
|
||||
|
||||
#include "CL/cl.h"
|
||||
#include "opencl_device_selection.h"
|
||||
|
||||
#ifndef strcasecmp
|
||||
|
Loading…
Reference in New Issue
Block a user