Quick Getting Started Guide for creating Intel® OpenCL SDK application in Microsoft Visual Studio*

Published: 07/05/2018  

Last Updated: 12/04/2020

By Joel Lin

Quick Getting Started Guide for creating Intel® OpenCL SDK applicaiton in Microsoft Visual Studio*


Intel® OpenCL™ SDK contains Micrsoft Visual Studio* Extension for Visual Studio 2017 and 2019. 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* 2017 IDE. Intel® SDK for OpenCL™ Applications is a standalone package. You are also encouraged to migrate openCL application to oneAPI DPC++, please visit this migration guide for further details.  

Figure 1. New a OpenCL project.

Within Microsoft Visual Studio* IDE, you can easily switch to Intel® DPC++ compiler, you can still create a new OpenCL project API from Visual Studio Files menu to create a new OpenCL Project if you install the Intel® OpenCL SDK.

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 -> CPU/GPU OpenCL Project for Windows. Following the UI flow can help generate sample platform host codes and OpenCL kernel device codes. The initial sample codes are to demonstrate using CPU/GPU to assign the result of “add" operation on two 1024x1024 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 an example of OpenCL image scaling kernel codes using Sampler hardware.

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

__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 APIs can be profiled by Intel® VTune™ Profiler

You can use Intel® VTune™ Profiler to profile OpenCL application to understand the openCL kernel execution time in VTune's timeline panel. 

Figure 2. Use VTune Profiler to profile OpenCL APIs. 


There are some updates and changes for Intel® OpenCL tools, Runtime and you can visit the links OpenCL Release notes, Developer Guide to find more.


Product and Performance Information


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