## Developing OpenCL Code with an Intel x86 CPU

From: andrew cooke <andrew@...>

Date: Mon, 18 Jan 2010 09:37:23 -0300

While I was travelling last week I needed to fix a bug in some OpenCL
code, despite using a laptop without a supported GPU.

Luckily, it turns out that it's not necessary to have a GPU to develop
OpenCL.  Even if it's an Intel CPU - AMD's CPU support works just fine
(as far as I can tell) with Intel chips.

All that is necessary is to install the AMD OpenCL SDK -
http://developer.amd.com/gpu/ATIStreamSDK/Pages/default.aspx -
following the instructions here -
http://developer.amd.com/gpu/ATIStreamSDK/assets/ATI_Stream_SDK_Installation_Notes.pdf
(the installation notes are critical - it's a more complex install
than NVidia's).

Note that I could not get the demo software to compile, but that my
own code works just fine (the demo code requires a library that does
not seem to exist - perhaps it is included in the AMD/ATI GPU
drivers?).

I also needed to change my code slightly for a couple of reasons.
First, the AMD compiler appears to follow the OpenCL spec more
closely, so found some errors in my code.  Second, the AMD
implementation requires that a platform be chosen - see
http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71
Third, the processor type needs to be changed to CPU, so my code now
looks like:

printf("\nCreating context");
state->context = clCreateContextFromType(properties, CL_DEVICE_TYPE_GPU,
NULL, NULL, &err);
if (CL_DEVICE_NOT_FOUND == err) {
printf("\nTrying CPU instead of GPU (no images!)");
state->context = clCreateContextFromType(properties,
CL_DEVICE_TYPE_CPU,
NULL, NULL, &err);
}
if (err) goto cleanup;

(and as you can see above, a CPU does not support images).

Andrew