- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Some of our customers and I have the following problem originating from the detection of a valid OpenCL platform for OpenGL interop.
We have computers with dual NVidia and Intel GPUs, along with an Intel CPU. clGetPlatformIds() returns 3 platforms, in order: the Intel GPU, the NVidia GPU then the Intel CPU.
I have an OpenGL context running on the NVidia GPU. However, when I call clGetGLContextInfoKHR() with CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR and the NVidia OpenGL context handle, both Intel platforms (GPU and CPU) return a device (pointers on clGetGLContextInfoKHR have been obtained with clGetExtensionFunctionAddressForPlatform() for their respective platform).
My detection algorithm takes the first device returned, so in this case, this is the Intel GPU device. Of course, all this ends up causing a crash way later in my program when I call clCreateFromGLRenderbuffer() in order to create an OpenCL image from an NVidia OpenGL render buffer.
So my questions are:
- Why do the Intel platforms say that they can create an OpenCL device interopable with an NVidia OpenGL context when they obviously cannot?
- Is there a stable way to detect this case and get around the problem?
Thanks in advance.
Olivier
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello OlivierL,
Thanks for the issue report.
Can you provide detail on which OS, System processor, and which OpenCL implementations (runtime) are installed? Details of the system where the issue had been reproduced are useful.
In this case, can the detection logic pick the device or platform based on whether or not ‘Intel’ is in either the platform name or device name? I expect this to be a stable/good solution.
Relevant OpenCL API functions:
https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/clGetDeviceIDs.html
https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/clGetPlatformIDs.html
After the id is captured the names can be read with
https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/clGetPlatformInfo.html
CL_PLATFORM_NAME
https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/clGetDeviceInfo.html
CL_DEVICE_NAME
… captured names are then string compared.
In Intel® System Studio 2019 Windows OpenCL™ Tools… there is a great template sample that has a methodology for picking a device in a similar fashion. It’s in the File->New templates GPU or CPU templates written in C++. It also shows how to get device information from an automatically created context (clCreateContextFromType and clGetContextInfo). A selection example is in the FindAnOpenCLPlatform(…) function and CheckPreferredPlatformMatch(…) functions.
We’ve alerted our Intel® Graphics Compute Runtime for OpenCL™ Driver developers to see if there are implementation changes that can be made to better address the observations in the first question you have.
Any developers interested in following changes can review the change logs posted on the Intel® Graphics Compute Runtime for OpenCL™ Driver github portal. The releases page does a consistent and concise job of explaining changes: https://github.com/intel/compute-runtime/releases
-MichaelC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Michael,
Thank you for your thorough answer. My system is a Dell Alienware 17 R3 running Windows 10 Professional 1809.
There is an NVidia GeForce GTX 980M, along with an Intel HD Graphics 530. The CPU is an Intel Core i7-6820HK. All drivers are up-to-date and the latest release Intel OpenCL SDK is installed.
When I enumerate the OpenCL platforms and devices, I get 3 platforms:
* Platform 1 (with 1 device):
Name="NVIDIA CUDA"
Vendor="NVIDIA Corporation"
Version=1.2
- Device 1: Name="GeForce GTX 980M"
* Platform 2 (with 2 devices):
Name="Intel(R) OpenCL"
Vendor="Intel(R) Corporation"
Version=2.1
- Device 1: CPU: Name="Intel(R) Core(TM) i7-6820HK CPU @ 2.70GHz"
- Device 2: GPU: Name="Intel(R) HD Graphics 530"
- Platform 3 (with 1 device):
Name="Experimental OpenCL 2.1 CPU Only Platform"
Vendor="Intel(R) Corporation"
Version=2.1
- Device 1: CPU: Name="Intel(R) Core(TM) i7-6820HK CPU @ 2.70GHz"
Depending on the order of installation of drivers, the Intel platform can come first (for instance when a system update installs a new version of the Intel HD Graphics 530 driver.
The main problem is the fact that when I call clGetGLContextInfoKHR() on the Intel platform with argument CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR and an NVidia HDC + OpenGL HRC, I get an Intel device with turns out to not be compatible with the NVidia OpenGL.
For the moment, I have coded a logic based on the comparison of the OpenGL vendor name and the OpenCL platform vendor name in order to try to link the OpenGL device with the OpenCL device.
However, this looks like a hack rather than a robust solution to the problem.
This is even worse with an AMD graphic card where the various OpenGL and OpenCL device and platform names will woefully oscillate among "AMD", "Advanced Micro Devices" and "ATI" (sic!), so a logic based on names seems flimsy.
I don't know if a Windows HDC or HRC contains enough information to detect whether it is an Intel device or not, but if it is the case, it would be far better if clGetGLContextInfoKHR() did not return any Intel device from a non-Intel graphic device.
Olivier
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page