Ahmad Siavosh
Ahmad Siavosh

Reputation: 676

An OpenCL program on non-compatible machines

I'm going to write an OpenCL program for running on different systems. Thus I'd like to know what will happen if :

I'd only like to know if the program runs correctly, and I completely understand that we'll lose the performance.

Thanks in advance :]

Upvotes: 1

Views: 238

Answers (2)

DarkZeros
DarkZeros

Reputation: 8410

That machine didn't have OpenCL capable GPUs, but an OpenCL capable CPU.

If your OpenCL adressess all types of devices (CL_DEVICE_ALL), then it will work perfectly.

That machine didn't have OpenCL capable GPUs and CPU.

  • If there is no device available:

OpenCL loads, but you will not have anything to run your kernels. So, simple run a Software code.

  • If there is no OpenCL driver:

It will not work, even not load (missing DLL at runtime). Unless you use a dynamic loading OpenCL (like CLEW).

In the case you use dynamic loading, still you will receive an error in the library loading. You have to handle this situation and put a failsafe CPU code.

I typically create a function with a prototype as the kernel(more or less), then directly call this method instead.


Anyway, it is possible to achieve it. I have many libraries that use OpenCL in the shadow, without any problem. They run in any kind of machine (No GPU, No OpenCL, multiple devices and CPU devices). No problem so far. Just do not suppose a OpenCL calls always return no error.

Upvotes: 1

Thomas
Thomas

Reputation: 3381

That machine didn't have OpenCL capable GPUs, but an OpenCL capable CPU.

Your OpenCL kernels will still work fine (notwithstanding driver bugs, of course) though it may be slower. Ideally you would have two kernel versions, one CPU and one GPU, to cater to both architectures. Note however that hardware limitations (and OpenCL version limitations, and vendor extensions) make this more complicated. In other words, it depends on what your code is doing. But in general it will work if you give even a modicum of attention to portability.

Of course, the best way to check is to test the code on a hardware sample representative of your client's machines. That way you can be sure.

That machine didn't have OpenCL capable GPUs and CPU.

Your OpenCL kernels will not run without OpenCL hardware. You will need some native fallback. But in practice CPU drivers are available for all modern operating systems and processors, so you can rely on a CPU driver being available if your user base is willing to install the driver if it doesn't already have one.

Upvotes: 1

Related Questions