以下文章中缺少图片,请在百度网盘下载word观看
https://download.csdn.net/download/qccz123456/10567835
https://pan.baidu.com/s/1sloNYyx
Intel® Code Builder for OpenCL™API for Microsoft Visual Studio*
Intel® SDK for OpenCL™ applications for Windows* OfflineCompiler plug-in for Microsoft Visual Studio* IDE enables you to develop OpenCLapplications with Visual Studio IDE.
The plug-in supports the following features:
· New project templates
· New OpenCL code file (*.cl)template
· Syntax highlighting
· Types and functions auto-completion
· Offline compilation and build of OpenCL kernels
· LLVM code view
· Assembly code view
· Program IR generation
· Selection of target OpenCL device - CPU or Intel Graphics
NOTE
To work with the plug-in features, create an OpenCL code projecttemplate or convert an existing project into the OpenCL code project.
See Also
· ConvertingExisting Projects into OpenCL Code Projects
· DebuggingOpenCL™ Kernels on CPU
· DebuggingOpenCL™ Kernels on GPU
· APIDebugging for GPU and CPU
Code Editing and Building
· ConfiguringMicrosoft Visual Studio* IDE
· ConvertingExisting Project into OpenCL™ Project
· UsingOpenCL™ Build Properties
· SelectingTarget OpenCL™ Device
· Generatingand Viewing Assembly Code
· Generatingand Viewing LLVM Code
· GeneratingIntermediate Program Binaries in Visual Studio*
· ConfiguringOpenCL™ Build Options
Configuring Microsoft VisualStudio* IDE
To configure the OpenCL™ API Offline Compilerplug-in for Microsoft Visual Studio* IDE, do the following:
1. In the Visual Studiosoftware select Project > Properties.
2. In the C/C++ > General propertypage, under Additional Include Directories, enter the full path tothe directory where the OpenCL code header files are located:
$(INTELOCLSDKROOT)\include
3. In the Linker > General propertypage, under Additional Library Directories, enter the full path tothe directory where the OpenCL code run-time import library file is located.For example, for 64-bit application:
$(INTELOCLSDKROOT)\lib\x64
4. In the Linker > Input propertypage, under Additional Dependencies, enter the name of the OpenCLICD import library file OpenCL.lib.
Converting an Existing Projectinto an OpenCL™ Project
OpenCL™ API Offline Compiler plug-in forMicrosoft Visual Studio* IDE enables you to convert a standard C/C++ project toan OpenCL project and vice versa.
To convert your project, do the following:
1. Right-click theproject you want to convert in the Solution Explorer.
2. In the project menuclick Convert to a project for OpenCL API.
OpenCL™ New Project Wizard
OpenCL™ New Project wizard is a plug-in forMicrosoft Visual Studio* software enables developing Windows* and Android*OpenCL applications with Visual Studio IDE either from scratch (empty project)or based on template projects.
The wizard kit supports the followingfeatures:
· Creatingan Empty OpenCL™ Project for Windows
· Createa New OpenCL™ Project from OpenCL Project Template for Windows*
· Createa New OpenCL™ Project from OpenCL Project Template for Android*
Creating an Empty OpenCL™ Projectfor Windows
To create an empty OpenCL™ project forMicrosoft Visual Studio* IDE, do the following:
1. Go to File > New > Project...
2. Select OpenCLtemplates from the Templates tree view.
3. Select EmptyOpenCL Project for Windows.
4. Fill the Name, Location,and Solution name fields and click OK
Create a New OpenCL™ Project fromOpenCL Project Template for Windows*
To create an OpenCL™ template project forWindows platforms in Microsoft Visual Studio* IDE, do the following:
1. Go to File > New > Project...
2. Select OpenCLtemplates from the Templates tree view.
3. Select CodeBuilder Project for Windows.
4. Fill the Name,Location, and Solution name fields and click OK.
5. In the CodeBuilder wizard for OpenCL API dialog, you can select the basicsettings for the behavior of the OpenCL application and kernel. The parametersthat can be set are platform name, device type, kernel type (images or buffermanipulation), build options, and local work group size behavior. Each fieldhas a short tool-tip explanation.
6. Click Finish tocreate the default template project or click Next to openthe Advanced Settings screen enabling you to set some advancedoptions like whether to enable profiling queue and the kernel's argumentsmemory source type. For CPU device type, you can also set the out-of-orderexecution mode and debug mode for the kernel.
7. Click Finish tocreate the default template project or click Previous toreturn the Basic Settings screen.
Building OpenCL™ Project
To build the solution using OpenCL™ APIOffline Compiler plug-in for Microsoft Visual Studio* IDE, click Build > BuildSolution.
When building solution, Intel OpenCL compilerautomatically builds attached OpenCL kernels. See the build result in the Output builddialog of the Microsoft Visual Studio IDE.
Using OpenCL™ Build Properties
OpenCL Build properties page in the Microsoft VisualStudio* IDE enables you to set compilation flags and change target device whenbuilding an OpenCL kernel. To change the settings, do the following:
1. Go to Project > Properties.
2. Click the Intel SDK for OpenCL Applications entryunder the Configuration Properties group.
3. Modify properties and click OK.
NOTE
The Intel® SDK for OpenCL™ Applications entryexists for OpenCL projects with *.cl source files attached. If the entrydoes not exist, convert an existing standard project into the OpenCL project.
SeeAlso
Creating an EmptyOpenCL™ Project
Converting ExistingProject into OpenCL Project
Selecting Target OpenCL™ Device
OpenCL™ API Offline Compiler plug-in forMicrosoft Visual Studio* IDE enables you to choose the target device whenbuilding your OpenCL code:
· Intel CPU
· Intel® Graphics
· Intel CPU onExperimental OpenCL 2.1 Platform
The default device is CPU.
To choose a target device, do the following:
1. Go to Project > Properties.
2. Click ConfigurationProperties > Intel SDK for OpenCL Applications > General.
3. Change the Device optionaccording your needs.
4. Click OK.
Generating and Viewing AssemblyCode
OpenCL™ API Offline Compiler plug-in forMicrosoft Visual Studio* IDE enables generating assembly representation of theOpenCL code. To enable generating and viewing the assembly code, do thefollowing:
1. Go to Project > Properties.
2. Click ConfigurationProperties > OpenCL Code Builder > General.
3. Modify the propertiesas needed, and click OK.
After the build, you can open the generatedassembly file in the Visual Studio editor by double-clicking the message inthe Output view.
Generating and Viewing LLVM Code
OpenCL™ API Offline Compiler plug-in forMicrosoft Visual Studio* IDE enables generating LLVM representation of the OpenCLcode. To enable generating and viewing LLVM code, do the following:
1. Go to Project > Properties.
2. Click ConfigurationProperties > Intel SDK for OpenCL Applications > General.
3. Change the GenerateLLVM Code option to Yes.
After the build, you can open the generatedLLVM file in the Visual Studio editor by double-clicking the message inthe Output view.
Generating Intermediate ProgramBinaries in Visual Studio*
OpenCL™ API Offline Compiler plug-in forMicrosoft Visual Studio* IDE generating program binaries of the OpenCL code.
An application can use generated programbinaries to create program from binaries later (clCreateProgramFromBinary(...)). To generate intermediate program binaries, do the following:
1. Go to Project > Properties.
2. Click ConfigurationProperties > Intel SDK for OpenCL Applications > General.
3. Change the CreateProgram Binary option to Yes.
4. Click OK.
Configuring OpenCL™ Build Options
OpenCL™ API Offline Compiler plug-in forMicrosoft Visual Studio* IDE enables configuring build options for the OpenCLcode. To configure the build options, do the following:
1. Go to Project > Properties.
2. Click ConfigurationProperties > Intel SDK for OpenCL Applications > General.
3. Add build options intothe Additional build options line.
4. Click OK.
Kernel Development Framework
Kernel Development Framework is nativeintegrated development environment in the Microsoft Visual Studio* IDE thatenables you to build and analyze OpenCL™ kernels.
The framework supports Intel® Architectureprocessors, Intel Processor Graphics, and remote development on Android*devices. The tool provides full offline OpenCL language compilation, whichincludes:
· OpenCL syntax checker
· Cross-platformcompilation
· Low Level VirtualMachine (LLVM) viewer
· Assembly code viewer
· Intermediate programbinary Generator
· The feature alsoprovides a way to assign input to the kernel, test the correctness, and analyzekernel performance based on group size, build options, and target device.
· KernelDevelopment Framework Session
· Buildingand Compiling OpenCL™ Program
Kernel Development FrameworkSession
Work in the Kernel Development Framework is managed throughsessions. To create, build, or analyze an OpenCL™ kernel you need to create asession.
A session contains:
· A file with an OpenCL program
· Build artifacts:
·
o Generated LLVM code
o Assembly code
o Intermediate binary files
· OpenCL kernels with assigned variables
· Analysis reports
There are two methods for creating a session, depending on thefile type that you are working on:
· For a *.cl file, you need to create asession
· For a *.exe file, you need to generatea session
See Also
Creating Sessionfrom Existing OpenCL Code
Code BuilderConfiguration Toolbar
Code Builder Build Toolbar
To show the toolbar go to: VIEW > Toolbars andmake sure that the Code Builder Build option is checked.
You can use the Code Builder Build toolbarto perform basic operations on sessions such as:
· Create new session
· Open session
· Save session
· Build session
· Compile session
· Open session'ssettings dialog
· Generate a new sessionfrom an existing OpenCL application
· Generate C++ code froman existing session
Creating a Session
Creating a Sessionfrom Existing OpenCL Code
Generate a Sessionfrom an OpenCL Application
Creating a New Session
This topic explains how to create and build a session.
To create a new session:
1. Go to CODE-BUILDER > OpenCL Kernel Development > NewSessions or click the New Session button in the toolbar.
2. Specify the session name, path to the folder to store thesession file and the content of the session (can be either empty session orwith pre-defined OpenCL code).
3. Click Done.
Once the session is created, the new session appears inthe Code Builder Session Explorer view.
If you don't see the Code Builder Session Explorer dialog,go to: CODE-BUILDER > OpenCL Kernel Development > Windows > CodeBuilder Session Explorer.
To build the session:
Right-click the session in the Code Builder SessionExplorer and select BuildSession.
After the build is complete, you can see the following newitems:
· the Build Artifacts folder inthe session shows the related build artifacts that were created during thesession build
· the Kernels folder in thesession shows the kernel that ran during the session build.
· The Code Builder Analysis Input paneappears with the Input configuration and the Kernel Arguments
Creating a Session from ExistingOpenCL Code
The Kernel Development Framework enables youto create a session from an existing project that contains OpenCL™ code files.If you have a project in Microsoft Visual Studio* that contains such files(s),you can do the following:
· Right-click the OpenCLfile and select Create Code Builder Session
·
· A new Session iscreated and becomes available in the Code Builder Session Explorer dialog.
Generate a Session from an OpenCLApplication
The Generate Session featureenables you to generate a KDF session from an existing working executable fileof an application that uses OpenCL APIs. This enables you to rerun a singlekernel.
To create a KDF Session:
1. In Microsoft* Visual Studio*, go to CODE-BUILDER > OpenCL KernelDevelopment > Generate Session.
2. Select an application and its working directory.
3. Optionally, you can configure the following:
o Add application arguments in the Arguments field
o Change the output directory of the created sessions in the Output Directory field.
o Set the number of configurations generated per kernel in theNumber of instance per NDRange.
By default, this is set to 1. In this case if there is more than one instanceof NDRange with the same global and local workgroup sizes, only oneconfiguration is created.
o Load the created sessions to the KDF. By default, this checkboxis checked.
Session Generator Features
· The Session Generator generates regular KDF sessions. It recordsany data needed to rerun the kernels: *.cl input file, build option, deviceselection (CPU/GPU), assigned arguments and their data, global/local groupsizes, target architecture (32/64 bit)
· The created variables are saved locally within the session.
· Every use of clBuildProgram API in the application creates aunique session file
· Programs that are not used in the application do not create asession file
· Every use of clEnqueueNDRangeKernel API in the applicationcreates a kernel configuration (see Creatinga New Analysis Configuration section).