The most important thing you need to develop an OpenCL application is to be able to compile and run your code. If that is what you need to know, then you’re in the right place! Unlike the CUDA development platform, OpenCL is an open standard and is supported on various devices. Anything from multi-core CPUs to integrated GPUs, to dedicated GPUs, and even some more exotic devices like DSPs and FPGAs. Because of this diversity, the development environment is a bit fragmented. There are OpenCL SDKs available from various vendors including Intel, AMD, and NVIDIA. What to do!

Grab the Intel SDK

It doesn’t matter what platform you’re developing on. Go ahead and grab the Intel SDK. It can be downloaded here: In case that link ever dies, you can always search for ‘download Intel OpenCL SDK’ to find the latest release. When installing, the SDK will integrate itself into visual studio, assuming you’re using Windows as your development platform. One thing to note is that the first few times I tried installing it, the installation was unsuccessful. I was only able to successfully install it when choosing to integrate it with Visual Studio 2010 pro only, and not Visual Studio 2012 express. Not sure if that’s a common problem or not, but just wanted to mention it in case you have any trouble getting the installation to succeed.

Why the Intel SDK

There are several reasons I chose the Intel SDK. The SDK is mature, and supports OpenCL 1.2 at the time of this writing. Not only that, but if you and you’re customers are interested in high performance computing, it is frankly unlikely that they’re using an AMD CPU. Also, code created with the Intel SDK tends to perform find on all platforms, whereas AMD’s SDK tends to only perform well for AMD products.

Creating your first program

Now that the SDK is installed, you’ll want to crack open Visual Studio. Go to File->New Project. You should see an entry, Visual C++ -> OpenCL. Select this option and create your project. You can uncheck ‘create empty project’ so it’ll at least add a file for you. Now, before you compile, let’s get some super-simple OpenCL code. Again, I’m going to defer to Intel’s example code. Once you download this, open the CapsBasic folder, and open the CapsBasic.cpp file. Copy and replace the contents with the source file in your project with the contents of CapsBasic.cpp. Then simply compile and run your code. It’s just that easy!

Taking a look at what’s happening

CapsBasic is really just enumerating the OpenCL platforms on your device, selecting one, and then enumerating all the OpenCL devices on the selected platform. If that doesn’t make any sense, don’t worry, we’ll get into that more in later articles. For now, you just need to know that to get details of a specific device in your computer, change the line in the source code that sets the required_platform_subname variable. For example, you can change that to “NVIDIA” and it’ll select an NVIDIA device in your computer and print out the OpenCL capabilities of that device. That’s it for now. You should now be able to easily compile and run OpenCL code on your computer!