Skip to content

Commit

Permalink
Remove opencl_device_selection.h
Browse files Browse the repository at this point in the history
Always use OpenCL device selection if OpenCL is enabled.

This fixes a regression which was introduced by commit
5c6a57b which removed
the definition for USE_DEVICE_SELECTION.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jan 9, 2019
1 parent 62b8575 commit e0fc4f2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 58 deletions.
7 changes: 0 additions & 7 deletions src/api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,14 @@ const char* TessBaseAPI::Version() {
* and returns sizeof(cl_device_id)
* otherwise *device=nullptr and returns 0.
*/
#ifdef USE_OPENCL
#ifdef USE_DEVICE_SELECTION
#include "opencl_device_selection.h"
#endif
#endif
size_t TessBaseAPI::getOpenCLDevice(void **data) {
#ifdef USE_OPENCL
#ifdef USE_DEVICE_SELECTION
ds_device device = OpenclDevice::getDeviceSelection();
if (device.type == DS_DEVICE_OPENCL_DEVICE) {
*data = new cl_device_id;
memcpy(*data, &device.oclDeviceID, sizeof(cl_device_id));
return sizeof(cl_device_id);
}
#endif
#endif

*data = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/opencl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AM_CPPFLAGS += $(OPENCL_CFLAGS) \
-I$(top_srcdir)/src/ccmain

noinst_HEADERS = \
openclwrapper.h oclkernels.h opencl_device_selection.h
openclwrapper.h oclkernels.h

noinst_LTLIBRARIES = libtesseract_opencl.la

Expand Down
48 changes: 0 additions & 48 deletions src/opencl/opencl_device_selection.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/opencl/openclwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#ifdef USE_OPENCL

#include <cstdio>
#include <cstring> // for memset, strcpy, ...
#include <vector>

#include "errcode.h" // for ASSERT_HOST
#include "opencl_device_selection.h"

GPUEnv OpenclDevice::gpuEnv;

Expand Down
24 changes: 23 additions & 1 deletion src/opencl/openclwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,29 @@
**************************************************************************/

#ifdef USE_OPENCL
#include "opencl_device_selection.h"

#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

struct TessDeviceScore;

// device type
enum ds_device_type {
DS_DEVICE_NATIVE_CPU = 0,
DS_DEVICE_OPENCL_DEVICE
};

struct ds_device {
ds_device_type type;
cl_device_id oclDeviceID;
char* oclDeviceName;
char* oclDriverVersion;
// a pointer to the score data, the content/format is application defined.
TessDeviceScore* score;
};

#ifndef strcasecmp
#define strcasecmp strcmp
Expand Down

0 comments on commit e0fc4f2

Please sign in to comment.