Few questions (CL_DEVICE_TYPE_CPU, CL_DEVICE_TYPE_GPU, CL_DEVICE_TYPE_ALL)

context = clCreateContextFromType( cprops, CL_DEVICE_TYPE_ALL, NULL, NULL, &err );

I have code to load precompiled kernels to blur image (or to do any other effects with images) and I started to analyze the code. I searched what is meanning of the CL_DEVICE_TYPE_ALL and I have found the following table:

https://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clGetDeviceIDs.html

which contains also CL_DEVICE_TYPE_CPU, and CL_DEVICE_TYPE_GPU.

Now I got a thought and ask myself these wuestions:

  1. Why I use here the flag CL_DEVICE_TYPE_ALL, do I really need to keep it in the context? Could I use just
context = clCreateContextFromType( cprops, CL_DEVICE_TYPE_GPU, NULL, NULL, &err );
  1. Why OpenCL needs the flag CL_DEVICE_TYPE_CPU how could it be used? Does OpenCL can use the kernel for CPU? I ask this question because last days I think what would be faster/better for me to make the blur actions and similar things. Would it be faster to use 4 core / 6 core or even 8 core CPU (eg. AMD FX 8320) or to use my cheap GPU (NVIDIA GT 640 128-bit 4GDDR)? Unfortunately I am just beginner in C/C++ so I am not sure how hard is it to learn to programme for more cores. However here is my last question:

  2. Could I use OpenCL to perform the job on 4 cores of CPU or even to devide the job between CPU and GPU? For example I would take image and separate it for 5 strips of same height, and I would use the kernel gaussian.bin to erform the blur actions on the strips and then splice the strips back together to created the blured image.

I don’t know answers for these questions and would be glad if you can explain them. I am using old version of OpenCL, I am still running Windows XP 32 bit

If you have an OpenCL driver for CPU installed then CL_DEVICE_TYPE_CPU devices appear, so yes, it is a useful flag to have.

You might, for example, try for a GPU device, and only if one is not found, try for a CPU device.

On Windows, both Intel and AMD have CPU drivers that either come with their GPU driver, or can be installed. On Mac OS X, Apple has provided a CPU driver since OS X 10.6. On Android most of the drivers are CPU (from what I read).