Quick Getting Started Guide for Intel® SDK for OpenCL™ Applications Integration in Intel® System Studio 2019

By Joel Lin,

Published:07/05/2018   Last Updated:07/05/2018

Quick Getting Started Guide for Intel® OpenCL SDK integration in Intel System Studio 2019

Introduction

Intel® OpenCL™ SDK has been integrated into Intel® System Studio 2019 now. This is a quick getting- started guide showing  how you can work on OpenCL program development within the SDK's integration environment of Microsoft Visual Studio 2015 IDE. You might also notice that there is a standalone version of Intel SDK for OpenCL application. Visual Studio IDE Integration for standalone version is slightly different from Intel System Studio 2019.  

Image Placeholder

Figure 1. Visit Tools menu-item to find Code Builder for OpenCL API. Several Intel® Tools are integrated in the same place.

After installed Intel System Studio 2019 nicely integrates with Microsoft Visual Studio IDE, You can easily switch to Intel® C++ compiler, efficiently setup Intel® performance libraries and quickly lunch Intel® VTune Amplifier to perform optimization and profiling tasks. Now <Intel Code Builder for OpenCL API> is also added with these integrations to facilitate all the developers’ user experience. Like the figure shows above, you can find Intel Code Builder for OpenCL API from Tools menu to make sure the integration works successfully .

The workflow to create an OpenCL project.

To start to your OpenCL project, click menu File->New->Project in Visual Studio and select Visual C++ -> OpenCL -> CodeBuilder Project for Windows. It will pops up the new wizard UI to help you setup to generate sample platform codes and OpenCL kernel codes. Check the figure 2 below.

Image Placeholder
CaptionFigure 2. Click the finish to generate one OpenCL sample code.

The more details you can check the online getting started guide pointed by Intel OpenCL SDK. Like how to check what kind of OpenCL devices your current platform supports and the links for the OpenCL Release notes, Developer Guide, Code Samples etc.

Once you created the Visual Studio project by using the new wizard, focus on OpenCL kernel codes and the data how you plan to feed into the kernel codes. The initial sample codes the wizard UI helps create are to demonstrate using GPU to assign the result of “Add” operation on two buffers A, B into a buffer C. Most of the host codes of this sample can be reused in testing your own OpenCL kernel development.

Let’s check what other tools provided by Intel SDK for OpenCL. In general, it provides OpenCL kernel debug session, OpenCL Application analysis, OpenCL API Debugger.

A simple image scaling OpenCL kernel using Sampler hardware.

Here we introduce an OpenCL kernel implements image scaling functionality by using GPU’s sampler. OpenCL kernel codes implementation is listed below

const sampler_t sampler = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_CLAMP | CLK_FILTER_LINEAR;
__kernel void image_scaling(__read_only image2d_t sourceImage,
                            __write_only image2d_t destinationImage,
                            const float widthNormScalar,
                            const float heightNormScalar)
{
    int2 coordinate = (int2)(get_global_id(0), get_global_id(1));
    float2 normalizedCoordinate = convert_float2(coordinate) * (float2)(widthNormScalar, heightNormScalar);
    float4 pixel = read_imagef(sourceImage, sampler, normalizedCoordinate);
    write_imagef(destinationImage, coordinate, pixel);
}

CLK_FILTER_LINEAR uses bilinear interpolation from sampler hardware therefore the operation will be more efficient than the implementation on general purpose processor.

OpenCL kernel Debug, Application analysis, OpenCL APIs inspections

Intel Code Builder for OpenCL also supports the fine-grained usages. Check the figure 3 below to find out where you can access these key usages.

Image Placeholder
Figure 3. The access path to these usages provided by Intel Code Builder for OpenCL.

To test CL kernels with different configurations separately and the possibility to test the combination kernels usage by arranging the order of workflows. It can also perform source-level debug capability for OpenCL kernel development.

Image Placeholder
Figure 4. Enable the debugging features for kernel source-level debug capability.

The Application Analysis of Code Builder also records several performance related information including the loading/storing/unloading duration for memory objects and the runtime duration for each CL APIs. More than that, you can review the CL attributes of memory objects and execution time for CL kernels.

Image Placeholder

Figure 5. Enable Application Analysis to track the running time for each CL APIs.

Image Placeholder
Figure 6. Enable OpenCL API Debugger to open multiple debugging view, such as Trace View and etc.

 

For the detailed functionalities, you can refer to Developer Guide for Intel® SDK for OpenCL™ Applications.

See also

 

https://software.intel.com/articles/getting-started-with-opencl-code-builder

/content/www/us/en/develop/articles/opencl-drivers.html

https://software.intel.com/en-us/articles/use-vtune-amplifier-system-2016-for-helloopencl-gpu-application-analysis

 

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804