How to Run OpenCL in Microsoft VS 2008 using AMD APP SDK

This guide explains how to run OpenCL applications in MSVS using AMD Accelerated Parallel Processing SDK formerly known as ATI Stream SDK. I have used the following software for this guide:

  • MSVS 2008 Professional Edition
  • AMD APP SDK v2.4 [Download Link]

vs-opencl

Note:This guide is also valid for older versions of AMD APP SDK (v2.3) or the ATI Stream SDK as it was called then. The only change required is to replace every occurrence of “AMDAPPSDK” with “ATISTREAMSDK”. Rest of the guide remains the same.

Step 1: Set Environment Variables

Make sure that following variables are present in the Environment Variables list and their values are set accordingly. Installing AMD APP SDK automatically set these Environment Variables and adds them to Path variable. This step is just to ensure the proper settings before proceeding to the next step.

The AMDAPPSDKROOT variable must be set to:

  • C:\Program Files\AMD APP\ (for 32-bit systems)
  • C:\Program Files (x86)\AMD APP\ (for 64-bit systems)

The AMDAPPSDKSAMPLESROOT variable must be set to:

  • C:\Users\\Documents\AMD APP\ (for Windows Vista or Windows 7)
  • C:\Documents and Settings\\My Documents\AMD APP\ (for Windows XP)

The path variable must include:

  • $(AMDAPPSDKROOT)\bin\x86 (for 32-bit systems)
  • $(AMDAPPSDKROOT)\bin\x86_64 (for 64-bit systems)
  • $(AMDAPPSDKSAMPLESROOT)\bin\x86 (for 32-bit systems)
  • $(AMDAPPSDKSAMPLESROOT)\bin\x86_64 (for 64-bit systems)

If the default configuration was not used while installing AMD APP SDK, modify the value to the location specified during the installation.

system_properties

Step 2: Create an Empty Project

Open VS 2008 and create a new Visual C++ Empty Project and add the c/c++ source files to this project.

vs_empty_project

Step 3: Setting Project Properties

Project Properties → C/C++ → Additional Include Directories

Include $(ATISTREAMSDKROOT)/include for OpenCL headers. Optionally, you can also include $(ATISTREAMSDKSAMPLESROOT)/include for SDKUtil headers.

Project Properties Linker Additional Library Directories

Additional Library Directories must include $(ATISTREAMSDKROOT)/lib/x86 for OpenCL libraries on a 32 Bit Systems and x86_64 for 64 Bit Systems. For SDKUtil libraries, include $(ATISTREAMSDKSAMPLESROOT)/lib/x86 or x86_64 depending upon your system configuration.

Project Properties Linker Input Additional Dependencies

Additional Dependencies must include OpenCL.lib. Optionally, you can include SDKUtil.lib if use of SDK Utility Libraries is intended.

That’s it, you are ready to create your first OpenCL project in Visual Studio. If you face any error message feel free to ask in comments section below.