OCL: cleanup unused code in case of undef HAVE_OPENCL#4102
OCL: cleanup unused code in case of undef HAVE_OPENCL#4102alalek wants to merge 3 commits intoopencv:masterfrom
Conversation
|
@alalek, this is useful patch, but I would suggest to decrease the amount of conditional branches. Basically, since each OpenCL runtime call is cdecl function (i.e. it leaves it to the caller side to clean the stack) it would be enough to redirect each OpenCL call to a stub function that would throw an exception. But there is very little chance that we even get to one of those functions, since useOpenCL() would give you false. I would probably also add special protection in ocl::Kernel::run() and few other functions. All the other #ifdef's are unnecessary and just make the code maintenance more difficult. |
|
The main idea is to completely disable any OpenCL code to:
I know "#if" decision for this as presented here (I tried do not use multi-line macros because they are very bad things for debugging). This way is used widely in OpenCV. |
|
@alalek, there can not be in principle any wrong logic until you actually call "clSomething". In principle, I would like to eliminate most of conditional branches in OpenCV code. This is one of the goal of the universal intrinsics BTW. And in fact I do not link the idea to have #ifdef HAVE_OPENCL everywhere in OpenCV code, but at least it's hidden inside a macro. Here explicit #ifdef's look very ugly. So, please, refactor it. |
WIP
Related issue: http://code.opencv.org/issues/4409 #5022
Binary size reduced for ~1.2Mb (world, Linux-64, without IPP optimizations: ~8%)