Commit b7f1edcc authored by Andrey Pavlenko's avatar Andrey Pavlenko Committed by OpenCV Buildbot

Merge pull request #1595 from alalek:cl_code_cleanup

parents dfbd5021 238550cd
...@@ -83,15 +83,6 @@ namespace cv ...@@ -83,15 +83,6 @@ namespace cv
DEVICE_MEM_PM //persistent memory DEVICE_MEM_PM //persistent memory
}; };
//Get the global device memory and read/write type
//return 1 if unified memory system supported, otherwise return 0
CV_EXPORTS int getDevMemType(DevMemRW& rw_type, DevMemType& mem_type);
//Set the global device memory and read/write type,
//the newly generated oclMat will all use this type
//return -1 if the target type is unsupported, otherwise return 0
CV_EXPORTS int setDevMemType(DevMemRW rw_type = DEVICE_MEM_R_W, DevMemType mem_type = DEVICE_MEM_DEFAULT);
// these classes contain OpenCL runtime information // these classes contain OpenCL runtime information
struct PlatformInfo; struct PlatformInfo;
...@@ -113,6 +104,7 @@ namespace cv ...@@ -113,6 +104,7 @@ namespace cv
std::vector<size_t> maxWorkItemSizes; std::vector<size_t> maxWorkItemSizes;
int maxComputeUnits; int maxComputeUnits;
size_t localMemorySize; size_t localMemorySize;
size_t maxMemAllocSize;
int deviceVersionMajor; int deviceVersionMajor;
int deviceVersionMinor; int deviceVersionMinor;
...@@ -199,23 +191,19 @@ namespace cv ...@@ -199,23 +191,19 @@ namespace cv
void CV_EXPORTS finish(); void CV_EXPORTS finish();
enum BINARY_CACHE_MODE
{
CACHE_NONE = 0, // do not cache OpenCL binary
CACHE_DEBUG = 0x1 << 0, // cache OpenCL binary when built in debug mode
CACHE_RELEASE = 0x1 << 1, // default behavior, only cache when built in release mode
CACHE_ALL = CACHE_DEBUG | CACHE_RELEASE, // cache opencl binary
};
//! Enable or disable OpenCL program binary caching onto local disk //! Enable or disable OpenCL program binary caching onto local disk
// After a program (*.cl files in opencl/ folder) is built at runtime, we allow the // After a program (*.cl files in opencl/ folder) is built at runtime, we allow the
// compiled OpenCL program to be cached to the path automatically as "path/*.clb" // compiled OpenCL program to be cached to the path automatically as "path/*.clb"
// binary file, which will be reused when the OpenCV executable is started again. // binary file, which will be reused when the OpenCV executable is started again.
// //
// Caching mode is controlled by the following enums // This feature is enabled by default.
// Notes
// 1. the feature is by default enabled when OpenCV is built in release mode.
// 2. the CACHE_DEBUG / CACHE_RELEASE flags only effectively work with MSVC compiler;
// for GNU compilers, the function always treats the build as release mode (enabled by default).
enum
{
CACHE_NONE = 0, // do not cache OpenCL binary
CACHE_DEBUG = 0x1 << 0, // cache OpenCL binary when built in debug mode (only work with MSVC)
CACHE_RELEASE = 0x1 << 1, // default behavior, only cache when built in release mode (only work with MSVC)
CACHE_ALL = CACHE_DEBUG | CACHE_RELEASE, // always cache opencl binary
};
CV_EXPORTS void setBinaryDiskCache(int mode = CACHE_RELEASE, cv::String path = "./"); CV_EXPORTS void setBinaryDiskCache(int mode = CACHE_RELEASE, cv::String path = "./");
//! set where binary cache to be saved to //! set where binary cache to be saved to
......
...@@ -98,9 +98,13 @@ inline cl_int getStringInfo(Functor f, ObjectType obj, cl_uint name, std::string ...@@ -98,9 +98,13 @@ inline cl_int getStringInfo(Functor f, ObjectType obj, cl_uint name, std::string
return err; return err;
param.resize(required); param.resize(required);
err = f(obj, name, required, &param.at(0), NULL); if (required > 0)
if (err != CL_SUCCESS) {
return err; err = f(obj, name, required, &param.at(0), NULL);
if (err != CL_SUCCESS)
return err;
param.resize(required - 1); // last symbol is '\0'
}
return CL_SUCCESS; return CL_SUCCESS;
}; };
......
...@@ -412,6 +412,9 @@ static int initializeOpenCLDevices() ...@@ -412,6 +412,9 @@ static int initializeOpenCLDevices()
openCLSafeCall(getScalarInfo(clGetDeviceInfo, device, CL_DEVICE_LOCAL_MEM_SIZE, localMemorySize)); openCLSafeCall(getScalarInfo(clGetDeviceInfo, device, CL_DEVICE_LOCAL_MEM_SIZE, localMemorySize));
deviceInfo.info.localMemorySize = (size_t)localMemorySize; deviceInfo.info.localMemorySize = (size_t)localMemorySize;
cl_ulong maxMemAllocSize = 0;
openCLSafeCall(getScalarInfo(clGetDeviceInfo, device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, maxMemAllocSize));
deviceInfo.info.maxMemAllocSize = (size_t)maxMemAllocSize;
cl_bool unifiedMemory = false; cl_bool unifiedMemory = false;
openCLSafeCall(getScalarInfo(clGetDeviceInfo, device, CL_DEVICE_HOST_UNIFIED_MEMORY, unifiedMemory)); openCLSafeCall(getScalarInfo(clGetDeviceInfo, device, CL_DEVICE_HOST_UNIFIED_MEMORY, unifiedMemory));
...@@ -452,7 +455,7 @@ static int initializeOpenCLDevices() ...@@ -452,7 +455,7 @@ static int initializeOpenCLDevices()
DeviceInfo::DeviceInfo() DeviceInfo::DeviceInfo()
: _id(-1), deviceType(DeviceType(0)), : _id(-1), deviceType(DeviceType(0)),
deviceVendorId(-1), deviceVendorId(-1),
maxWorkGroupSize(0), maxComputeUnits(0), localMemorySize(0), maxWorkGroupSize(0), maxComputeUnits(0), localMemorySize(0), maxMemAllocSize(0),
deviceVersionMajor(0), deviceVersionMinor(0), deviceVersionMajor(0), deviceVersionMinor(0),
haveDoubleSupport(false), isUnifiedMemory(false), haveDoubleSupport(false), isUnifiedMemory(false),
platform(NULL) platform(NULL)
......
...@@ -110,17 +110,12 @@ void ProgramCache::releaseProgram() ...@@ -110,17 +110,12 @@ void ProgramCache::releaseProgram()
cacheSize = 0; cacheSize = 0;
} }
static int enable_disk_cache = true || static bool enable_disk_cache = true;
#ifdef _DEBUG
false;
#else
true;
#endif
static String binpath = ""; static String binpath = "";
void setBinaryDiskCache(int mode, String path) void setBinaryDiskCache(int mode, String path)
{ {
enable_disk_cache = 0; enable_disk_cache = false;
binpath = ""; binpath = "";
if(mode == CACHE_NONE) if(mode == CACHE_NONE)
...@@ -128,7 +123,7 @@ void setBinaryDiskCache(int mode, String path) ...@@ -128,7 +123,7 @@ void setBinaryDiskCache(int mode, String path)
return; return;
} }
enable_disk_cache = enable_disk_cache =
#ifdef _DEBUG #if defined(_DEBUG) || defined(DEBUG)
(mode & CACHE_DEBUG) == CACHE_DEBUG; (mode & CACHE_DEBUG) == CACHE_DEBUG;
#else #else
(mode & CACHE_RELEASE) == CACHE_RELEASE; (mode & CACHE_RELEASE) == CACHE_RELEASE;
......
...@@ -45,26 +45,6 @@ ...@@ -45,26 +45,6 @@
#include "precomp.hpp" #include "precomp.hpp"
#ifdef __GNUC__
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
#define GCC_DIAG_STR(s) #s
#define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y)
# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
# define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
# define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
# else
# define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
# define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(warning GCC_DIAG_JOINSTR(-W,x))
# endif
#else
# define GCC_DIAG_OFF(x)
# define GCC_DIAG_ON(x)
#endif
#endif /* __GNUC__ */
using namespace std; using namespace std;
namespace cv namespace cv
...@@ -134,9 +114,6 @@ namespace cv ...@@ -134,9 +114,6 @@ namespace cv
build_options, finish_mode); build_options, finish_mode);
} }
#ifdef __GNUC__
GCC_DIAG_OFF(deprecated-declarations)
#endif
cl_mem bindTexture(const oclMat &mat) cl_mem bindTexture(const oclMat &mat)
{ {
cl_mem texture; cl_mem texture;
...@@ -234,9 +211,6 @@ namespace cv ...@@ -234,9 +211,6 @@ namespace cv
openCLSafeCall(err); openCLSafeCall(err);
return texture; return texture;
} }
#ifdef __GNUC__
GCC_DIAG_ON(deprecated-declarations)
#endif
Ptr<TextureCL> bindTexturePtr(const oclMat &mat) Ptr<TextureCL> bindTexturePtr(const oclMat &mat)
{ {
......
...@@ -45,6 +45,11 @@ ...@@ -45,6 +45,11 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencl_kernels.hpp" #include "opencl_kernels.hpp"
// TODO Remove this after HAVE_CLAMDBLAS eliminating
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
using namespace cv; using namespace cv;
using namespace ocl; using namespace ocl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment