Fix OpenCL device detection when some OpenCL platform has no devices#15813
Merged
opencv-pushbot merged 1 commit into3.4from Nov 6, 2019
unknown repository
Merged
Fix OpenCL device detection when some OpenCL platform has no devices#15813opencv-pushbot merged 1 commit into3.4from unknown repository
opencv-pushbot merged 1 commit into3.4from
unknown repository
Conversation
alalek
reviewed
Oct 30, 2019
| static void getDevices(std::vector<cl_device_id>& devices, cl_platform_id platform) | ||
| { | ||
| cl_uint numDevices = 0; | ||
| CV_OCL_DBG_CHECK(clGetDeviceIDs(platform, (cl_device_type)Device::TYPE_ALL, 0, NULL, &numDevices)); |
Member
There was a problem hiding this comment.
There is one more similar check in Context::Impl ctor.
Author
There was a problem hiding this comment.
I changed Context::Impl constructor as well, but I doubt it fixes anything.
alalek
reviewed
Nov 5, 2019
modules/core/src/ocl.cpp
Outdated
| cl_int status = clGetDeviceIDs(platform, (cl_device_type)Device::TYPE_ALL, 0, NULL, &numDevices); | ||
| if (status != CL_DEVICE_NOT_FOUND) // Not an error if platform has no devices | ||
| { | ||
| CV_OCL_CHECK_RESULT(status, |
Member
There was a problem hiding this comment.
Original checks are "debug"-only.
Keep them "debug": CV_OCL_DBG_CHECK_RESULT
It's not an error if some OpenCL platform has no devices. This makes
OpenCL device detection work correctly in the following scenario:
$ OPENCV_OPENCL_DEVICE=:GPU: ./opencv_test_dnn
OpenCV version: 4.1.2-dev
OpenCV VCS version: 4.1.2-80-g467748ee98-dirty
Build type: Debug
Compiler: /usr/bin/g++ (ver 7.4.0)
Parallel framework: pthreads
CPU features: SSE SSE2 SSE3 *SSE4.1 *SSE4.2 *FP16 *AVX *AVX2 *AVX512-SKX?
Intel(R) IPP version: ippIP AVX2 (l9) 2019.0.0 Gold (-) Jul 24 2018
OpenCL Platforms:
AMD Accelerated Parallel Processing
Portable Computing Language
CPU: pthread-AMD Ryzen 7 2700X Eight-Core Processor (OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-znver1)
NVIDIA CUDA
dGPU: GeForce GTX 1080 (OpenCL 1.2 CUDA)
Current OpenCL device:
Type = dGPU
Name = GeForce GTX 1080
Version = OpenCL 1.2 CUDA
Driver version = 430.26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's not an error if some OpenCL platform has no devices. This makes
OpenCL device detection work correctly in the following scenario:
Note the empty "AMD Accelerated Parallel Processing" platform above. It will cause an exception in getDevices() and OpenCL device detection failure even when there are other OpenCL devices available.