# clBuildProgram hangs on some plateform - how to retrieve the CL capabilities?



## mjeulinl (Dec 18, 2013)

Hi Folks,

My problem started with an hangs of the "clBuildProgram" function on specific systems:
It occurs only on Win 8 (or greater) with the Intel HD Graphic devices (3000, 4000)[drivers up to date] while every thing works well on other systems.
The version of OpenCL is 1.1 and is supposed to be supported by the graphic chipsets.

I am currently reaching the point that make me wonder how to test the device in order to avoid that hang (I guess due to some driver problems).

So far I do the following:

```
// Check device availability & capability
{
  cl_bool isDeviceAvailable, isDeviceCompilerAvailale;
  if (!GetDeviceInfo(deviceIDs[deviceIndex], CL_DEVICE_AVAILABLE, isDeviceAvailable) || isDeviceAvailable != CL_TRUE ||
  !GetDeviceInfo(deviceIDs[deviceIndex], CL_DEVICE_COMPILER_AVAILABLE, isDeviceCompilerAvailale) || isDeviceCompilerAvailale != CL_TRUE)
  {
  if (verbose) Log::Warning("%s::%d OpenCL device %d::%d not available.", __FUNCTION__, __LINE__, platformIndex, deviceIndex);
  continue;
  }

  cl_device_exec_capabilities executionCapabilities;
  if (GetDeviceInfo(deviceIDs[deviceIndex], CL_DEVICE_EXECUTION_CAPABILITIES, executionCapabilities) || !(executionCapabilities & CL_EXEC_KERNEL))
  {
  if (verbose) Log::Warning("%s::%d OpenCL device %d::%d has not the required execution capabilities.", __FUNCTION__, __LINE__, platformIndex, deviceIndex);
  continue;
  }
}
```

None of this function tell me that the device has a lack of OpenCL support.
I am working on legacy code, but I though of the "Extensions" and "clImages" support but none seems to be used.

What tells me that I am missing something is that with the exact same configuration, GPU-Z considers the same device as unavailable (Do I miss some tests?).

I have also seen that similar problems has been corrected on your side (given last runs):
http://www.techpowerup.com/forums/t...n-lenovo-g500h-with-intel-and-amd-gpu.194261/
http://www.techpowerup.com/forums/threads/pc-hangs-when-opening-gpu-z.179520/


Thank you very much.
Kind regards,
M. J-L


----------



## W1zzard (Dec 18, 2013)

OpenCL is quite problematic. I've seen crashes in the driver (that will crash your own app), can be caught with __try or similar exception handlers.

Other crashes can't be avoided. I put a flag in the registry before initializing OpenCL and check for that flag on next start to see if last try failed.

Check with your debugger where it hangs (in Visual Studio you can see the stack trace, then right click and load symbols from Microsoft servers)


----------



## mjeulinl (Dec 19, 2013)

Thank you very much W1zzard.

I forgot to tell that the problem only occurs on client desktop and we were unfortunately not able to reproduce it on our hardware. The only thing I got able to was with one remote desktop to create a dmp which gave me the fact that it hangs on clBuildPrograms ; I guess I should have taken his OpenCL symbols at the same time...

I am gonna keep the way we do (similar to yours from if I understand well) with a cache and a timeout.

Thank you again.
Best regards,
Michaël Jeulin-L.


----------

