PDA

View Full Version : Way to know if OpenCL is installed



pelotoescogorciao
03-17-2011, 12:09 AM
Hi,

I got a problem. Imagine my app uses OpenCL but it requires to be compatible with old OSs and computers. The user might use an old driver without OpenCL suport.
Currently, if I link my program with the OpenCL.lib/OpenCL.dll then the dynamic-library reference will make my program impossible to be executed. It's neither possible to use "delayed DLL" calls, because Windows will emit a "Sorry can't find OpenCL.dll DLL" message box the first time you call a clXXXXXXX function.

To solve that, you should add an INLINED function in the OpenCL.h file to know if OpenCL is available. For instance, in case of Windows, it could be like this:



void inline int IsOpenCLInstalled ()
{
#ifdef WIN32
FILE *f = fopen("$WINDIR\\system32\\OpenCL.dll");
if ( f!=NULL )
{
fclose(f);
return 1;
}
return 0;
#else
/* perform OpenCL runtime detection for other OSs */
#endif
}


Thanks.

hotboy18
05-18-2011, 02:18 PM
Thanks for the straightforward solution.

santana
08-24-2011, 01:36 AM
This is a really informative comment. My problem has already been fixed... :D

david.garcia
08-24-2011, 04:16 AM
I would suggest dynamically opening the library with LoadLibrary()/dlopen() instead.

Gedolo
05-29-2012, 11:19 AM
It would be handy to try to ask the available OpenCL context versions.
If it fails no library.
If it returns something useful you can immediately start working with that.