Get Started with Intel® SDK for OpenCL™ Applications 2020 on Windows* OS

Published: 03/03/2020  

Last Updated: 03/02/2020

By Michael R Carroll

1. Overview

  • This article walks developers through:
    • Installation for the OpenCL™ developer tools in Intel® System Studio 2020. This is the latest update to Intel® SDK for OpenCL™ Applications on Windows* 10 OS.
    • Building and executing an OpenCL™ application with Microsoft Visual Studio* 2019 IDE. 
  • This article covers Intel® SDK for OpenCL™ Applications 2020 on Windows* 10 OS as:
  • FPGA devices are not covered here... see fpgasoftware.intel.com.
  • Users looking to interoperate with Intel® oneAPI DPCPP/SYCL* programs can review the article on interoperability.
  • The reference platform used in this guide is an Intel® NUC (NUC6i7KYK) with
    • Intel® Core™ i7-6770HQ Processor and Intel® Iris® Pro 580 Graphics.
    • Windows* 10 Enterprise OS 1809 17763.1039

2. Prerequisites

OpenCL™ implementations

The system needs an OpenCL™ implementation for an Intel® CPU or Intel® Graphics device. By default, a Windows* OS distribution may or may not already have OpenCL™ implementation(s) from Intel.

  • The SDK can function with both CPU and Intel® Graphics Technology implementations, or just one implementation.
  • Recent distributions of Windows* OS will install the Intel® Graphics Technology driver by default for systems with Intel® Graphics Technology. This driver package contains OpenCL™ CPU and Intel® Graphics Technology implementations. These OpenCL™ implementations may not be up to date to support all the developer features provided in Intel® SDK for OpenCL™ Applications. Options:
  • Intel® distributes CPU only OpenCL™ implementations. See the article on OpenCL™ Runtimes for Intel® Processors for more details.
  • Analysis and debug capabilities may only be available for Intel® Graphics Technology implementations. Analysis and debug features depend on the version of the SDK in use.

3. Install Tools

If a new OpenCL™ implementation has not been installed, SDK installation is still possible. Follow the installer dialog. If using Intel® System Studio 2020, here is the default install summary dialog:

OpenCL™ Tools install summary

The installer will take some time to apply plugins for the Microsoft Visual Studio* 2019 IDE. In Intel® SDK for OpenCL™ Applications 2020 initial release, the installer can also install the Intel® CPU Runtime for OpenCL™ Applications implementation to the system. The CPU Runtime will not install if an existing CPU Runtime is detected on the system.

 

4. Check Implementation(s)

Quickly confirming visible OpenCL™ implementations can ensure the system is setup properly. Examples of typical utilities used to examine the system are clinfo, gpu_caps_viewer, and GPU-Z.

clinfo is a typical program used in the OpenCL™ developer ecosystem to check system capabilities. Precompiled executables of clinfo for Windows* OS are posted on the Github* portal at the publication time of this article.

Some users in the Windows* OS OpenCL™ ecosystem prefer the gpu_caps_viewer and GPU-Z for platform discovery.

Such tools may report the detected OpenCL™ implementations, as well as device parameters associated with those implementations.

Use these parameters to better:

  • Dynamically allocate OpenCL™ memory objects 
  • Schedule OpenCL™ command queue items
  • Size global NDRanges and local workgroup sizes
  • Use OpenCL™ extensions available for the device, referencing the extension specifications on the Khronos OpenCL™ registry.

Assuming the SDK, CPU implementation, and Intel® Graphics Technology implementation have been installed... here’s what is displayed from a platform and device perspective:

  • The Intel(R) OpenCL platform has:
    • A CPU OpenCL™ target device implementation suitable for production usages.
    • An Intel® Graphics Technology OpenCL™ target device implementation suitable for production usages.
      • Users who have only Intel® CPU Runtime for OpenCL Applications installed will only see the CPU OpenCL™ target device.
    • This configuration could change (i.e. different platforms for different devices) given future updates or different runtime configurations. Please ensure your application is sufficiently flexible and tested on supported hardware.

Device Version reporting a NEO implementation like ‘OpenCL 2.1 NEO’ maps to the validation platform for Intel® SDK for OpenCL™ Applications 2020. Implementations without the NEO branch designation will likely not be able to interface with all Intel® SDK for OpenCL™ Applications 2020 features. This field shows the output of the  OpenCL™ API call clGetDeviceInfo(…) looking for CL_DEVICE_VERSION information.

Production OpenCL™ programs will similarly interrogate available OpenCL™ implementations.

 

 

5. Try Example Project

Intel® SDK for OpenCL™ Applications 2020 places template projects available for using in Visual Studio* 2019. To use a template project, select File->New->Project… In the New Project dialog, Visual C++ OpenCL™ template projects can be selected.

 

New->Project menu item

Template selection dialog

The CPU and Intel® Graphics Technology OpenCL™ Projects contain C++ host target source examples (.cpp files) that use the OpenCL™ host side C API. They also contain an OpenCL-C device target example (.cl files). These examples are helpful for developers new to heterogeneous and OpenCL™ programming. The Empty OpenCL™ Project contains an empty place holder C++ host target source (.cpp), and an empty placeholder device target source (.cl).

In this example, the Intel® Graphics Technology project is selected. Here are the automatically generated sources that it comes with:

Solution Explorer view of Intel® Graphics Technology template project

Note: Examining the properties of the GPUOpenCLProject1 can inform a user of project settings needed to build a non-template OpenCL™ application.

When Build->Build Solution is selected, this project will use the Visual Studio* 2019 compiler to build the C++ sources and the SDK’s offline compiler (ioc64.exe/ioc32.exe) to build the kernel (.cl). A status report from ioc build as well as the host side program build will be emitted to the 'Output' window pane. Here is the build result:

With this template, the Build Solution action will stage the executable and the OpenCL-C kernel (.cl) next to each other in the project’s target directory.

Troubleshoot: If the ioc64 or ioc32 "Proprocessing" step returns an error. Check your runtime deployment in accordance with section 4 of this document. If clinfo or a similar tool can not interrogate the system, consider redeploying the OpenCL™ runtimes. Check to ensure any OpenCL.dll files are from Khronos and 2.x capable, like the one included with the SDK. 1.2 or earlier limited OpenCL.dll offerings from non-Intel vendors will prohibit SDK functionality.

Launch the built executable with the Local Windows Debugger button in the top toolbar. To pause the application and review console output, consider adding a system(“pause”); to the bottom of the main function of the C++ host target source file. Example:

Add a pause to review shell output.

After Building the Solution and launching the Local Windows Debugger again. Here is the resulting output shell:

The program has been successfully built and has executed the sample OpenCL-C kernel on the Intel® Graphics Technology device.

 

6. More

*OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.

*Other names and brands may be claimed as the property of others

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.