diff --git a/api/tesseractmain.cpp b/api/tesseractmain.cpp index dc9fabf8581663d513b9913717ddad4de167d839..2d18e432433647139cdedb7a1462245af0e74d2a 100644 --- a/api/tesseractmain.cpp +++ b/api/tesseractmain.cpp @@ -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); diff --git a/configure.ac b/configure.ac index 13ddf9f891cf3bc66e7af2cca438d6420210ce29..6c7d33178a5968fb2fd88f31bcd98410878885b0 100644 --- a/configure.ac +++ b/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 diff --git a/opencl/opencl_device_selection.h b/opencl/opencl_device_selection.h index d28f2a278ee399a25853967e72c462804f77ceb6..64e317fff522a59fd28037cf9342177f063652c8 100644 --- a/opencl/opencl_device_selection.h +++ b/opencl/opencl_device_selection.h @@ -11,7 +11,12 @@ #include #include #include + +#ifdef __APPLE__ +#include +#else #include +#endif #define DS_DEVICE_NAME_LENGTH 256 diff --git a/opencl/openclwrapper.cpp b/opencl/openclwrapper.cpp index d103b7d858c192e57dd226cca4ae20fc2a8f1876..1b5ccfe0a5fb66ef07552a4bd3e301a67a5f052d 100644 --- a/opencl/openclwrapper.cpp +++ b/opencl/openclwrapper.cpp @@ -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. diff --git a/opencl/openclwrapper.h b/opencl/openclwrapper.h index e0425e9cc375d52b7b8043a8874ec35c91a856fb..976f070133e0cafc02e95392860f6420ccd15a27 100644 --- a/opencl/openclwrapper.h +++ b/opencl/openclwrapper.h @@ -138,7 +138,6 @@ #define USE_DEVICE_SELECTION 1 -#include "CL/cl.h" #include "opencl_device_selection.h" #ifndef strcasecmp