Home

User Manual - Intel® SDK for OpenCL™ Applications 2014

image

Contents

1. SobelFilter_O cbreport 12 512 0 40 05 Average execution timetmsy 0 703660 Best Configuration Worst Configuration Gx Gy Gz Lx si 512 0 Ile 312 M gi 512 0 51 ale M gi 512 0 sl S12 0 1 1 1 1 1 1 1 y 512 512 0 1 1 0 Average execution timeimsi 2 1162 10 10 10 10 10 10 10 Measurmentfiterations Total hMedian Standard Deviation Mininmur Maxinnum 0 il d 5 Jl 512 0 Jl 512 0 Variables View 0 787904 0 765334 Lz Iterations Total Queue Submit Execution 0 767904 O 0006152 O 0076256 0 706325 2 1162 0000467 O 0049952 2 10125 1 43124 00003212 O 0061612 1 41708 1 1569 00004068 0 00365 1 14365 1 00209 00004088 00034748 0 990143 0 93767 0000408 M0033872 0 926253 0 925757 00003504 00035624 0 914164 Submit Queue Execution 0 0078250 O 00NG1s2 0 766325 0 00292 0 000584 0 752922 00513801 00140444 00004964 0 034652 0 753944 0 891768 0 891706 U fooadd Of 6066 0 705332 1 64 0 10 1 i465 0 10 0 002628 0000292 OF4sied 0 049932 0002044 Oepsd4dd 0 049932 0 002044 0 791028 0 004088 0 000SE4 O f54256 0 00292 O 000584 0 74698 0 002628 0 000292 0 751608 0 921932 0 000438 0 004029 0 904908 0 937116 00003212 0 0034164 0 925674 The Variable View table enables you to see read and read back times for each variable as well as the output file path for output parameters Clicking on this input output path pops up its content
2. fix performance bottlenecks apply Scholar hints fix failing tests Unt a OE aikas ee aS Correct Code Tuned Code Code debug Optimized aTe See Also Enabling OpenCL Scholar OpenCL Scholar Hints Enabling OpenCL Scholar You can enable the OpenCL Scholar feature in Intel tools for OpenCL code development NOTE Generating Assembly IR LLVM and SPIR output is not supported in the Scholar mode Scholar in Kernel Builder Command Line Interface In the Kernel Builder for OpenCL API command line interface add the scholar command line option For example ioc64 input mykernel cl device gpu scholar The tool prints optimization hints in the following format lt filename gt lt line gt lt column gt Scholar lt message gt Scholar in Offline Compiler for Eclipse To use Scholar in Eclipse 1 Goto Intel OpenCL gt Options 2 Check the Enable Scholar Support check box under the Scholar Configuration group box 3 Build an OpenCL kernel file to see Scholar hints highlighted light blue in the Console View The hints also appear with an info marker in the Problems View An info marker appears in the editor for each Scholar hint Scholar in Offline Compiler for Visual Studio To use Scholar in the Miscrosoft Visual Studio 1 Right click your project and open the project properties 79 User Manual Intel SDK for OpenCL Applications 2 Go to Configuration P
3. Intel SDK for OpenCL Applications 2014 User Manual Copyright 2010 2014 Intel Corporation All Rights Reserved Contents LEJarTATOFM Ogata sisiere i Sa stersicge arm ape E wea eeranwaiememieseecddeceaeneds 5 GeEEING EID and SUD BOE scrissimu a a a aa a aa pn 7 What iS NeW ea E E 8 Code Editing and Building with Visual Studio Plug in ssssssssss2s222u20u220u2202202220u22022202222 nn 9 OpenCL API Offline Compiler Plug in for Microsoft Visual Studio IDE ccccce cece eee eee 9 Configuring Microsoft Visual Studio IDE sic 1c5icentetarenenoaewlawsitotenawbduaaxwhidudesantaxsiaktosteaessehadnen 9 Converting Existing Project into ODENCL Project cccec cece cece eee ee eee eee eeeeeeeeeeeeeeeeenenaas 10 PUNGIN OPENGL PrO O C trccecansanaenecdacscstue sence es hidaescencnnambadar ce munsasisbe E 10 Using Open Build Properties svete sarees ctor toe gst EEEE E Ea 10 S lecting Target OpenCL DEViCe is chaasins edu cinadeaeinaeneenadvensidees e EN a A a 11 Generating and Viewing Assembly Code ssssssssssresrresrrrsrrnrrrnerrrerrrsrerrrrerrrsrrrrrenrrrenrrenan 11 Generating and Viewing LLVM Code sssssssssssrssrrsrresrrrsrrrsrrnrrrerrrerrrerrrrrrerrrerrrererrrrerrrenan 12 Generating Intermediate Program Binaries with Offline Compiler Plug in cccceeee eee eeeeeees 13 COnTICURING OpenCL Buld ODMONS sscstescencasviceecacicaceseranwebemseccteeaaeeuatentsaeveesacewetenageareeienes
4. OpenCL Build properties page in the Microsoft Visual Studio IDE enables you to set compilation flags and change target device when building an OpenCL kernel To change the settings do the following 1 Goto Project gt Properties 10 Code Editing and Building with Visual Studio Plug in Click the Intel SDK for OpenCL Applications entry under the Configuration Properties Configuration Active Debug Platform Actrve Win32 Configuration Manager gt Common Properties Include 4 Configuration Properties Device CPU device CPU General SIMD Default simnd default 4 Intel SDK for OpenCL Appl Generate assembly code No General Generate Ivm code No Math piman Generate binary file Mo Warnings Additional build options 3 Modify properties and click OK NOTE The Intel SDK for OpenCL Applications entry exists for OpenCL projects with cl source files attached If the entry does not exist convert an existing standard project into the OpenCL project See Also Creating an Empty OpenCL Project Converting Existing Project into OpenCL Project Selecting Target OpenCL Device OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE enables you to choose the target device when building your OpenCL code Intel CPU Intel Graphics Intel Xeon Phi coprocessor Intel CPU on Experimental OpenCL 2 0 Platform The default device is CPU To ch
5. Shows help menu containing the list of available commands hel arguments and options Offline Compiler supports the following options Option Use Description 40 device lt device_type gt targetos lt 0s gt simd lt instruction_set_arch gt output lt output_file_path gt asm lt file_path gt livm lt file_path gt vines Ole oA Tk Me palh llvm spir64 lt file_path gt ir lt file_path gt spir32 lt file_path gt spir64 lt file_path gt scholar bo lt bui L d opelons gt Building with Kernel Builder Command Line I nterface Selects target device type e cpu Intel CPU device which is Default e gpu Intel Graphics device e co Intel Xeon Phi coprocessor device e cpu_2_0 Intel CPU device on Experimental OpenCL 2 0 Platform Set target operating system if it is different from current android use with cpu device only The command is supported only in 32 bit version of the tool Selects target instruction set architecture Available on CPU device only The following instruction set architectures are available e sse42 Streaming SIMD Extensions 4 2 e avx Intel Advanced Vector Extensions Intel AVX e avx2 Intel Advanced Vector Extensions 2 Intel AVX2 Writes build log into the output_file_path When this option is specified the build log does not appear in the command line Generates assembly code Generates LL
6. obelFilter cl 4 Build Artifacts B SobelFilterI SobelFilter asm SobelFilter ir P SobelFilter_x 6 spir SobelFilter_x64 spir B SobelFilter_x86 1I B SobelFilter_x64 1l All build artifacts are stored in the sessions folder You can double click the LLVM Assembly code to see its content in the IDE s editor You can open the containing folder by right clicking one of the files and selecting OpenCL Containing Folder Kernel Arguments Once OpenCL program build is completed successfully you are able to see all built kernels with arguments under the Kernels node in the Code Builder Session Explorer 98 Preview Features Pe Session SobelFilter 1 files 4 OpenCL Files sobelFilter cl F3 Build Artifacts al kernels d gb SobelFilter F Arguments Ka _ private MOME sampler_t Sam c _ global READ_ONLY imaged _t Input c _ global WRITE_ONLY image d_t Output C _ global NONE int Mask cl ed ll Code Builder Build Toolbar To show the toolbar go to VIEW gt Toolbars and make sure that the Code Builder Build option is checked WE Bue You can use the Code Builder Build toolbar to perform basic operations on sessions such as Create new session Load session Save session Build session Compile session Open session s settings dialog Analyzing Kernel Performance Using the Code Builder Analysis Toolbar To show the toolbar go to VIEW gt Toolbars and make sure that Code Builder Analysis option
7. Projects ConsoleApplication1 Debug ConsoleApplicationl e Build 1 succeeded failed up to date skipped 4 l Iit 12 Code Editing and Building with Visual Studio Plug in Generating Intermediate Program Binaries with Offline Compiler Plug in OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE generating program binaries of the OpenCL code An application can use generated program binaries to create program from binaries later clCreateProgramFromBinary To generate intermediate program binaries do the following 1 Goto Project gt Properties 2 Click Configuration Properties gt I ntel SDK for OpenCl Applications gt General 3 Change the Create Program Binary option to Yes Configuration Active Debug Platform Active Win32 g Configuration Manager gt Common Properties Include 4 Configuration Properties Device CPU device CPU 4 Intel SDE for OpenCl Appl SIMD Default simd default Gene al a Generate assembly code No a Generate Ilvm code No arnings 3 z 7 Generate binary file Yes ir Comma nd Li ne amp JI 1 ee sa sa ems iz 4 Click OK Configuring OpenCL Build Options OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE enables configuring build options for the OpenCL code To configure the build options do the following 1 Goto Project gt Properties 2 Click Configuration Properties gt I ntel
8. do the following e Select Analyze gt Variable management Or click cells in the Assigned Variable column of the Analyze Board In the Variable Management dialog click Add e Inthe Select Variable Type dialog choose Sampler from the Type combo box Create Sampler Variable Name Addressing Mode Filtering Mode Normalized Coordinates 30 Building and Analyzing with Kernel Builder See Also Creating Images Creating Buffers Using Structs Kernel Builder for OpenCL API supports user defined structs To use structs for kernel analysis you need to define them Go to Analyze gt Struct Management Choose data type and enter fill name Click Add to add a new field Click OK to save the created field 7 l x momen i _ struct Name PENA Struct Types Type Name 1 char a 2 uchar b After defining the struct you can select is as type when creating a buffer variable 31 User Manual Intel SDK for OpenCL Applications I0 Mode Data type Size Memory flags to use Get output buffers data Initialization options Input file CSV or bin Use random values Zero the entire buffer A csv file for a struct buffer should have the following format e Line numbers should be greated or equal to the buffer size e Each line should contain all concatenated data fields For example EVpeCder Seruce Poine LNE X IROA cloar values For a buffer
9. o stage passOfStage sa passOtstage stage passOfStage passOfStage 5 passOfStage tarne Objects Solution Team Ex Class View When creating an OpenCL context for with for example clCreateContext API call the Objects Tree updates immediately with the new context object Objects dim when become released by for example clRelease Use the following buttons to control the Objects Tree view e Sort By enables toggling the way data is displayed o Sort by Context all entities that are associated with a specific context are displayed as context successors o Sort by Device all contexts are displayed as children of the devices e Show Objects enables displaying only a subset of the OpenCL objects Use it when you have a lot of OpenCL objects that are alive at some given moment and you need to see status of only 51 User Manual Intel SDK for OpenCL Applications several objects or object types To view objects of a specific type only o Select Show Objects gt uncheck Show All o Select Show Objects gt select the object type to display e Open Source Code in a new tab enables viewing the source code associated with the program object Right click any Program object in the tree then click Open Source Code in a new tab Objects Tree Li Sort By gt Show Objects e Platform 1 Intel R OpenCL Ge Context 1 Buffer 1 wie Buffer 2 e Save Binaries enables
10. s arguments memory source type For CPU device type you can also set the out of order execution mode and debug mode for the kernel 75 User Manual Intel SDK for OpenCL Applications Advanced Settings Enable Profiling Queue Input Memory Source Use Host Memory InoutB Memory Source Use Host Memory i z B o h Next gt C M 7 Click Finish to create the default template project or click Previous to return the Basic Settings screen Create a New OpenCL Project from OpenCL Project Template for Android To create an OpenCL template project for Android devices in Microsoft Visual Studio 2012 only do the following 1 Goto File gt New gt Project 2 Select OpenCL templates from the Templates tree view 3 Select CodeBuilder Project for Android i b Recent NET Framework 4 5 Sort by Default X Sai Search Installed Templates Ctrl E Pp T Visual C s CodeBuilder Project for Android Visual C ype Visual C 4 Templates An OpenCL Project b Visual Basic CodeBuilder Project for Windows Visual C b Visual C 4 Visual C Empty OpenCL Project for Windows Visual C ATI Fill the Name Location and Solution name fields and click OK In the Code Builder wizard for OpenCL API dialog you can select the basic settings for the behavior of the OpenCL application and kernel The parameters that can be set are platform name device type kernel type
11. the Console window background color turns green otherwise it turns red In case of failure the Kernel Builder reports the number of the problematic line Double click the error line in the Console text box to jump to the relevant line in the code You can save the compiled binary by clicking the Create Program Binary button 18 Building and Analyzing with Kernel Builder See Also Loading Code from File Saving and Loading Code Kernel Builder for OpenCL API enables saving and loading the generated OpenCL LLVM SPIR LLVM Assembly and source code To save the code click the Save As e button and select code type to save Ir Save Source Ctri Save LLVM As Save SPIR LLVM 32 bit As Save SPIR LLVM 64 bit As Save ASM As Save Session To load OpenCL code from file do one of the following E Click the Open button and select Open Press Ctri O Select File gt Open Drag and drop file into the code editor window Saving and Loading Session Kernel Builder for OpenCL API enables saving the current session A Session is all the open tabs including their configured options and analysis configurations To save the session click the Save As G button and select Save Session Fa To load a saved session click the Open button and select Load Session NOTE Following an unsuccessful shutdown the Kernel Builder for OpenCL API prompts you to restore one of the last 5 au
12. SDK for OpenCL Applications gt General 3 Add build options into the Additional build options line Configuration Active Debug Platform Active Win32 Configuration Manager gt Common Properties Include 4 Configuration Properties Device CPU device CPU a Intel SDK for OpenCL Appl SIMD Default simd default General Generate assembly code Yes asm Math Optimizations Generate Ilvm code Yes llvm Warnings Generate binary file Yes ir Cirina Tene cl single precision contant cl denorms are zero 4 Click OK 13 Code Editing and Building with Eclipse Plug in OpenCL API Offline Compiler for Eclipse IDE OpenCL API Offline Compiler plug in for Eclipse IDE enables developing OpenCL kernels with the Eclipse IDE The Offline Compiler plug in supports Eclipse versions 4 2 Juno 4 3 Kepler and 4 4 Luna The plug in supports the following features Offline compilation build and link of OpenCL kernels LLVM code generation Assembly code generation program IR generation Target OpenCL device selection Configuring OpenCL API Offline Compiler Plug in for Eclipse IDE To enable the OpenCL API Offline Compiler plug in for Eclipse IDE do the following 1 Copy the plug in jar file from INTELOCLSDKROOT bin eclipse plug in to S ECLIPSEROOT dropins On Linux OS add INTELOCLSDKROOT bin tO LD_LIBRARY_PATH Run Eclipse IDE Select Window gt Preferences Switch
13. Sessions e To configure the session open the Session Options menu by selecting CODE BUILDER gt Kernel Development Framework gt Session Options The Session Configuration window enables you to define e Target device to perform build or analysis operations e Build options e Target platform architecture Code Builder Configuration Toolbar You can control some of the Session s options through the Code Builder Config toolbar To show the toolbar go to VIEW gt Toolbars and make sure that Code Builder Config is checked OpenCL Platform Intel R Corporation OpenCL Device Intel CPU Target Architechture x86 is The Code Builder Config toolbar enables you to Select the target OpenCL Platform Currently only Intel s platform is supported Select the target OpenCL Device Select the target platform architecture Show the platform info dialog Configuring Device Options Open the Session Options menu via selecting CODE BUILDER gt OpenCL Kernel Development gt Session Options The Device Options tab provides several configuration options 94 Preview Features new _session Session Options Device Options Build Options General Options Target Machine Local Machine VKARTOSH MOBL3 Remote Android Machine Fe OpenCL Device OpenCL Platform Intel R Corporation OpenCL Device Intel CPU Network Settings Minimum Port Maximum Fort Cancel g m Target Machine group box enables
14. Type Not Available Properties View Properties See Also Enabling the API Debugger 54 Debugging with Visual Studio Plug in Command Queue View OpenCL API Debugger plug in for Microsoft Visual Studio IDE provides Command Queue View which enables tracking the execution status of enqueued commands issued by clEnqueue API call The status for a command can be either of the following options e Submitted e Running e Completed The Command Queue View also displays events for a particular command queue Separate Queues or for all events from all queues Unify Queues Access the Command Queue View by selecting CODE BUILDER gt OpenCL Debugger gt Command Queue View Command Queue lal Save As dy Unify Queues Sort By Time Ascending CommandQueue 1 CPU In Order Submitted Running Completed NDRANGE KERNEL 0 VIAF D 5 Data View Image View Problems view Trace View Command Queue Use the following buttons to control the Command Queue View e Save As enables dumping the current status of commands to a text file for a later investigation e Unify Queues enables to view all commands across all queues Also note the following o When working in the Unified queues mode each entry is added a suffix of the form co NUMBER which indicates the command queue number with which the command is associated o For example TASK 3 CQ 1 Indicates that the 3rd command enqueued to some queue is
15. copy 3 Click Copy Variable Removing Variables To delete variables when using the Kernel Development Framework do the following 1 Open the Code Builder Variable management window 2 Right click a variable name 3 Click Delete variable or Delete all variables You can delete all buffers images or samples by right clicking the corresponding node Buffers Images or Samplers respectively 108
16. dumping binary files that were built for the program object with use of clBuildProgram Or clCreateProgramWithBinaries Right click any built program object in the tree then click Save Binaries and select the location to save the binaries See Also Enabling the API Debugger Properties View OpenCL API Debugger plug in for Microsoft Visual Studio IDE exposes miscellaneous properties for each OpenCL object or Command Queue event Properties view pre fetches information about OpenCL objects or events and displays it when a particular object is selected Access the Properties View by selecting CODE BUILDER gt OpenCL Debugger gt Properties View All properties in the Properties View are read only OpenCL Objects Properties To view properties for an OpenCL object do the following 1 Select left click some object from the Objects View window 2 Open the Properties view The OpenCL Objects Properties view is an alternative to calling API calls such as clGetDevicelInfo 52 Debugging with Visual Studio Plug in Command Queue Events Properties To view properties for an OpenCL command queue event do the following 1 Select left click an event from the Command Queue View window Objects Tree J Sort By T Show Objects ag Platform 1 Intel R OpentL T Context 1 A Device 1 CPU FA CommandQueue 1 In Order eC Program 1 Built Ele Kernel 1 ToneMappingPerPixel inputlmage
17. i ea Saving Intermediate Representation Code in Eclipse IDE To save the Intermediate Representation code using the OpenCL API Offline Compiler plug in for Eclipse IDE do the following 1 Compile an c1 file using the Offline Compiler plug in for Eclipse IDE 2 Select Intel OpenCL gt Save IR Binary add file name select path and click Save 17 Building and Analyzing with Kernel Builder Kernel Builder for OpenCL API The Kernel Builder for OpenCL API is the standalone version of the OpenCL Code Builder It enables you to build and analyze OpenCL kernels The tool supports Intel processors Intel Graphics and Intel Xeon Phi coprocessors The tool provides full offline OpenCL language compilation which includes OpenCL syntax checker Cross platform compilation Low Level Virtual Machine LLVM viewer Assembly code viewer Intermediate program binary generator With the Analyze Board of the Kernel Builder you can e Assign input to the kernel and test its correctness Analyze kernel performance based on o Group size o Build options o Device e Perform Deep Kernel Analysis NOTE Intel Graphics support is available on Windows OS only Using Kernel Builder Building and Compiling Kernels To build or compile an OpenCL kernel using the Kernel Builder for OpenCL API do the following 1 Write your code into the code editor or load code from file 2 Click Build or Compile If you succeed
18. images and buffers 101 User Manual Intel SDK for OpenCL Applications sobelFilter_Lcbreport select Report Variables view Gx Gy Gz Lx Ly 512 51 0 512 512 0 5l 512 0 Read Time Read Back Time Input Output 0 448804 i CrUserstcvectest Desktop lab contentylab sessionllena brmp 0 468368 0 12556 CiUserskcvectest 4ppData localy Temp Outputsl2_1 512_2 img 0 016352 0 gls 512 0 giz 512 0 gls 512 0 gls 512 0 l 512 0 gl 512 0 Variable Management Variable Management Overview You can manage variables in Kernel Development Framework via the Code Builder Variable Management dialog To open the dialog go to CODE BUILDER gt Kernel Development Framework gt Windows gt Variable Management or click the Variable Management button In the Code Builder Analysis toolbar 102 Code Builder Variable Management 4 Add CA Delete Delete All 4 Buffers Data Type char size 155 source Random Values TO Mode Input Memory Flags CL_MEM_USE HOST_PTR d mages l Ee image_l d ejirmmage_1 Data Type imaged t Width 5123 Height 5125 Depth 1 Array size 1 Row Pitch 0 slice Pitch 0 Channel Data Type CLUNORM_INTS Channel Order CL_BORA IO Mode Output Memory Flags CLMEM_COPY HOST_PTR b Ee image_2 b ke image_3 b e image_4 d Samplers 4 sampler Normalized Coordinates false Addressing Mode CL_40DRESS_ MIRRORED REPEAT Filtering Mode CL_FILTER_WESREST Creating Buffer Variables To
19. images or buffer manipulation build options and local work group size behavior Each field has a short tool tip explanation a 76 Preview Features Basic Settings Platform Name Intel Device Type CPL Create Kemel with Images Create Kemel with Buffers a Previous Click Finish to create the default template project or click Next to open the Advanced Settings screen enabling you to set some advanced options like whether to enable profiling queue and the kernel s arguments memory source type For CPU device type you can also set the out of order execution mode 77 User Manual Intel SDK for OpenCL Applications Code Builder wizard for OpenCL API fon Welcome to Code Builder wizard for OpenCL API Advanced Settings rofiling Queue 7 Click Finish to create the default template project or click Previous to return the Basic Settings screen NOTE You need the Android NDK installed on your system to use the Create a New OpenCL Project feature for Android OpenCL Scholar About OpenCL Scholar OpenCL Scholar is a preview feature that reports potential problems and optimization opportunities in OpenCL kernels Upon enabling the scholar mode compiling the kernel provides hints on improving the kernel performance Use Scholar prior to applying any other performance tuning actions such as profiling and right after making sure the kernel works as expected 78 Preview Features
20. is checked Select Kernel No Kernels x Ka You can use the Code Builder Analysis toolbar to perform analysis operations on sessions such as Selecting the OpenCL kernel to execute analysis on Start Analysis Open Code Buidler Analysis Input window Open Code Builder Variable Management windows Analyzing Input To assign analysis inputs for an OpenCL kernel do the following 1 Select the desirable kernel from the session s kernels list in the Code Builder Session Explorer or from the Select Kernel combobox in the Code Builder Analysis toolbar 99 User Manual Intel SDK for OpenCL Applications 2 Open the Code Builder Analysis Input window from CODE BUILDER gt Kernel Development Framework gt Windows gt Code Builder Analysis Input or by clicking the Open Analysis Input button in the Code Builder Analysis toolbar 3 Assign a variable for each kernel argument in the Kernel Arguments table by clicking the Click here to assign link under the Assigned Variable column You can assign one dimensional variables Such aS integer float char half and so on on the fly by typing single values into the table See section Creating Variables for details Running Analysis To start the analysis go to CODE BUILDER gt Kernel Development Framework gt Run Analysis or click the button P in the Code Builder Analysis toolbar Viewing the Analysis Results Analysis Results Overview Once analysis is completed several
21. ones from lt programfilesdir gt Common Files Intel OpenCL2 0 sys to the respective system directories OpenCL New Project Wizard About the OpenCL New Project Wizard OpenCL New Project wizard is a plug in for Microsoft 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 following features e Create a new empty OpenCL project for Windows platforms e Create a new OpenCL project from OpenCL project template for Windows platforms e Create a new OpenCL project from OpenCL project template for Android devices See Also Creating an empty OpenCL Project Create a new OpenCL project from OpenCL project template 73 User Manual Intel SDK for OpenCL Applications Creating an Empty OpenCL Project for Windows To create an empty OpenCL project for Microsoft Visual Studio IDE do the following 1 Goto File gt New gt Project 2 Select OpenCL templates from the Templates tree view New Project b Recent NET Framework 4 5 Sort by Default Search Installed Templates Ctri E 4 Installed T Visual C CodeBuilder Project for Windows Visual C iMac 4 Templates An OpenCL Project b Visual Basic s Empty OpenCL Project for Windows Visual C b Visual C 4 Viewal Cow 3 Select Empty OpenCL Project for Windows 4 Fill the Name Location a
22. r loa ng POI cue ula Weighs ee Abel eecisie siecle De eine aS Use the Restrict Qualifier for Kernel Arguments Scholar recommends using the restrict qualifier on kernel arguments that may alias other arguments if you are sure that this aliasing can never actually occur Such optimization helps the compiler limit the effects of pointer aliasing while aiding the caching optimizations 80 Preview Features The message location is the parameter name and its content is parameter lt param name gt should be marked as restrict if it never shares memory with other arguments Consider the following code kerne avor piri co boba a oae wel resol olor Ia eos a wena IOE Gh Ces opa E aO ET E E E O a leh Rebeka E e Coa all For the code above Scholar provides the following hint message mykernel cl 1 46 Scholar parameter b should be marked as restrict if it never shares memory with other arguments Consider native_ and half_ Versions of Builtins Scholar reports the following math builtins usage as potentially inefficient when the native_ and half_ versions might be used instead e sin e COs o exp e log native_ and half_ versions use hardware instructions directly potentially greatly decreasing the time needed for these calculations The message location is the beginning of the name of the called function and its content is using native_ lt name gt or half_ lt name gt can provide greater performance at some a
23. reports are being generated A new report is being generated for each analysis run The reports are available under the Reports node in the Code Builder Session Explorer window a Session SobelFilter 1 files PJ OpencL Files FJ Build Artifacts FJ Kernels d gt Reports SobelFilterO chreport obelFilter Lcbreport obelFilter_2 chreport Each report contains several views e Execution View provide information on execution times statistics and on the best and worst configurations e Variables View provide information on the read and read back time of the memory object being used in the kernel and allows you to see their content You can toggle between the views through the Report Selection combobox located at the top of the report s layout Execution View The top part of the Execution View enables you to see the tested global and local size best and the worst configurations based on median execution time In case only one configuration exists the result appears in both result windows The table below enables you to see statistical analysis results for all configurations The statistics consists of the following iteration execution time values for the selected configuration Median Average Standard deviation Maximum Minimum 100 Preview Features Expending each row in the table enables you to see the total run time the breakdown to queue submit and execute times per iteration for the given configuration
24. selecting the target machine e Local Machine e Remote Machine To use the Remote Machine option you need to 1 Connect an Android device with Intel processor or an emulator based on Intel x86 System Image 2 Copy OpenCL runtime to the Android device or emulator See section Installing OpenCL Runtime on Emulator 3 Click Setup to copy OpenCL tools to the device NOTE You need to use the Setup option each time you start an emulator device OpenCL Device group box enables selecting the target platform and device for the selected machine Intel CPU Intel R Graphics Intel Xeon Phi tm coprocessor Intel CPU on experimental OpenCL2 0 Platform Network Settings group box enables configuring the network port range Configuring Build Options Open the Session Options menu via selecting CODE BUILDER gt OpenCL Kernel Development gt Session Options 95 User Manual Intel SDK for OpenCL Applications The Build Options tab provides several configuration options new _session Session Options Build Options General Options OpenCL Optians Target Build Architectures Use Current Plattonm Architecture Target Operating System Current Operating System Target Instruction Set Advanced Vector Extension AVX Cancel OpenCL Options group box which enables typing the options into the text box Target Build Architecture group box enables Using the current platform architecture Configuring th
25. software operations and functions Any change to any of those factors may cause the results to vary You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases including the performance of that product when combined with other products User Manual Intel SDK for OpenCL Applications Intel Intel logo Intel Core VTune Xeon are trademarks of Intel Corporation in the U S and other countries This document contains information on products in the design phase of development Other names and brands may be claimed as the property of others OpenCL and the OpenCL logo are trademarks of Apple Inc used by permission from Khronos Microsoft product screen shot s reprinted with permission from Microsoft Corporation Copyright 2010 2014 Intel Corporation All rights reserved Getting Help and Support To get support visit the product support forum at http software intel com en us forums intel opencl sdk For information on SDK requirements Known issues and limitations refer to the Release Notes What is New Comparing to the User s Guide of the Intel SDK for OpenCL Applications 2014 R1 the User Manual now has the following changes e The document is divided into the User Manual with the information about tools and two Reference Manuals one with information on the OpenCL Runtime for Intel CPUs and Intel Processor Graphics and another with the inf
26. the interface of the Kernel Builder for OpenCL API The Debugger supports e Running OpenCL kernels on the Intel Graphics device step by step e Setting breakpoints e Viewing variable values To enable the Kernel Debugger set the CL_GPU_KERNEL_DEBUGGER_ENABLED environment to True 82 Preview Features To start debugging 1 Open an existing OpenCL file or write a new kernel in the Kernel Builder code editor i 3 Click the Debug button L or select Analyze gt Debug board Click the Refresh kernel s button to get the list of kernels available for debugging Select a kernel to debug by clicking the kernel name from the pull down menu If only one kernel IS available it is selected automatically 5 Assign parameters for the debug session and click Debug nied Upong clicking the Debug button the tab with the Debugger controls opens automatically ao 35 int X get global id 0 5 36 int get global id 1 a7 38 Read image coordinates O EEE int22 PizelCoords X Y Empty red circles O appear in the kernel code editor next to the executable lines suggesting the locations where you can set breakpoints for kernel debugging Yellow and Blue arrows T appear next to the executable line of the selected kernel The yellow arrow is the next line to execute in a work item while the blue arrow is the next line to execute in a work group See Also Using Kernel Builder Assigning Debug Parameters To set kernel arg
27. to the Intel OpenCL dialog and set OpenCL binary directorys INTELOCLSDKROOT bin ae INTELOCLSDKROOT represents SDK installation root folder ECLIPSEROOT represents the Eclipse root folder To configure other options select Intel OpenCL gt Options Configuring Options In the OpenCL API Offline Compiler Plug in for Eclipse IDE go to Intel OpenCL gt Options and configure the needed options e Type the build options into the Build Options text box or click to add options from list Hold Ctrl to select several options e Select the target architecture o x86 for 32 bit architecture o x64 for 64 bit architecture e Select the target instruction set o Streaming SIMD Extension 4 2 SSE4 2 o Advanced Vector Extensions Intel AVX o Advanced Vector Extensions 2 Intel AVX2 14 Code Editing and Building with Eclipse Plug in e Select the build type o Debug o Build e Select the OpenCL Device type o Intel CPU o Intel Graphics o Intel Xeon Phi coprocessor o Intel CPU on Experimental OpenCL 2 0 Platform NOTE Intel Graphics support is available on Windows OS only Building and Compiling Kernels in Eclipse IDE To build or compile an OpenCL kernel using the OpenCL API Offline Compiler plug in for Eclipse IDE do the following 1 Write code into the Eclipse code editor or load code from file 2 Click the Build or Compile L button at the tool bar or right click the file in the projec
28. 0 10 5 4 6 clGetDevicelnfo 5 0 122 24 3 45 clGetPlatformIDs 2 0 2 1 1 1 clGetPlatforminfo 2 0 6 3 3 3 clSetKernelArg 326 0 11727 35 I7 11 Kernel Launch Commands shows every OpenCL kernel that was launched during program execution Each row shows the time of execution and work size data for each launch analysis session from captuing duration Kernel Name Latency ps Run Duration ps Start Time ps Global Work Size Local Work Size Global Work Offset Queue ID BitonicSort 183084 22881120 172808198523476 8388608 0 1 BitonicSort 147752 13237236 172808227764648 4194304 0 1 p BitonicSort 124392 18392496 172808243862316 8388608 0 1 Oueued Time us 172808243737924 Started Time us 172808243862316 Ended Time us 172808262254812 Duration us 18392496 Return Value 0 Command Tvpe CL_COMMAND_NDRANGE_KERNEL BitonicSort 134612 13173288 172808265695740 4194304 0 1 BitonicSort 115340 12774708 172808281376432 4194304 0 1 BitonicSort 134320 18800420 172808305273420 8388608 0 1 BitonicSort 124684 13634064 172808327202912 4194304 0 1 BitonicSort 121472 13165112 172808343336788 4194304 0 1 BitonicSort 122348 13130656 172808359015436 4194304 0 1 BitonicSort 122640 13162192 172808374592176 8388608 0 1 BitonicSort 124684 12785512 172808391066232 4194304 0 1 BitonicSort 122056 13265268 172808406210228 4194304 0 1 Memory Commands shows every memor
29. 0728_ 10 Parent topic Preview Features Creating and Launching New Analyze Session To create and run an Analyze session do the following 1 Goto CODE BUILDER gt OpenCL Application Analysis gt New Analyze Session 2 Inthe OpenCL Analyze Session dialog specify information about the application that you want to analyze 3 Make sure that the Start Automatically on Process Launch check box is selected and then click Launch 4 Your application starts and the profiler starts to collect data 5 Exercise the functionality that might contain performance issues 6 While the application is running a new Session Run tab is opened in the main Visual Studio window 7 Click Pause Resume analyze button in the Session Run tab to pause or resume data collection 8 Click Close analyze or close the application 87 User Manual Intel SDK for OpenCL Applications fe OpenCL Analyze Session olal Application Setting Which application would you like to analyze Application Arguments Working Directory m Start Automaticly on Process Launch o Application full path to the target application Arguments command line arguments to use when starting the target application o Working Directory working directory for the target application to be started If no working directory is specified the default is the directory that contains the target application O Analyzing the Data After you finish running the ap
30. 13 Code Editing and Building with EclipSe Plug in ssssssnsnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 14 OpenCL API Offline Compiler for Eclipse IDE cc ccc ccccceeee eee reese ees eeeeeeeeen een eenngaaas 14 Configuring OpenCL API Offline Compiler Plug in for Eclipse IDE cccceeeee eee e eee eeeees 14 COMMOUMIRG QDEIOWS erronis rrine nie edueencccotnes aqaumtenteacerenanedneemnceomicdacenueutiecaenens 14 Building and Compiling Kernels in EclipSe IDE cccccccc cece cece cece eee eset eens eeeeeseeeneeeneneneees 15 Generating Assembly Code in Eclipse IDE ccccccccc cece cece seen eee e eee enaeeeeeeee een eeeneaaaas 16 Linking Program Binaries in Eclipse DE siscscacicnes csiearetcasiavneaiesabeecradenhteadeswekwekiareecateaveeaaies 16 Saving and Loading OpenCL Code in Eclipse IDE cccccccc cece eee eeeeeeeeeeeeeeeeeeeeesseannneees 16 Saving Intermediate Representation Code in Eclipse IDE ccccce cece ce eesee sense eee eeeeeseennenees 17 Building and Analyzing with Kernel Builder cccccssscccceeeeeeesnnneeeeseeeeeeeeeesesaaeaeeeeeeeeenneeeaas 18 Kernel Builder for OPENCL API cece cece eee nee e een e eed n DDE E EEE E EEE E EE Eee SSE DEES EEE SHEER EES 18 SING Kerie UN GCR ec Acweetetmeseee ted deancecenns yas cadet ecsemsnanesnceheeaeeaser auenaeubene aeaicesedehauseennne yeseeones 18 Building and Compiling Kernels cccccccccee cece
31. 54 770 Data View Image View Problems view Trace View Command Queue e Right click context menu enables toggling between various display modes of arguments Hex Decimal and show raw values for example 0x2 instead of CL_DEVICE_TYPE_CPU ti Show values in Hex Show values in Decimal Show raw values seston et ol fh eros j q 2 To enable automatic trace generation select CODE BUILDER gt OpenCL Debugger gt API Debugger gt Auto generate session Traces are saved in the folder that is specified in the Output Folder text box Automatic trace generation is an equivalent to clicking Save after the host application ended See Also Enabling the API Debugger 50 Debugging with Visual Studio Plug in Objects Tree View OpenCL API Debugger plug in for Microsoft Visual Studio IDE Objects Tree view enables e Getting a better understanding of which objects are alive released at any given point of time e Showing hierarchy and dependencies of various OpenCL objects API Debugger also reflects the OpenCL objects that exist in memory during application execution Platform Devices Context Buffer and so on Objects Tree AT Sort By L Show Objects o Platform 1 Intel R OpenCL Ee Context 1 A Device 1 CPU FA CommandQueue 1 In Or 0 Program 1 Built db Kernel 1 BitonicSort l a 1 theArray dig dir AD stage
32. Build Program Help d d Compile Program E Session O ptions Windows Le Settings The build log appears in the Console Output dialog 97 User Manual Intel SDK for OpenCL Applications show output from OpenCl Build z E a Setting target instruction set architecture to Default Advanced Vector Extension 2 AVA OpenCL Intel CPU device was found Device name Intel R Core TM i7 4770K CPU 3 5 GHz Device version OpenCL 1 2 Build 71 Device vendor Intel R Corporation Device profile FULL_PROFILE Compilation started ompilation done inking started Linking done Device build started Device build done Kernel lt SobelFilter gt was not vectorized Done 4 b Output Breakpoints Error List Build Artifacts Once OpenCL program build is completed the build artifacts appear under the Builds Artifacts note in the Code Builder Session Explorer The list of artifacts includes e Generated LLVM code lt file_name gt 11 e Generated assembly code for CPU and Xeon Phi only lt filen_name gt asm e Program s intermediate program s binary lt file_name gt ir e 32 bit version of generate SPIR LLVM code lt file_name gt _x86 11 e 64 bit version of generate SPIR LLVM code lt file_name gt _x64 11 e 32 bit version of the SPIR binary lt file_name gt _x86 spir e 32 bit version of the SPIR binary lt file_name gt _x64 spir 4 CY Session SobelFilter 1 files 4 FS OpenCL Files
33. Development Framework gt Windows gt Code Builder Session Explorer Creating Session from Existing OpenCL Code The Kernel Development Framework enables you to create a session from an existing application that contains OpenCL code files If you have a project in Microsoft Visual Studio that contains such files s you can do the following e Right click the OpenCL file and select Create Code Builder Session Ey Create Code Builder Session e Anew Session is created and becomes available in the Code Builder Session Explorer dialog Saving and Loading Sessions To save your session go to CODE BUILDER gt Kernel Development Framework gt Save Session Or click the Save Session button in the Code Builder Build toolbar menu New sessions are saved under the New Session Default Directory defined in the Kernel Development Framework s Settings See Kernel Development Framework Settings chapter on how to change these settings 93 User Manual Intel SDK for OpenCL Applications To load a saved session do the following 1 Goto CODE BUILDER gt Kernel Development Framework gt Load Session Or click the Load Session button in the Code Builder Build toolbar menu 2 Select the session to load in the Open File dialog and click Open Removing Sessions To remove a session from the Code Builder Session Explorer dialog right click the session that you want to remove and select Remove Session Keep local files Configuring
34. E ilma geWidth Ua ai Buffer 1 Buffer 2 Buffer 3 Objects Tree Solution Explorer Team Explorer Class View 2 Open the Properties view Properties View Buffer 1 Reference Count 0 Key 26B1 DAB Other Information Memory Type CL MEM_OBJECT_BUFFER Flags 0 CL_MEM_READ_ONLY 1 CL_MEM_USE_HOST_PTR Size Bytes 30720000 Host Pointer O08 CDO080 Map Count 0 Memory Type Not Available Properties View Properties 53 User Manual Intel SDK for OpenCL Applications The Command Queue Events Properties view is an alternative to retrieving execution time by adding the CL_QUEUE_PROFILING_ENABLE parameter to clCreateCommandQueue when creating the command queue to which the commands are enqueued and then querying the enqueued events execution times using clGetEventProfilingInfo To view properties for an OpenCL command queue event 1 Select left click some event from the Command Queue View window Command Queue bed Save As oy Unify Queues Sort By Time Ascending CommandQueue 1 CPU In Order Submitted Running Completed NDRANGE KERNEL 0 Data View Image View Problems view Trace View Command Queue 2 Open the Properties view Properties View Butter 1 SHH 4 Basic Information Reference Count g 4 Other Information Memory Type CL MEM_OBJECT_BUFFER Flags 0 CL_MEM_READ ONLY 1 CL_MEM_USE_HOST_PTR Size Bytes 307 20000 Host Pointer gac paoa Map Count 0 Memory
35. Explorer 2 Click Run As gt 1 Android Application NOTE Install the Intel Hardware Accelerated Execution Manager HAXM to accelerate the emulator performance on Windows OS Parent topic Developing OpenCL Applications for Android OS See Also Installing OpenCL Runtime on Android OS 72 Preview Features OpenCL 2 0 Experimental Development Environment OpenCL 2 0 Experimental Development Environment enables you to test OpenCL 2 0 features with the Intel CPU on Windows OS When developing applications for the OpenCL 2 0 runtime Emulator use the header files located in lt sdkdir gt include 2 0 CL NOTE Only the CPU OpenCL 2 0 device is supported on the 4th generation Intel Core processors and lower The experimental development environment is part of the SDK package and does not require installation of any other OpenCL platforms like Intel s implementation of the OpenCL 1 2 standard Also the OpenCL 2 0 experimental platform may coexist with other OpenCL platforms if installed under the same system The OpenCL 2 0 Experimental Development Environment is an OpenCL 2 0 platform that you can select when developing your application for testing OpenCL 2 0 features The platform name is Intel CPU on Experimental OpenCL 2 0 Platform NOTE Make sure OpenCL dll Intelopencl32 dl1l and IntelOpenCL64 d11 in the system directories were not changed or updated If these files are changed replace them with the
36. Finish CommandQue 00 03 24 1185 clEnqueueNDRangeKer clEnqueueNDRangeKer CL SUCCESS 00 03 24 027 mmand Queue The Save As button in the Image View enables saving a copy of the displayed image to disk as bitmap The number of states to save per each memory object Image Buffers and SubBuffers can be configured via 60 Debugging with Visual Studio Plug in CODE BUILDER gt OpenCL Debugger gt API Debugger gt I mages amp Buffers gt Number of previous states Code Builder Debugger Configuration Advanced Settings API Debugger W Enable OpenCL API Debugger Images amp Buffers Enable Dumping Images W Enable Dumping Raw Data Number of previous states 5 Other settings Auto generate session Output Folder C Users lt you_account gt Docur You can also disable dumping images by unchecking Enable Dumping I mages Notes To display the data the plug in has to perform background activities such as fetching the data and converting it into a displayable format which might impact performance when using the Enable Dumping I mages or Enable Dumping Raw Data options Take into account that profiling performance measured by either clGetEventProfilingInfo runtime API call any other method for measuring execution time or occupied host memory might entail c
37. OpenCL kernels The stitch between simultaneous debugging of OpenCL kernel and host application might be complicated in different stages API Debugging feature of the Code Builder Debugger plug in for Microsoft Visual Studio covers the stitch The API Debugging feature enables monitoring and understanding OpenCL environment of applications throughout execution The feature supports the following e API Tracing lists a trace of all OpenCL API calls that occurred during the execution list of trace arguments return values and execution time OpenCL Objects View shows all OpenCL objects that exist in memory during the execution Properties View retrieves common information per each OpenCL object Command Queue View tracks the execution status of the enqueued commands Problems View summarizing all error and warning messages 47 User Manual Intel SDK for OpenCL Applications Image View viSually displays all 2D image objects as bitmaps Data View visually displays buffer data and 2D image pixel arrays on a grid e Save Load session enables capturing a state snapshot of all views of the plug in saving it on disk and also loading the stored sessions e Memory Tracing enables storing OpenCL Images and Buffers content and visually examining either by Bitmap or Grid view the contents of the underlying data associated with the memory object throughout the various API calls that affected it NOTE Concurrent debugg
38. VM code Generates 32 bit LLVM SPIR code Generates 64 bit LLVM SPIR code Generates intermediate representation binary Generates 32 bit SPIR code Generates 64 bit SPIR code Enables performance hints Adds comma separated build options 41 OpenCL Debugger for Linux OS OpenCL Debugger for Linux OS enables debugging OpenCL kernels with the GNU Project Debugger GDB NOTE Debugger supports kernel debugging on CPU device only To debug OpenCL kernels with the Debugger you need the GNU Project Debugger GDB version 7 3 1 or higher with Python support Directly link your application to libpthread so Do not use LD_PRELOAD since LD_PRELOAD fails loading the Intel OpenCL devices altogether To enable GDB debugging of an OpenCL kernel in the build options string parameter in the clBuildProgram function 1 Add the g flag 2 Specify the full path to the file s lt full path to the OpenCL source file gt NOTE Relative path to the CL file is not supported Enclose the entire path with double quotes if the path includes spaces For example err clBuildProgram lt your_cl_program_name gt 0 NOR E ENS ae a eoo E e o Ss G er NOL E NULL 3 Invoke your application that executes the target OpenCL kernel in GDB oa patar EO cl 6 cla cum lt cloommMcina e cuacte 42 OpenCL Debugger for Linux OS Place a breakpoint in the host application after compiling the OpenCL code a
39. _SUCCESS 24 clSetKernelArg Kernel 2 1 8 1CE3D8 CL SUCCESS clSetKernelArg Kernel 2 0 8 1CE3B8 CL_SUCCESS clSetKernelArg Kernel 1 1 4 1CFDEC CL_SUCCESS 21 clSetKernelArg Kernel 1 0 8 1CESD8 CL SUCCESS Data View Image View Problems wiew Trace View Command Queue Properties View Properties The number of states to save per each memory object Image Buffers and SubBuffers can be configured via CODE BUILDER gt OpenCL Debugger gt API Debugger gt Images amp Buffers gt Number of previous states code ues Debugger Configuration NN Advanced Settings API Debugger Enable OpenCL AFI Debugger Images amp Buffers Enable Dumping Images Enable Dumping Raw Data Number of previous states 5 73 i Other settings Auto generate session Output Folder C Users lt you_account gt Docur We can also disable dumping raw data by unchecking Enable Dumping Raw Data Notes e To display the data the plug in has to perform background activities such as fetching the data and converting it into a displayable format which might impact performance when using the Enable Dumping I mages or Enable Dumping Raw Data options Take into account that profiling performance measured by either clGetEventProfilingInfo runtime API call any other method for measuring execution time or occupied host memory might entail certain performance degradation To get more accurate profiling results use t
40. a clEnqueueTask command and is associated with Command Queue 1 o Each queue has a color and all its corresponding commands have the color of the queue Such differentiation makes it easy to spot in the eye the corresponding queues of the commands in question 55 User Manual Intel SDK for OpenCL Applications Objects Tree i Sort By cy Show Objects 5 Platform 1 Intel R OpenCL D E Context 1 E Dewice 1 ad ote P Program 1 Built El Context 2 a Hee Device 2 GPU a2 Command Queue 2 In Order CommandQueue 3 An Order 5 Program 2 Built i ab Kernel 2 SobelFilter Object Sahin Toa Cas Vv Proper Proper Command queues in the Objects Tree view share the same color in the view as their color in the Command Queue view o The Unify Queues button changes into Separate Queues button after being clicked which does the opposite operation and shows events status per queue e Separate Queues appears when working in Unified mode after clicking Unify Queues and does the opposite to Unify Queues operation which is showing the commands per queue First select the queue from the drop down list under the Save As button then the view updates with the commands that are associated with the selected queue See Also Enabling the API Debugger Problems View OpenCL API Debugger plug in for Microsoft Visual Studio IDE provides the Problems View that summarizes into a si
41. ame l0 Mode Data Type Size Memory flags to use Get output butter data Initialization options Input file CSV or binary O Use random values Zero the entire buffer Creating Image Variables To create a new image variable 1 Open the variable management dialog CODE BUILDER ANALYZE WINDOW HELP OpenCL Kernel Development Ey New Session els el OpenCL Plat OpenCL Debugger Open Session OpenCL Application Analysis Save Session i Platform Info i Build Program Help ol o Compile Program F Session Options Windows Fi Settings 2 Click the Add button Ea in the Code Builder Variable Management dialog and choose I mage in the opened context menu Use input bitmap files and the parameters to create images Create output images with the correct size type channel order and so on NOTE In this version of the tool only 2 dimensional images with CL _UNORM_INT8 channel data type and CL_BGRA channel order are supported 105 User Manual Intel SDK for OpenCL Applications Image Variable Name IO Mode Data Type Source Width Height Depth Array Size Row Pitch Slice Pitch 0 Channel Data Type CL UNORM _INTS Channel Order CL BGRA Access Qualifier write_only Memory flags to use Get output image data Cancel The Get output image data checkbox disables reading back the output buffer or image It means that you can try more th
42. an one combination of global or local work sizes where there is no need to read the same output for all the combinations Creating Sampler Variables To create new sampler variable 1 Open the variable management dialog 106 Preview Features CODE BUILDER ANALYZE WINDOW HELP OpenCL Kernel Development ifs New Session els Ka OpenCL Plat OpenCL Debugger f Open Session OpenCL Appl ication Analysis F Save Session SEALT ts i Build Program Help i dhi Compile Program Session Options Windows t FE Analysis Input ES Setti Migs 1 Variable Ma nagement 2 amp 5 Code Builder Session Explorer 2 Click the Add button Ed in the Code Builder Variable Management dialog and choose Sampler in the opened context menu sampler Varlable Name sampler_1 Addressing Mode CLADDRESS_MIRRORED_REPEAT Filtering Mode CL_FILTER_NEAREST E Normalized Coordinates Selecting Memory Options You can change memory options of buffers or images using Kernel Development Framewokr Refer to the relevant sections of this guide for guidelines on creating or editing variables NOTE You are not limited in selecting options Avoid selecting the option combinations that are forbidden by the OpenCL 1 2 specification otherwise you may encounter errors upon analysis To choose buffers and images memory options do the following 1 Open the variable properties by right clicking an image or buffer varia
43. ariable properties by right clicking an image or buffer variable in the Variables Management window 2 Click the button next to Memory flags to use 3 Select options and click Done 33 User Manual Intel SDK for OpenCL Applications Memory options CL_MEM_READ WRITE CL _MEM_WRITE_ONLY CL_MEM_READ ONLY ICL MEM_USE_HOST PTR CL MEM_ALLOC HOST PTR LMEM_COPY HOST _PTR Select d_mem_flag to use L MEM HOST READ ONLY L MEM_HOST_NO_ACCESS CL MEM_HOST_WRITE_ONLY C See Also Creating Variables Editing Variables Editing Variables To edit the variables in the system using the Kernel Builder for OpenCL API do the following L 2 3 4 Select Analyze gt Variable management Or click cells in the Assigned Variable column of the Analyze Board Right click a variable name Click Edit variable properties Change the desired properties and click Done Viewing Variable Contents To view buffer or image contents when using the Kernel Builder for OpenCL API do the following 1 Select Analyze gt Variable management Or click cells in the Assigned Variable column of the Analyze Board 2 Right click a buffer or image name you want to view 3 Click Show variable contents Deleting Variables To delete variables when using the Kernel Builder for OpenCL API do the following L 2 3 34 Select Analyze gt Variable management Or click cells in the Assigned Variabl
44. ating System available on Windows OS only o Choosing the Target instruction set Streaming SIMD Extension 4 2 SSE4 2 Advanced Vector Extension AVX Advanced Vector Extension AVX2 Name of the selected instruction set architecture appears in the main window top bar as an indicator next to the file name Kernel Builder Local Intel CPU 64 bit alyze Help Changing the Target Build Architecture options enables viewing assembly code of different Instruction set architectures and generating program binaries for different hardware platforms 23 User Manual Intel SDK for OpenCL Applications NOTE Target Build Architecture options are available for the CPU device only enable Stripped LLVM generation check the Replace meaningful names with arbitrary one checkbox Configuring Advanced Options The Advanced Options tab provides several configuration options Options Device Options Build Options Advanced Options i amp Nehvork Settings Minium Fort 5010 Hamun Port 5999 E android Support Android Debug Bridge edb Path 1917 SDK PLATFORM TOOLS adb exe cae Oa etwork Settings group box which enables configuring the network port range Banaroia Support text box which enables specifying the path to the Android Debug Bridge adb See Also Configuring the Environment Installing OpenCL Runtime on Android Emulator Configuring Linkage Options To configur
45. ble in the Code Builder Variable Management window and selecting Edit Variable Open the combobox next to Memory flags to use Select options and click Done U N 107 User Manual Intel SDK for OpenCL Applications Memory flags to use Get output butter data E CL MEM_WRITE_ONLY E CL MEM_READ ONLY CL MEM_USE HOST PTR CL MEM_ALLOC HOST PTR CL MEM_COPY_HOST FTR CL MEM_HOST WRITE_ONLY CL MEM_HOST READ ONLY CL MEM_HOST_ NO ACCESS Tr T Initialization options Input file CSV or bin Use random values Zero the entire buffe Editing the Variables To edit the variables in the system using the Kernel Development Framework do the following Open the Code Builder Variable management window Right click a variable name Click Edit Variable Change the desired properties and click Done PMD Viewing Contents of the Variables To view buffer or image contents when using the Kernel Development Framework do the following 1 Open the Code Builder Variable management window 2 Right click a buffer or image name you want to view 3 Click View Variable Copying Variables To create a copy of buffer image or sampler varialbe when using the Kernel Development Framework do the following 1 Open the Code Builder Variable management window 2 Right click a buffer image or sampler name you want to
46. ccuracy COSE Consider the following code kerno Caor TEO Ik leyctlwaliahe a ae Ine Gid S oxo fe ovo oban L AO A e ES etleatel For the code above Scholar provides the following hint message 81 User Manual Intel SDK for OpenCL Applications mykerncl cll o 7 ehoar lS tine sala Sin or Nhal f oin can provide oreater Perrormance ar some accuracy Cost Avoid Non Coalesced Memory Access Scholar suggests avoiding non coalesced memory accesses Such memory accesses occur when adjacent work items access non adjacent buffer elements Coalesced memory accesses are translated to wide loads and stores while non coalesced accesses translate to gathers and scatters Wide loads and stores outperform gathers and scatters The message location is the beginning of the statement in which the memory access occurs and its content is non coalesced memory access Consider the following code korno haor on a ooa aane aa aa aa e ne e e e o O Ploae Poa ell akcl S For the code above Scholar provides the following hint message mykernel cl 3 3 Scholar non coalesced memory access Refer to the product Optimization Guide for more optimization hints and explanations See Also Intel SDK for OpenCL Applications Optimization Guide Debugging Kernels on Intel Graphics About Kernel Debugger Kernel Debugger is a preview feature that enables OpenCL kernel debugging on Intel Graphics device through
47. ce group box which enables selecting the target device for the selected machine e Intel CPU e Intel R Graphics e Intel Xeon Phi tm coprocessor e Intel CPU on Experimental OpenCL 2 0 Platform NOTE Intel Graphics support is available on Windows OS only The selected device options can be found in the program window title Kernel Builder Local Intel CPU 64 bit alyze Help NOTE Select the target device for each Code editor tab separately CPU device is default for all open tabs Configuring Build Options The Build Options tab provides several configuration options 22 Building and Analyzing with Kernel Builder Build Options Advanced Options OpenCL Options 2 Target Build Architecture Use current platform architecture Target operating system Current Operating System Target instruction set Advanced Vector Extension AVX EH Stripped LLVM T Replace meaningful names with arbitrary ones orenci Options group box which enables e Typing the options into the text box e Selecting options from the list available on clicking the button To select several options from the list hold Ctrl Or arset Build Architecture group box which enables e Using the current platform architecture e Configuring the build architecture manually by unchecking the Use current platform architecture check box and selecting o Select Target operating system Current Operating System Android Oper
48. cence eee eee eee e eee e ee eeeeeeeeeeeee ee eesgaaaaannnnes 18 Saving and Loading COCC x isc ca tenes cote sviencccnceu E EEEE EE A E EE A 19 Saving and Loading SCSSION ss isissisisreanirsaissansrkinn e aiaa ain aaa adai aa 19 LLVM SPIR and Assembly Code VieW ssssssssrssresrrrsrrrsrrrsrenrrrsrrrerrrrrrrrrrerrrsrrrrrene 20 Generating Intermediate Program Binaries ssesssssrssrrrerrsrrrsrrrerrrerrerrrsrrrerrrerrerrrene 20 Linking Programi BINGMGS sresssristnur anni EE A 21 COnN OUTO OPON serian E E E A S A 21 CONTMOUN IAG Linkage OOUIOMS aiskconssencentncssaauscescntureseoactesenac tess N 24 Kernel Performance Aaly SiS cvcccuncis neon nai a kins ster i A A dA D Eat Da Aaa A a T REENA 27 Analyzing OpenCL Kernel Performance s sssssssrssrrrsrrrsrrrsrerrrrsrrrsrrrrrrrrrrerrrerererere 27 MO N aD O ai a A E a A E EE 28 Viewing Analysis Results srsrimrekenieneisinn e EE E E a A ENA ET iE 35 Deep Kernel Analysis in Kernel Builder n ssnsnsenrnsnnnsrsnsrrrsrrnsrenrrrsrrrsrrrrrerrrrerrrsrrrsrene 36 Building with Kernel Builder Command Line I nterfaCe ssssssss222222222u22222022222222220222 2 25 40 OpenCL Debugger for LINUX OS sisdeccddicscesmssniiiccassdaeeweas sawenanacenswwescieaess catewiadeddennesearerensaies 42 Debugging with Visual Studio Plug in sssssssssu2222252222u202220u220u20u202un0unnunnnnnnnnnnnnnnnnnnnnnnnnnn 45 ODEHnCL DeDUOOEl AE E T AAE OEE E E T T TE 45 Enabling Debugging
49. cifications and product descriptions at any time without notice Designers must not rely on the absence or characteristics of any features or instructions marked reserved or undefined Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them The information here IS Subject to change without notice Do not finalize a design with this information The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications Current characterized errata are available on request Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order Copies of documents which have an order number and are referenced in this document or other Intel literature may be obtained by calling 1 800 548 4725 or go to http www intel com design literature htm Intel processor numbers are not a measure of performance Processor numbers differentiate features within each processor family not across different processor families Go to http www intel com products processor_number Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors Performance tests such as SYSmark and MobileMark are measured using Specific computer systems components
50. ck Execution statistics Statistics per Iteration The Execution Iteration Times ms table in the Analysis Results tab of the Kernel Builder for OpenCL API enables you to see the total run time the breakdown to queue submit and execute times per iteration for the given configuration To open the Execution Iteration Times ms table do the following 35 User Manual Intel SDK for OpenCL Applications 3 1 Click the Analyze button 2 Switch to the Analysis Results tab 3 Click Execution Iteration Times ms Variable Handling The Variable Handling table in the Analysis Results tab of the Kernel Builder for OpenCL API enables you to see read and read back times for each variable as well as the output file path for output parameters Clicking on this input output path pops up its content images and buffers To open the Variable Handling table do the following H 1 Click the Analyze button 2 Switch to the Analysis Results tab 3 Click Variable Handling NOTE The analysis results restore each time you select the kernel from the kernel list Deep Kernel Analysis in Kernel Builder About the Deep Kernel Analysis Deep Kernel Analysis feature of the Kernel Builder for OpenCL API enables getting profiling data for OpenCL kernels running on Intel Graphics The data includes Exact kernel runtime for each execution unit and hardware thread in GPU cycles Exact execution time for
51. clblitfns9 rtl elortfna o img ebk 0 Cl Olt mS Img Cok ruil clbltfnv8 rtl cloleTavsimg CUk 6 CLE et ive img cbk ru libcl_logger so libclang_compiler so libcpu_device so libgnustl_shared so libintelocl so libOclCpuBackEnd so libOclCpuDebugging so i bOpenCh S O4 2 libtask _executor so libtbb_preview so libtbbmalloc so opencl_ pch O O O O O O O O O O O O O O OO OOOOOOOOOOOO Use the following command to copy the files 70 OpenCL Development for Android OS adb s lt Emulator Name gt push lt filel gt system lib 2 Inthe system 1lib folder on the Android device create two links ado Ss Emulator Neue sli Ved system y ndor ile lin SS Ili CjoeinC lin Se IL rib Ooenein sO eeii eS eleilloCm cme lp c a Om cil ila 3 Copy the intel icd file to system vendor Khronos OpenCL vendors folder Use the following command ado s lt mulbaronu name gt pUSsteIneel heel Sy7sicm veoncdo w Kimonos pemely vomadoms NOTE If you close the emulator you must reinstall the OpenCL runtime after you run it again See Also Configuring the Environment Creating an Android Application To create a new application do the following 1 Run the Eclipse IDE from the SDK installation folder o On Windows OS run c sdk adt bundle windows x86_64 20130219 eclipse eclipse o On Ubuntu OS run sdk adt bundle linux x86_64 eclipse eclipse 2 Specify the Android NDK location tn Eclipse 1 Goto Window gt Prefer
52. create new buffer variable 1 Open the variable management dialog Preview Features 103 User Manual Intel SDK for OpenCL Applications CODE BUILDER ANALYZE WINDOW HELP OpenCL Kernel Development ifs New Session els Ka OpenCL Plat OpenCL Debugger Open Session OpenCL Application Analysis e ij Platform Info ioe Build Program Help i al 0 Compile Program Session Options Windows F Z Analysis Input E Setti NGS 1 Variable Ma nagement RS Code Builder Session Explorer 2 Click the Add button 4 in the Code Builder Variable Management dialog and choose Buffer in the opened context menu Use csv or binary files random values or zeroes to create buffers e When using csv files each line represents one OpenCL data type like int4 float16 and so on with a value in each column to satisfy the type size For example for a long8 at least eight columns of long numbers should exist in each line The size of the buffer is used as the number of lines to read from csv The csv file may hold more columns or lines than needed for a specific buffer but not fewer e When using binary files the content should be a concatenation of the OpenCL data type and as with using csv files the file may hold more data than indicated by the Size argument NOTE Output buffers do not need a value assigned to them If a value is assigned it is ignored 104 Preview Features Buffer Variable M
53. d session of the plug in The directory is stored under the Output Folder specified in the same window See Also Enabling the API Debugger 66 OpenCL Development for Android OS Configuring the Environment To develop OpenCL applications for Android OS you need to configure your system the following way Download Android SDK Put lt Android_ SDK_Install gt sdk platform tools in PATH environment variable Enable Intel Virtualization Technology vt x in BIOS Windows OS only Run Android SDK Manager from lt Android_SDK_Install gt sdk tools android bat Mark and install o Android 4 2 2 API 17 gt Intel x86 Atom System I mage o Extras gt Google USB Driver o Extras gt Intel x86 Emulator Accelerator HAXM Windows only 6 Install the OpenCL runtime on an Android device or emulator UBBWNEF NOTE Root permissions are required on Android devices and emulator To make the Android device be accessible without root permissions 1 Identify the Intel devices by running lsusb command for example tS exe ClUletinate tr gt lsusb Output reduced Bus 00S Device 00S ID S027 0a Intel Coro 2 Following the example above you can either change the ownership of the device file and or give permissions to the file o Change ownership of the device file to the desired user and group via the following command sudo chown USER GROUP dev bus usb 003 008 where USER and GROUP are the target use
54. e build architecture manually by unchecking the Use current platform architecture check box and selecting o Select Target operating system Current Operating System Android Operating System available on Windows OS only o Choosing the Target instruction set Streaming SIMD Extension 4 2 SSE4 2 Advanced Vector Extension AVX Advanced Vector Extension AVX2 Changing the Target Build Architecture options enables viewing assembly code of different instruction set architectures and generating program binaries for different hardware platforms NOTE Target Build Architecture options are available for the CPU device only Configuring General Options Open the Session Options menu via selecting CODE BUILDER The General Options tab enables defining the target session s platform architecture x86 or x64 96 Preview Features new_session Session Options Cancel Building and Compiling OpenCL Program To build an OpenCL program via the Kernel Development Framework feature of the OpenCL Code Builder do the following 1 Select the session with the code that you would like to build 2 Go to CODE BUILDER gt Kernel Development Framework gt Build Program Or click the Build Program button in Code Builder Build toolbar menu CODE BUILDER ANALYZE WINDOW HELP OpenCL Kernel Development t E New Session OpenCL Debugger d Open Session OpenCL Application Analysis Save Session ij Platform Info
55. e column of the Analyze Board Right click a variable name Click Delete variable or Delete all variables Building and Analyzing with Kernel Builder Viewing Analysis Results Best and Worst Configurations The Analysis Results tab of the Kernel Builder for OpenCL API enables you to see the tested global and local size best and the worst configurations based on median execution time In case only one configuration exists the result appears in both result windows Best Configuration 6f640 480 03 L128 1 05 Execution Time trish 1 10407 Worst Configuration 6f640 480 03 L01 480 05 Execution Time rst 1 61366 To export or view the analysis results do the following F 1 Click the Analyze es button 2 Switch to the Analysis Results tab 3 Right click the table and choose the action you need to perform i Export Selected Configuration 36 Export All Configurations 36 Show All Configurations Statistics for Each Configuration The Execution Statistics table in the Analysis Results tab of the Kernel Builder for OpenCL API enables you to see statistical analysis results for a selected configuration The statistics consists of the following iteration execution time values for the selected configuration Median Average Standard deviation Maximum Minimum To open the Execution Statistics table do the following H 1 Click the Analyze button 2 Switch to the Analysis Results tab 3 Cli
56. e device options for linkage of the OpenCL code use the Linkage Options menu of the ie Kernel Builder for OpenCL API Open the Linkage Options menu by clicking Linkage button Gt gt Link Options Configuring Device Options for Linkage The Device Options tab provides several configuration options 24 Building and Analyzing with Kernel Builder Linkage Options Device Options Advanced Options Gi Target Machine Local Machine VEARTOSH MOBL3 O Remote Android Machine OpenCl Device Intel CPU Intel R Graphics 6 Intel R Xeon Phi TM Coprocessor Drarget Machine group box which enables selecting the target machine e Local Machine e Remote Machine To use the Remote Machine option you need to 1 Connect an Android device with Intel processor or an emulator based on Intel x86 System Image 2 Copy OpenCL runtime to the Android device or emulator See sections Installing OpenCL Runtime on Android OS Emulator and Configuring the Environment 3 Click Setup to copy OpenCL tools to the device NOTE You need to use the Setup option each time you start an emulator device orenci Device group box which enables selecting the target device for the selected machine Intel CPU Intel R Graphics Intel Xeon Phi tm coprocessor Intel CPU on Experimental OpenCL 2 0 Platform 25 User Manual Intel SDK for OpenCL Applications NOTE Intel Graphics support is available on Window
57. e global WG size o When choosing auto all global work group size devisors and all powers of 2 smaller than the global work group size ran in the analysis dialog to compare device properties and choose the 27 User Manual Intel SDK for OpenCL Applications See Also Creating Variables Managing Variables Creating Variables Creating Buffers To create buffers using Kernel Builder for OpenCL API do the following e Select Analyze gt Variable management Or click cells in the Assigned Variable column of the Analyze Board e Inthe Variable Management dialog click Add e Inthe Select Variable Type dialog choose Buffer from the Type combo box Use csv or binary files random values or zeroes to create buffers e When using csv files each line represents one OpenCL data type like int4 float16 and so on with a value in each column to satisfy the type size For example for a longs at least eight columns of long numbers should exist in each line The size of the buffer is used as the number of lines to read from csv The csv file may hold more columns or lines than needed for a specific buffer but not fewer e When using binary files the content should be a concatenation of the OpenCL data type and as with using csv files the file may hold more data than indicated by the Size argument NOTE Output buffers do not need a value assigned to them If a value is assigned it is ignored 28 Building and Analyzi
58. e trile gt If the path includes spaces enclose the entire path with double quotes NOTE Relative path to the CL file is not supported For example err ClBbudl ar rogram 45 User Manual Intel SDK for OpenCL Applications g_program 0 NULL DE E S a a a NULL NULL According to the OpenCL standard work items execute OpenCL kernels simultaneously The Debugger requires setting in advance the global ID of the work item to debug which is before debugging session starts The Debugger stops on breakpoints in OpenCL code only when the pre set work item reaches them NOTE To work with the OpenCL Debugger plug in for Microsoft Visual Studio IDE the OpenCL kernel code must exist in a text file separate from the code of the host Debugging OpenCL code that appears only in a string embedded in the host application is not supported Create your OpenCL project with the OpenCL Offline Compiler plug in for Microsoft Visual Studio to get seamless integration with the Debugger Configuring Debugger To configure the OpenCL Debugger plug in for Microsoft Visual Studio IDE do the following 1 Run the Visual Studio IDE 2 Select CODE BUILDER gt OpenCL Debugger gt Options 3 Check Enable OpenCL Kernel Debugging 4 Set applicable values in the Select Work Items fields The values specify its 3D coordinates You can select only one work item NOTE If NDRange is not 3D leave unused dimension val
59. e6l2alcs log To Compilation started 1 166 1 error expected identifier or Compilation failed Problems view Sola eg Failed to aa a 1 for Devi Ice 1 CPU Double errs here to EE F a Context 1 was released before Program 1 with Program 1 having Referen 4 4 Resource leak Program 1 was not released Ai vies Image View Problems view Trace View Command Queue See Also Enabling the API Debu Image View This view enables visual displaying of the OpenCL Image objects in the host application Each Image object is added to the Objects View and by double clicking each Image object the bitmap is displayed the underlying pixel array gets translated into bitmap 57 User Manual Intel SDK for OpenCL Applications L Sort By 4p Show Objects Se 4 Platform 1 ntel R OpenCL E Context 1 BARR Device 1 CPU Command Queue 1 In On 4 0 Program 1 Built E db Kernel 1 SobelFilter i sam Sampler 2 Buffer 2 Context 2 Objects Solution Team Ex Class View Double click the Image you need and wait for the Image View to appear with the latest state of the image Image Image 1 History fd Save As aii Data View Image Vi Problem Trace Vi Comma Properti Properties From the Images drop down select any Image The view displays the image as bitmap 58 Debuggi
60. edian 0 765186 0 003066 0 000292 0 754382 Memory Flags CL_MEM_USE_HOST_PTR 4 Arguments Standard Deviation 0 0745105 0 00781251 0 00052964 0 069475 ena BOWE mamper Minimum 0 758032 0 002336 0 000292 0 748688 eee agree eee ae Maximum 1 00886 0 028616 0 002044 0 98696 i il S EO E 0 0 844172 0 028616 0 002044 0 792196 emel Arguments a BS Reports 3 sania 1 1 00886 0 010804 0 000876 0 99696 Arg Memory Space Access Qualifier Data Type Arg Name A SobelFilter_0 cbreport 2 0 785772 0 003504 0 000584 0 77234 0 _private NONE sampler_t Sam san SobelFilter_l cbreport 3 0 759492 0 003212 0 000292 0 748688 global READ_ONLY SobelFilter_2 cbreport aneanan 2 _global WRITE_ONLY E Session jon 1 fil D 3 global NONE _ int p ae SsTL aT 5125120 1 4 0 10 1 14476 0 003504 0 0040004 1 13179 global MONE Output 1x Show output from OpenCL Build 7 Workgroup Gi definitions Setting target instruction set architecture to Default Advanced Vectc a Global size Local size OpenCL Intel CPU device was found 512 12 4 Auto Device name Intel R Core TM i7 477 K CPU 3 5 GHz Device version OpenCL 1 2 Build 71 1 512 Auto T Auto Device vendor Intel R Corporation Device profile FULL_PROFILE y Z 0 0 Auto 4 gt 4 b Number of iterations 10 Code Soluti Class Prope Team Output Find Results 1 Breakpoints Error List NOTE All screenshots in this user manual or
61. emulator use the following command OpenCL Development for Android OS GN ocheoiwe SDK tostelil gt sdk tceols eumlatoe exe aycd test _ emulator oaceLclen size 1024 Parent topic Developing OpenCL Applications for Android OS Installing OpenCL Runtime on Android Emulator To install the Intel OpenCL runtime on Android Emulator using script do the following 1 Goto the android preinstall subfolder of the Intel SDK for OpenCL Applications 2014 installation folder 2 Use the OpenCL_Android_Install script to configure the emulator or Android device or use the following options to start the emulator manually 69 User Manual Intel SDK for OpenCL Applications o On Ubuntu OS OpenCL_Android_Install h The script requests root password o On Windows OS oOpencL_Android_Install d lt your device emulator gt NOTE On Windows only one device can be running at installation time NOTE Installation of the OpenCL runtime for Android via scripts is supported only on emulator NOTE Root permissions are required on Android emulator To configure the emulator manually 1 Copy the following files from the SDK installation folder to system vendor 1lib using the Android Debug Bridge _ oOcl_svml_g9 so __ocl_svml_n8 so __ocl_svml_s9 so __ocl_svml_v8 so clot HGI SEEL cloIrtcTtngo img ebk lt 6 Clotting amg COkertl clbltfnn8 rtl elod ona cleromen nlc mme Glare cl bilernns amg COk rtl
62. en exporting Buffer SubBuffer you get each buffer cell in a separated line The Buffer SubBuffer values are interpreted as a contiguous memory chunk containing unsigned chars as its elements When exporting an Image as a CSV the number of rows in the output CSV is the height of the image number of rows and each row represents all columns of that row joined and delimited by commas The values in the cells are interpreted according to the image channel data type so for example an Image that has CL_SIGNED_INT32 as its data type causes the resulting output to display each row as an array of signed 32 bit integers Each state is related to the API call that caused the change and is in the following format ID API Call Where ID is the number of API call that caused the change and API Call is the OpenCL API call that affected changed the object This is the same API call that it shown in the Trace View When selecting a memory object from the drop down list or alternatively selecting a memory object state the Trace View automatically highlights the API call that is related to that state 64 Debugging with Visual Studio Plug in Trace View led Save o gt Load Session a SUCCESS x Errors Filter a Return Value 28 clEnqueueNDRangeKernel CommandQue CL_SUCCESS 00 39 37 529 27 clFinish CommandQueue 1 CL SUCCESS clEnqueueNDRangeKernel CommandQue CL SUCCESS 25 clSetKernelArg Kerel 2 2 4 1CFDEC CL
63. ences gt Android gt NDK 2 Enter the Android NDK path 3 Create a new Android project 1 Goto File gt New gt Project gt Android gt Android Application Project 2 Add the appropriate information For example 71 User Manual Intel SDK for OpenCL Applications New Androld Application New Android Application Ay The prefix com example is meant as a placeholder and should not be used Application Name OpencCLFirstApp Project Name OpencLFirstapp Package Name 4 com example opencifirstapp Minimum Required SDK 0 API 16 Android 4 1 Jelly Bean Target SDK 9 API 17 Andr oid 4 2 Jelly Bean Compile With API 17 Android 4 2 Jelly Bean Theme Holo Light with Dark Action Bar m O Choose the highest API level that the application is known to work with This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app s forward compatibility with the target version The application is still able to run on older versions down to minSdkVersion Your application may look dated if you are not me 3 Click Next in all remaining forms 4 Click Finish 4 Run the created emulator 5 Install the OpenCL runtime on the emulator or device 6 Develop the application and run it using the Intel OpenCL software technology implementation 1 Right click the project name in the Project
64. erApp Microsoft Visual Studio Administrator Quick Launch Ctrl Q f A X FILE EDT WEW PROJECT BUILD DEBUG TEAM SQL TOOLS TEST CODE BUILDER ANALYZE WINDOW HELP iD 8 aa gt Local Windows Debugger Debug Win32 aA BBA Bue A OpenCL Platform Intel R Corporation OpenCL Device Intel CPU TargetArchitechture x86 Select Kernel SobelFilter rp BS Code Builder Session Explorer v Code Builder Variable Management not ss A ix Se x x t ES Session session_0 1 files Select Report Execution View z C3 Add K3 Delete Q Delete All Bg 4 9 Session SobelFilter 1 files 4 Buffers o 4 OpenCL Files Best Configuration 512 512 0 4 0 05 Average execution time s 0 7105 4 buffer_0 3 SobelFilter cl Data Type char i 4 Build Artifacts Worst Configuration 512 512 0 1 1 0 Average execution time s 2 0809 Size 155 B SobelFilter ll jm eee aa ae A a Source Random Values 9 B SobelFilter asm Gx Gy Gz Lx Ly Lz Iterations Total Queue Submit Execution IO Mode Input m PR g SobelFilterir 512251220 11 0 10 2 08097 0 0004088 0 0048472 2 06794 lt Memory Flags CL_MEM_USE_HOST_PTR 5 SobelFilter_x86 spir 4 buffer_1 a SobelFilter_x64 spir SLA Si al Ps 0 aici ee 0 0049932 ili Data Type int z SobelFilter_x86 ll mani e l A Size 1024 z Sobeiran aai Measur ment Iterations Total Submit Queue Execution Sa Randam Wolke 4 P3 Kernels Average 0 79789 0 0063072 0 0005548 0 782239 10 Mode Input 4 45 SobelFilter M
65. ertain performance degradation To get more accurate profiling results use the runtime directly by pushing CtrI F5 Start w o Debugging or disabling API Debugger in the plug in configuration menu Only 2D images are supported for viewing which is memory objects that contain CL_MEM_OBJECT_IMAGE2D In their image_type field inside their descriptor cl_image_desc Images above 2GB are not supported and will not be displayed The bitmaps shown in the Image View are merely an 8 bit RGBA approximation of the underlying pixel array of the associated images Behind the scenes the plug in does a liner color conversion from the input range of the pixels which can be any type supported by the OpenCL runtime for example CL_SNORM_INTS8 CL_UNSIGNED_INT16 and so on to the 0 255 range As a result the presented colors might not accurately represent the bitmap as expected See Also Enabling the API Debugger Data View The Data View enables visual displaying on a grid of all the OpenCL Memory Objects Images Buffers and SubBuffers that were instantiated in the host application 61 User Manual Intel SDK for OpenCL Applications Each Memory Object is added to the Objects View and by double clicking Buffers SubBuffers you can display the buffer contents or by double clicking an Image you can view the raw pixel data associated with the image Objects Tree z Platform 1 Intel R OpenCL E Context 1 A Device 1 CPU o Comma
66. h Kernel Builder for OpenCL API do the following 1 Click the Link Ot button 2 Inthe Select IR Files window click Choose Files and select the compiled objects and libraries to link 3 Click Done If the linkage succeeds the Console window background color turns green otherwise it turns red When linkage completes you can save the created executable or library by clicking the Create a ey ar Program Binary button Configuring Options To configure the Kernel Builder for OpenCL API options open the Options menu by selecting Tools gt Options Configuring Device Options The Device Options tab provides several configuration options Device Options Advanced Options amp Target Machine Local Machine Remote Android Machine E OpenCl Device Intel CPU Intel R Graphics 6 Intel R Xeon Phi TM Coprocessor Drarget Machine group box which enables selecting the target machine 21 User Manual Intel SDK for OpenCL Applications e Local Machine e Remote Machine To use the Remote Machine option you need to 1 Connect an Android device with Intel processor or an emulator based on Intel x86 System Image 2 Copy OpenCL runtime to the Android device or emulator See section Installing OpenCL Runtime on Android OS Emulator 3 Click Setup to copy OpenCL tools to the device NOTE You need to use the Setup option each time you start an emulator device orenci Devi
67. he runtime directly by pushing CtrI F5 Start w o Debugging or disabling API Debugger in the plug in configuration menu 65 User Manual Intel SDK for OpenCL Applications Memory objects above 2GB are not supported and are not displayed e Buffers Sub Buffers that are set as parameters to kernels via clSetKernelArg are fetched into API Debugger after each kernel enqueue operation regardless of the memory flags they were created with This means that even buffers created with CL_MEM_READ_ONLY are fetched behind the scenes See Also Enabling the API Debugger Memory Tracing Memory tracing enables the user to capture the session of the debugging into a file and also to load a previously stored state into the views The stored state contains e State of all the views this includes all the data that is filled in the various views of the plug in e Images bitmaps if Enable Dumping I mages is on e Memory objects raw data if Enable Raw Data is on The state can be stored by either of the following ways e Automatically when host application ends e Manually by going to Trace View gt Save gt Save Session trace The automatic memory tracing contains e State of all the views e CSV of all API calls that occurred during the execution And can be enabled via CODE BUILDER gt OpenCL Debugger gt API Debugger gt Other settings gt Auto generate session This option creates a separate directory for each capture
68. hit a breakpoint multiple times To examine a specific segment of code for a single work item you should manually insert a condition on get_global_id 44 Debugging with Visual Studio Plug in OpenCL Debugger OpenCL Debugger plug in for Microsoft Visual Studio IDE enables debugging OpenCL kernels using the Microsoft Visual Studio software debugger GUI The Debugger enables debugging host code and OpenCL kernels in a single Microsoft Visual Studio debug session Debugger supports existing Microsoft Visual Studio debugging windows such as Breakpoints e Memory view Watch variables including OpenCL types like float4 int4 and so on e Call stack Auto and local variables views NOTE Debugging is available only for CPU device If the code should run on Intel Graphics debug on CPU device during development phase then change the target device For debugger limitations and known issues refer to the Intel SDK for OpenCL Applications 2014 Release Notes Enabling Debugging in OpenCL Runtime To enable debugging mode in the Intel OpenCL runtime for compiling OpenCL code using OpenCL Debugger plug in for Microsoft Visual Studio IDE do the following 1 Add the g flag to the build options string parameter in the clBuildProgram function 2 Specify full path to the file in the build options string parameter to the clBuildProgram function accordingly including the CL file name S lt Pull path Eo the pen L sourc
69. iginate from Microsoft Visual Studio 2012 The Kernel Development Framework is also supported in Visual Studio versions 2010 and 2013 Kernel Development Framework Session About the Development Sessions Work in the Kernel Development Framework is managed through session To create build or analyze an OpenCL kernel you need to create a session A session contains e A file with an OpenCL program e Build artifacts o Generated LLVM code o Assembly code o Intermediate binary files e OpenCL kernels with assigned variables and analysis reports Creating a New Session To create a new session do the following 1 Go to CODE BUILDER gt Kernel Development Framework gt New Sessions Or click the New Session button te in the Code Builder Build toolbar menu 92 Preview Features 2 Specify the session name path to the folder to store the session file and the content of the session can be either empty session or with pre defined OpenCL code Name new _ session Location C Code Session Content Empty session Duplicate files to session folder Done Cancel 3 Click Done Once the session is created the new session appears in the Code Builder Session Explorer Dialog Code Builder Session Explorer Pew Session new session 1 files OpenCL Files program cl Build Artifacts Kernels Reports If you don t see the Code Builder Session Explorer dialog go to CODE BUILDER gt Kernel
70. in OpenCL Runtime ssssssrserrssrensrrrsrrrsrrrrrrrrrrerrrerrrrrerrrrerrrerrrrrent 45 Contournng DeDUJOE aire cor pesni a E e ae aoii 46 Legal Information Changing Debugging POrDonuciiusriii eeuna REA EE AA a 46 TFOUDIESMOOEING Ne DeDUJOET arsioreis korei aea a a a e inde dea hoe ea tance NA 47 APRI Depuggingun Visuals tudio sick toncsiceck er a Aa OAA E A 47 OpenC ETAPI DEDUGQG Cres wixinesieecolssdindddeieteetalnieemnacsoiganerdidcouteieanuiynacaeolervakiae 47 Enabling the API Debugger xcivianesseiiaviecdiaalecidiaesinw a AE wend ae legedida seed vaaeeen eee Na 48 Mace WIG Westetectaubes paaneteetiettacnaanteneeb ae osaces du ober waned vest cucone ace a ubek decedee E tee tine 49 Ob ects Tree VieWirisevvescengverveveveueddedumie na vee reed dead weeaweaedldaianeeyatbuseedden puna EN ss 51 PFODEIICS VIEW canoniera Eo nanos cnasekeunret cates A Chetan madenion malware sadsouiecteneanrnates 52 Command Queue VIEW esa ciacrdaartudoee E E A ET E EEEN 55 PRODIGIMNS VIEW Sienra E aa AEE E A E E AEAEE 56 MaAJGS VIEW enearo ei A NE EE ENEAN A Ena a ieaiai 57 Data VIEW aoan E AEE E A EEE E E E AE NR 61 Memory ITa CNO saas r a a a a a E O 66 OpenCL Development for Android OS sssssssss22222222222u22222022202220u20uu20nunnnnnnnnnnnnnnnnnnnnnn 67 Configuring TNe ENVIFONIMENE srrarieniia innan N A E A AE ONE EE NA 67 Creating an ANGrOld EmMa ession a a E E O ERN 68 Installing OpenCL Runtime on Android Emulator ses
71. ing sessions are not supported with the OpenCL API Debugger This includes attaching the debugger to more than one process or opening multiple instances of the Visual Studio and debugging processes concurrently See Also Trace View Objects Tree View Properties View Command Queue View Problems View Image View Data View Memory Tracing Enabling the API Debugger To use the API Debugger do the following 1 Start the Microsoft Visual Studio IDE 2 Goto CODE BUILDER gt OpenCL Debugger gt Options gt API Debugger 3 Check Enable OpenCL API Debugger 4 Insert breakpoints in the application in different OpenCL API calls and then start debugging with F5 5 Open the needed API Debugger views by selecting CODE BUILDER gt OpenCL Debugger and select the view you need The API Debugger updates the view panes when e The Debugger hits a breakpoint in Microsoft Visual Studio IDE e One of the views behavior changes which means you click a buttons e The host application execution ends So to see data in the views 1 Insert some breakpoints in your application in different API calls or run the application with Start Debugging F5 2 Then open the needed views via CODE BUILDER gt OpenCL Debugger 48 Debugging with Visual Studio Plug in CODE BUILDER ANALYZE WINDOW HELP OpenCL Kernel Development OpenCL Debugger 38 Objects Tree View OpenCL Application Analysis t db Command Queue View ig Platfor
72. ive OpenCL objects API trace command queue and so on o to either a binary file trace that can be later loaded with the Load Session button o or you can export a list trace of all API calls into a csv file e Load Session enables restoring the state of the views from a previously saved trace file either using Save As or Generate trace file option in the API Debugger settings 49 User Manual Intel SDK for OpenCL Applications NOTE This feature is available only when Visual Studio IDE is not in debug mode as views are synced with the application you debug e Success Errors enables filtering successful or failed API calls e API Display Mode toggles between views o Function name only o Function name and arguments o Function name with argument names and values lay Mode nction names only Program 1 num_device e context Context 1 c Functions with arguments Functions with arguments names and values e Filter enables filtering out API calls by name Start typing device for example to get only API calls with device in their name Trace View led Save 9 Load Session a SUCCESS Filter device API Return Value Time 14 clGetDevicelnfo Dewice 1 412 CL_SUCCESS IRFS clGetDevicelnfo Dewice 1 413 CL SUCCESS 17 47 54 1771 GetDevicelnfo Device 1 413 CL SUCCESS LARA TTL GetDevicelDs Platform 1 42 CLSUCCESS 17 47
73. l Kernel Execution Statistics Timestamps Siadet The chart shows 12 bars of utilization across the profiling time Each color represents a specific EU while the average time of an EU utilization over time range determines the height of each color on each bar Double clicking any of the colored parts opens a dialog showing the hardware thread activations across time 38 Building and Analyzing with Kernel Builder i a JE ah Tag Half Slice 0 EU 8 Ea EU Hardware Thread 7 J lhread J Thread 2 Hi Thread activators on the EU acess Hne ial 245950 247035 246146 2992544 250353 Time GPU Cycles mk EOG dal LD Click the legend to the left to toggle each hardware thread appearance on the graph on the right Viewing Execution Statistics of Deep Kernel Analysis The following tables of the Kernel Builder for OpenCL API Deep Kernel Analysis Results tabs show textual tables with execution data e EU Statistics data on the execution units on the Intel Processor Graphics physical location SIMD width and number of activations of the hardware threads to run the kernel e Full Kernel Execution Statistics reflects total kernel execution time on each EU including Statistics per execution unit and their averages o Average o Median o Minimum amp maximum o Standard deviation e Timestamps Statistics reflects total execution time for each of the selected lines 39 Building with Kernel Bui
74. l size and local sizes per workload dimension in the Workgroup size definitions group box 6 Click Analyze to wrap a specific kernel and execute analyses You can use the local size s text boxes for several different test configurations e Set single size value for a single test e Add several comma separated sizes for multiple tests e Set 0 to utilize the default framework assigned local size e Click Auto to enable the Kernel Builder iterate on all sizes that are smaller than global size and device maximum local size Workgroup size definitions Global size Local sizets Sio 1024 a Auto Y 1024 Autko Auto Zi 1024 1 2 3 64 ato Number of iterations i Also consider the following e Using each option is available for each dimension To analyze the kernel in its designed conditions set a single value e To find the local size that provides higher performance results click Auto or set a list of comma separated values e To improve the analysis accuracy run each global and local work size combination several times by increasing the Number of iterations value Several iterations minimize the impact of other system processes or tasks on the kernel execution time e Use the Device Information appropriate device for the kernel e When running analysis on Experimental OpencL 2 0 Platform you may use local WG size as described in OpenCL 2 0 specification o Local work group size doesn t have to be a divisor of th
75. lder Command Line Interface Kernel Builder for OpenCL API provides a command line interface The tool supports Intel processors Intel Graphics and Intel Xeon Phi coprocessors also providing full offline OpenCL language compilation which includes e Creating executable Intermediate Representation IR from source code e Creating compiled object from source code e Creating executable IR or library from object IR and libraries The command line tool is located in INTELOCLSDKROOT bin under x86 or x64 folder depending on OS To use the Offline Compiler command line interface 1 Start the command line 2 Type ioc 4 to run 64 bit version Type the run parameters in the following sequence TOC VOOr TOn Cma lt commamd gt lt argqumeme gt lt OpErons gt Offline Compiler supports the following commands Command Use Description Creates executable IR from source code Default command in case nothing is specified cmd build cmd compile Creates compiled object IR from source code comd 1ink Creates executable IR or library from object IR and libraries Offline Compiler supports the following arguments Argument Use Description Builds OpenCL code from the input_file_path file Use the input argument with the build and compile commands input lt input_file_path gt binary lt binary_files gt Links comma separated binary files Use with the link command version Shows the tool version
76. lso Using Kernel Builder Watching Variables and Kernel Arguments The Watch Variable box contains variable names and values used by the kernel being debugged Watch Variables Variable Coords fSobel horizontal Buffers and images passed as kernel arguments appear in the Arguments box Mame input_image output_image Click any variable name to see its content See Also Using Kernel Builder 86 Preview Features OpenCL Analysis Tool About the OpenCL Analyze Tool OpenCL Analyze Tool is a preview feature that provides basic performance information for OpenCL applications The Analyze Tool enables to collect trace data of OpenCL APIS OpenCL kernels and OpenCL memory operations You can use the Analyze Tool to find out the time of execution the frequency and the work size data of each OpenCL kernel that was launched during your program s execution You can also find statistics of all OpenCL API calls and data about memory commands executed in your program When you use the Analyze Tool you create an Analyze Session which contains the configuration data for collecting performance information and the results of the analyze run You can explore all the analyze sessions that you created in the Analyze Session Explorer window Analyze Sessions Explorer ix 4 Profiling Sessions 4 BrtonicSort_20140728 d capture capture_l capture_2 capture_s BitonicSort_20140728 1 BitonicSort_2014
77. m Info Properties View Help a Trace View Problems View a Image View Data View Options Ctrl 1 See Also Trace View Objects Tree View Properties View Command Queue View Problems View Image View Data View Memory Tracing Trace View The trace view contains trace of all OpenCL API Calls during the execution API call arguments returned values and time of execution To access the trace view select CODE BUILDER gt OpenCL Debugger gt Trace View Trace View API Return Value Time 29 clReleaseContext Conte CL_SUCCESS 17 48 26 720 28 clReleaseCommandQue CL SUCCESS 17 48 21 219 z clReleaseProgram Progr lc _SUCCESS 17 48 21 218 2 clReleaseKernel Kernel CL_ SUCCESS 17 48 21 2715 25 clReleaseMemObject Bu CL_SUCCESS 17 48 00 757 24 clReleaseMemObyect Bu CL SUCCESS 17 46 00 757 Data View Image View Problems wiew Trace View Command Queue Use the following buttons to control the view e Save enables saving the current state of all views with l
78. me the date and an incrementing session number When profiling begins and also each time you pause and resume the data collection during the session a new capture subdirectory is created in the session directory The capture directory is called capture and an incrementing number for example capture_1 capture_2 and so on The files in that directory comprise the capture reports These are the types of files in a capture directory o csv capture reports in CSV format o bin capture reports in binary format you can open such reports in Visual Studio from the Analyze Sessions Explorer In addition a session file is created in the session directory This file stores the data about session configuration You can use it to create and run another similar session Configuring the Analyze Tool You can use the Analyze Session Settings dialog to change the reports directory and also to change the connection info for the analyze sessions To open the Analyze Session Setting dialog go to CODE BUILDER gt OpenCL Application Analysis gt Settings 90 Preview Features E Analyze Session oo EF Reports Location Place the output reports in the solution directory when a solution is opened Use this location to place the output reports when there is no opened solution C PerfLogs n Connection Find available port in this range From Port Number 20000 To Port Number 60000 OK Ca
79. ncel Report Location full path to the directory that contains analyze reports You can mark the Place output reports in the solution directory check button In this case if you open a solution in Visual Studio the Analyze Tool ignores the specified directory and places the analysis reports into the solution directory Connection range of ports number for the Analyze Tool to find an available port The Analyze Tool uses a port in the specified range to establish connection with Visual Studio Kernel Development Framework About Kernel Development Framework Kernel Development Framework is preview feature of native integrated development environment in the Microsoft Visual Studio that enables you to build and analyze OpenCL kernels The framework supports Intel Architecture processors Intel Processor Graphics and Intel Xeon Phi coprocessors as well as remote development on Android devices The tool provides full offline OpenCL language compilation which includes OpenCL syntax checker Cross platform compilation Low Level Virtual Machine LLVM viewer Assembly code viewer Intermediate program binary Generator The feature also provides a way to assign input to the kernel test the correctness and analyze kernel performance based on group size build options and target device 91 User Manual Intel SDK for OpenCL Applications J SobelFilt
80. nd Solution name fields and click OK Create a New OpenCL Project from OpenCL Project Template for Windows To create an OpenCL template project for Windows platforms in Microsoft Visual Studio IDE do the following 1 Goto File gt New gt Project 2 Select OpenCL templates from the Templates tree view 3 Select Code Builder Project for Windows b Recent NET Framework 4 5 Sort by Default 4 Installed s CodeBuilder Project for Windows Visual C Type Visual C 4 Templates An OpenCL Project b Visual Basic Empty OpenCL Project for Windows Visual C b Visual C 4 VWiewsl fa Fill the Name Location and Solution name fields and click OK In the Code Builder wizard for OpenCL API dialog you can select the basic settings for the behavior of the OpenCL application and kernel The parameters that can be set are platform name device type kernel type images or buffer manipulation build options and local work group size behavior Each field has a short tool tip explanation PaA 74 Preview Features Basic Settings Platform Name Intel Device Type GFU Create Kemel with Images Create Kemel with Buffers Build Options Pills explicit Local Work Group Size ph lt Previous Cancel r Click Finish to create the default template project or click Next to open the Advanced Settings screen enabling you to set some advanced options like whether to enable profiling queue and the kernel
81. nd then execute the kernel Consider using clEnqueueNDRangeKernel Once you hit the breakpoint place another breakpoint in the target kernel and issue a run command gdb b square Broakpoant gt ar Ox 00000 ss Filer Continue the run until the GDB stops inside the kernel and then query the symbols gaby ee 1 __kernel void square 2 o e ine Aoo 2 ee Ere EDL E 4 const unsigned int nElems 6 int index get_global_id Q0 7 if index lt nElems 8 Se e Ene S a a e e a o e E oea 2 FO gdb p nElems e ad GPAD ENA 40 SZ na gdb You can also examine the call stack and variables in the calling frames For example SdP lone 0 square input Ox3t7e3ce0 cutpurt Uxseced900 nElems 1024 at Simple _sgquare cl 6 TA OOC OOO VE 7 OOO o Ee tinh ss are 43 User Manual Intel SDK for OpenCL Applications To OOOO think 64bdtZ 3 sl saivwokekhernic lk params SIZ pParameters pEntryPont at ii gbd When the kernel compilation completes and GDB receives a notification of the kernel code the GDB stops inside a kernel After that you can find the source files GDB recognizes including the files that contain the OpenCL kernels by issuing the i sources command to GDB The path is the full route to the OpenCL source file provided with the s flag while building the kernel During the debugging session all work items execute simultaneously which means that different work items
82. ndQueue 1 In Order Ly Program 1 Built ei ig gt Kernel 1 RowFilter 3 feed src dig dst width height fi srcStride fia dstStride 2 filterKernel Objects Tree Solution Ex Team Explo Class View Double click the Buffer you need and Data View window appears with the latest state of the buffer sub buffer Data View Memory Object Buffer History 39 clEnqueueNDRangeKerne Type Pe Data View Image View Problems view Trace View Command Queue Properties View Properties From the Memory Objects drop down select any memory object and the view shows the raw data associated with the object 62 Debugging with Visual Studio Plug in Data View Memory Object Image 1 History 42 clEnqueueWritelmage 1 Ree RE Re 0 89 0 54 0 49 1 00 0 87 0 54 0 52 17 00 0 87 0 53 0 50 1 00 0 89 0 54 0 49 1 00 0 89 0 54 0 49 1 00 0 87 0 54 0 52 1 00 0 67 0 53 0 50 1 00 0 89 0 54 0 49 1 00 0 89 0 54 0 49 1 00 0 87 0 54 0 52 1 00 0 67 0 53 0 50 1 00 0 89 0 54 0 49 1 00 0 89 0 54 0 49 1 00 0 87 0 54 0 52 1 00 0 67 0 53 0 50 1 00 0 89 0 54 0 49 1 00 0 89 0 54 0 49 1 00 0 87 0 54 0 52 1 00 0 67 0 53 0 50 1 00 0 89 0 55 0 48 1 00 0 89 0 55 0 48 1 00 0 89 0 51 0 44 7 00 0 67 0 51 0 44 1 00 0 89 0 55 0 47 1 00 0 89 0 53 0 47 1 00 0 88 0 55 0 45 1 00 0 66 0 52 0 45 1 00 Data View Image View Problems view T
83. ng with Kernel Builder Create Buffer Variable Name 512 float input I0 Mode Memory Space Data type Size Memory flags to use Get output buffers data Initialization options Input file CSV or binary Use random values Zero the entire buffer See Also Creating Images Creating Samplers Choosing Memory Options Creating Images To create images using Kernel Builder for OpenCL API do the following e Select Analyze gt Variable management Or click cells in the Assigned Variable column of the Analyze Board e Inthe Variable Management dialog click Add In the Select Variable Type dialog choose Image from the Type combo box Use input bitmap files and the parameters to create images Create output images with the correct size type channel order and so on 29 User Manual Intel SDK for OpenCL Applications Create Image Vanable Name output_bitmap Access Qualifier Data type imagezd t Width Af Height 430 chanel Data Type Chamel order access Mode Get output image data The Get output image data checkbox disables reading back the output buffer or image It means that you can try more than one combination of global or local work sizes where there is no need to read the same output for all the combinations See Also Creating Buffers Creating Samplers Choosing Memory Options Creating Samplers To create samplers using Kernel Builder for OpenCL API
84. ng with Visual Studio Plug in The history drop down enables viewing various states of the selected image where each state is a result of an API call If for instance you create an image with all pixels set to 0 you see on Image creation the following view Image View Image Image 1 Histor 23 clCreatelmage save As Data View Image Vi Problem Trace Vi Comma Properti Properties Now after running the kernel on the selected Image you can observe that it was updated indirectly by clEnqueueNDRange API call therefore causing the kernel to run 59 User Manual Intel SDK for OpenCL Applications Image View Image Image 1 r History 43 clEngueueNDRa d Save s Data View Image Vi Problem Trace Vi Comma Properti Properties Each state is related to the API call that caused the change and is in the following format ID API Call Where ID is the number of API call that caused the change and API Call is the OpenCL API call that affected changed the object This is the same API call that it shown in the Trace View When selecting an Image from the drop down or alternatively selecting an Image state the Trace View automatically highlights the API call that is related to that state aod pee Trace View bel Save O Load Session E 42 clEnqueueWritelmage ve clEnqueueReadimage C CL_SUCCESS 00 03 24 187 cl
85. ngle view all errors and warnings that occurred during the execution To access the view select CODE BUILDER gt OpenCL Debugger gt Problems View Problems view Decription i Save As ENES Resource leak Kaaa 1 was not released Data View Image View Problems view Trace View Command Queue 56 Debugging with Visual Studio Plug in Problems View supports the following features e Displaying warnings and errors of kernel compilation Showing uninitialized kernel arguments each one of them is set by calling clSetKernelArg for each argument e Releasing OpenCL objects in the out of order mode for example when you release a program object before releasing its kernels clReleaseProgram before clReleaseKernel e Resource leaks at the end of the program an error entry is added for each OpenCL resource programs buffers images and so on that is not released e API call failures when an OpenCL API call fails an error entry is added to the problems view You can right click the entry to jump to the line item in the trace view that caused the failure Double clicking an error in the Problems View opens the compilation error log message in the code editing area gt lt ToneMapping_2012 Microsoft Visual Studio FILE EDIT VIEW GIT PROJECT BUILD DEBUG TEAM TOOLS TEST ANALYZE in fl m X Local Windows Debugger Debug fa _ TE Ta ee tee eat eels ler eee 1 Pcosco bs9c 437 a e45l
86. nore All Default Libraries Input Ignore Specific Default Libraries Manifest File Module Definition File Converting Existing Project into OpenCL Project OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE enables you to convert a Standard C C project to an OpenCL project and vice versa To convert your project do the following 1 Right click the project you want to convert in the Solution Explorer 2 Inthe project menu click Convert to a project for OpenCL API Building OpenCL Project To build the solution using OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE click Build gt Build Solution When building solution Intel OpenCL compiler automatically builds attached OpenCL kernels See the build result in the Output build dialog of the Microsoft Visual Studio IDE Output eee eee ee ene ory ary dry aryhene tuners aggre wh Chas hh PhS CP MLA RUE RR mmm eee ecg A Er Tene E Ne Neg yee eee Ohara ar Puree genres pm gan CNS 8s GAS Us ORLA CR BORIS REP ee rare elt Irene ee ee ra ence ee q x Show output from Build k rel gt Rebuild All started Project ConsoleApplicationl Configuration Debug Win3 ry l gt stdafx cpp l gt ConsoleApplicationl cpp 1 gt ConsoleApplicationl vcxproj gt c visual studio 20 12 Projects ConsoleApplication1 Debug ConsoleApplicationl exe Rebuild All 1 succeeded failed skipped Using OpenCL Build Properties
87. of size 4 the csv file contains Oy ley So iG ee I Cee IO lore O70 4 52 Zero and random values are available as with regular type buffers You can edit a struct In such case any buffer using the struct reinitializes with the new data 32 Building and Analyzing with Kernel Builder You can delete a struct as long as other structures or buffer variables do not use it When working with uniform variables fill the values in the pop up dialog for every field to insert values for the struct For example Arg Memory Space Access Quailifier Data Type Mame Assigned Variable 1 _global MONE point out Click Here To Assign 2 _ global MONE uint structsize Click Here To Assign point pointfink x 1 pointiint oO pointiFloat value 3 56 mre NOTE You must define structs with the same names as used in the code to enable the Kernel Builder to assign a variable to the argument See Also Creating Variables Editing Variables Choosing Memory Options You can change memory options of buffers or images using Kernel Builder for OpenCL API Refer to the relevant sections of this guide for guidelines on creating or editing variables NOTE You are not limited in selecting options Avoid selecting the option combinations that are forbidden by the OpenCL 1 2 specification otherwise you may encounter errors upon analysis To choose buffers and images memory options do the following 1 Open the v
88. on and off NOTE Do not use the Auto feature for best local group size configuration with Deep Kernel Analysis Define a single group size for both global and local for each dimension used Viewing Deep Kernel Analysis Results After the profiling is done the data is collected and is shown in a graph and a few tables Execution Duration 37 User Manual Intel SDK for OpenCL Applications Select Kernel to Analyze SobelFiter Refresh eels Assign Parameters Analysis Results Deep Kernel Analysis Results Profiling Results for group size s X 512 3 Y 512 4 HV Thread utiization on the EUs acess time Lf a Half Sice 0 EU a Half Shee 0 EU 1 Half Sioe 0 EU 2 a Half Sice 0 EU 3 Half Sice 0 EU 4 a Half Sice 0 EUS Half Sice 0 EU S Half Sice 0 EU 10 a Half Shoe 0 EU 11 Half Sice 0 EU 12 a Half Slice 1 EU 0 Half Slice 1 EU 1 a Half Slice 1 EU 2 Half Slice 1 EU 3 at a Half Slice 1 EU 4 Half Sice 1 BUS s Half Sice 1 EU 9 a Half Shoe 1 EU 10 a Half Sice 1 EU i1 0 Half Sice 1 BU 12 95 63 Active HW threads m E eS CACI ELIP ME A ce a O6SERr 2 OFS OGGEOC iT naa i a L Zi 66802 0 m OO Tt iT ino aS PEESI GSE i a oo a ha E E ben OO OO O imma oo fs rhl0Gt 68o i bane a PERCHES init Pm nm eS TORS 9 Mmm mmm m ee a T6LSS C6 a BAr ENERO ld aa Execution Duration EU Statistics Fu
89. oose a target device do the following Go to Project gt Properties Click Configuration Properties gt I ntel SDK for OpenCL Applications gt General Change the Device option according your needs Click OK ee Generating and Viewing Assembly Code OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE enables generating assembly representation of the OpenCL code To enable generating and viewing the assembly code do the following 1 Goto Project gt Properties 2 Click Configuration Properties gt Intel SDK for OpenCL Applications gt General 11 User Manual Intel SDK for OpenCL Applications Code option to Yes Platform Active Win32 bf Configuration Manager 3 Change the Generate Assembl Configuration Actrve Debug t Common Properties Include a Configuration Properties Device CPU device CPU 4 Intel SDK for OpenCL Appl SIMD Default simd default General Generate assembly code Yes asm eee Cipla alione Generate Ilvm code No Warnings Generate binary file Mo Command Line 4 Click OK CES E a a hola awtiane After the build you can open the generated assembly file in the Visual Studio editor by double clicking the message in the Output view Output 1x Show output from Build Z ER n l gt Build succeeded ae l gt ct wisual studio 2012 Projects ConsoleApplication1l ConsoleApplicationl Debug OpenCLFile asm Generated assemt l g
90. ormation on the OpenCL Runtime for Intel CPUs and Intel Xeon Phi coprocessors Updated guideline for using Code Builder options in Visual Studio Added a section about the OpenCL 2 0 Experimental Development Environment Renamed the JumpStart feature now it is called the OpenCL New Project Wizard Added new chapter about the new tool OpenCL Analysis Tool Added new chapter about the new tool Kernel Development Framework Other minor corrections Please submit your feedback if you have any comments or suggestions regarding this document contents structure and so on Code Editing and Building with Visual Studio Plug in OpenCL API Offline Compiler Plug in for Microsoft Visual Studio IDE OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE enables you to develop OpenCL applications with Visual Studio IDE The plug in supports the following features New project templates New OpenCl file c1 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 project template or convert an existing project into the OpenCL project See Also Converting Existing Projects into OpenCL Projects Configuring Microsoft Visual Studio IDE To configure the OpenCL API Offline Com
91. piler plug in for Microsoft Visual Studio IDE do the following 1 Inthe Visual Studio software select Project gt Properties 2 Inthe C C gt General property page under Additional Include Directories enter the full path to the directory where the OpenCL header files are located INTELOCLSDKROOT include Configuration Active Debug Platform Active Win32 Configuration Manager a C C a Additional Include Directories SCNTELOCLSDKROOT include General Additional Fusing Directories Optimization Debug Information Format Program Database for Edit And Continue Z1 3 Inthe Linker gt General property page under Additional Library Directories enter the full path to the directory where the OpenCL run time import library file is located For example for 64 bit application User Manual Intel SDK for OpenCL Applications INTELOCLSDKROOT lib x64 Confiquration Active Debug Platform ActiveWin32 we Configuration Manager 4 Linker Additional Library Directories S INTELOCLSDKROOT ib x64 General Link Library Dependencies Yes Input Use Library Dependency Inputs No 4 In the Linker gt Input property page under Additional Dependencies enter the name of the OpenCL ICD import library file OpencL 1ib Configuration Active Debug Platform ActiveWin32 O Configuration Manager 4 Linker Additional Dependencies OpenCL lib General Ig
92. plication the new analyze session that you created appears in the Analyze Explorer window and the following reports are generated and appear in the main Visual Studio window e API Call lists statistics of calls made to the OpenCL API including the number of times the API call was called the number of times error returned and statistics on the elapsed time each API call took while executing 88 Preview Features choose a wiew API Calls analysis session from captuing duration Avg Duration ps Min Duration prs Max Duration ps Api Name Count Errors Total Time ps clBuildProgram 1 0 1103853 1103853 1103853 1103853 clCreateButfer 1 0 1 8 178 178 178 clCreateCommandQueve 1 0 202 202 202 202 clCreateContext 1 0 1830318 1830318 1830318 1630318 clCreateKernel 1 0 2636 2636 2636 2636 clCreateProgramWithSource 1 0 134 134 134 134 clEnqueueNDRangeKernel 3 W 140446 468 a2 filter curently displayed X out of Y Api Name Start Time ps End Time ps Error code clEnqueveNDRangeKernel 173244896626 173244896918 g clEnqueueNDRangeKernel 173244925994 173244926235 0 clEnqueueNDRangeKernel 173244942159 175244942590 g clEnqueueNDRangeKernel 173244964033 173244964272 0 clEnqueueNDRangeKernel 173244979774 175244979996 g clEnqueueNDRangeKernel 173245003709 173245003942 0 clEnqueueNDRangeKernel 173245025703 173245025945 0 clEngueveNDRangeKkernel 173245041886 173245042106 li clGetDevicelDs 2
93. r and group to have permissions to the device o Give permissions to everyone Sudo chmod 666 dev bus usb 003 008 Udev configuration files should be edited to enable full permissions without sudo 67 User Manual Intel SDK for OpenCL Applications 3 Edit any file s that conform to the following convention etc udev rules d N android rules and append the following line SUBSYSTEM usb ATIRS idVendon s087 ATTRS idProduct 0a21 MODE 0666 If nO android rules file are present in etc udev rules d create the following file etc udev rules d 51l android rules 4 Next step enables read and write opetations on an Android device Call adb root and then call adb remount See Also Installing OpenCL Runtime on Android OS Creating an Android Emulator To create a new Android emulator 1 Run Android SDK Manager from lt Android_SDK_Install gt sdk tools android bat 2 In Android SDK Manager select Tools gt Manage AVDs and define new emulator 68 Skin Front Camera Back Camera Memory Optons Internal Storage SD Card Emulation Options gt Edit Android Virt kest_emulator 4 7 WXGA 1280 720 xhdpi Android 4 22 AP Level 17 Intel Atom x86 Hardware keyboard present N Display a skin with hardware controls None None 7 RAM 512 VM Heap 128 Snapshot Use Host GPL Chrernde the easing AND with the same name To run the created
94. race View Command Queue Properties View Properties The history drop down enables viewing various states of the selected memory object where each State is a result of an API call Consider the situation of a host application that calculates a histogram of a grayscale image For example use a buffer with 256 bins for each color of the image to calculate the histogram As a first step issue an NDRange kernel called bzero to initialize the buffer with zeros __ kernel void bzero _ global unsigned int outBuft __ const unsigned int cols i size t row get _ global id size_t col get_global_id 1 outBuf row cols col 8 Examine the buffer contents on the grid and see that all buffer elements are set to zero Data View Data View Image View Problems wiew Trace View Command Queue Properties View Properties Now as a second step issue a 2 NDRange command that calculates the histogram of the image using the buffer as bins counter 63 User Manual Intel SDK for OpenCL Applications Data View Data View Image View Problems wiew Trace View Command Queue Properties View Properties This example has 22 pixel elements with grayscale value 5 and 27 pixels with grayscale value 9 and SO On Use the Type box to select the underlying data type for example cl_uint cl_double cLlong clLulong cl_float cl_double The Save As button enables saving a CSV representation of the data to disk Wh
95. ries do the following 1 Build code in the Eclipse editor 2 Click the Link button or select Intel OpenCL gt Link Navigate Search Project Intel OpenCLl ip age Ue ee Al e T i 3 Click Browse select the input files to link and click OK 4 Type the output file destination into the Output File text box or click Browse to specify the path using graphics user interface 5 Specify OpenCL device type and Architecture in the Target Configuration group box and click OK See Also Configuring Offline Compiler for Eclipse IDE Building and Compiling Kernels in Eclipse IDE Saving and Loading OpenCL Code in Eclipse IDE Create a C C eclipse project to open or link c1 files in Eclipse IDE 16 Code Editing and Building with Eclipse Plug in NOTE Install the Eclipse C C Development Tool CDT to work with the Offline Compiler capabilities To save a c1 file using OpenCL API Offline Compiler plug in for Eclipse IDE do the following 1 Inthe Eclipse user interface select File gt Save As 2 Enter or select folder to save the file 3 Type the file name and click OK To load OpenCL code from file into the Eclipse IDE code editor do the following Right click the target C C project and select Import Go to General gt File system and click Next Click Browse select the folder with the files you need to import and click OK Select the files you need to import and click Finish
96. roperties gt Intel SDK for OpenCL Applications gt General 3 Set Generate Scholar Messages to Yes 4 Build the project to see the Scholar hints as warnings for each cL kernel code file of the project The Scholar hints appear in the Output View of the build log as well as in the Error List view NOTE The Intel SDK for OpenCL Applications group appears in the Configuration Properties only if our project is an OpenCL API project See Also Building with Kernel Builder Command Line Interface OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE OpenCL API Offline Compiler for Eclipse IDE Converting Existing Project into OpenCL Project OpenCL Scholar Hints OpenCL Scholar suggests several hints for OpenCL code optimization Use Floating Point over Integers for Calculations Scholar notifies about each integer calculation that can be implemented with floating point instead Floating point calculations are generally faster than the integer equivalents and have more bandwidth Still the optimization might negatively affect code readability The message location is the beginning of the left hand operand of the operation and its content is prefer floating Point calculations bo integer Calculations Consider the following code korne F yvord Gropa ant a en eo E e a a TO Mora a i cave For the code above Scholar provides the following hint message vaceieguedlate Ie she e oae helan prere
97. rrerrrerrerrrsrrrerne 86 OpenCL AnalysiS TOO hiore n E ET ET E T T E EER 87 About the OpenCL Analyze TOOl oreren EE E EEEE A A 87 Creating and Launching New Analyze Session sssssssrsssrrsrrrsrrrerrrerrnrrrsrrrerrrerrerrrene 87 Anang iNe Data a a AE O A E AA T 88 Revising Code and Rerunning SESSION cccccce cece cece E e a 90 COnfiQUnING the Almaly Ze TOO wactoteaian a a a NA a a a eaa EE 90 Kernel Development Framework neiseina aa a E AA A NA Er A 91 About Kernel Development FrameworK ssssssrrssrssrrrsrrrsrrrsrrrrrrerrrerrrerrrrrrerrrerererene 91 Kernel Development Framework Session s sssssrrserrnrrrsrrrerrrrrrnrrrerrrerrrrrrerrrerrrsrere 92 Building and Compiling OpenCL Program ssssssrsssrssrrrsrrrerrnrrrsrrrerrrerrrrrrsrrrerresrrnt 97 BUIN AFUITI CES erare a A E ET A E A ER 98 Kernel Arguments simeristino ea aaa ar a aen aE 98 User Manual Intel SDK for OpenCL Applications Code Builder Bulla TOODA iranse n a rtan E AA a 99 AnalyZing Kernel PErNormMmaNCE aaa aa a a ei a aaa 99 VanapDle Managemen rsr erara AE a a 102 Legal Information Legal Information By using this document in addition to any agreements you have with Intel you accept the terms set forth below You may not use or facilitate the use of this document in connection with any infringement or other legal analysis concerning Intel products described herein You agree to grant Intel a non exclusive royalty free license
98. s OS only The selected device options can be found in the program window title Kernel Builder Local Intel CPU 64 bit alyze Help NOTE Select the target device for each Code editor tab separately CPU device is default for all open tabs Configuring Link Options The Link Options tab provides several configuration options Link Options Advanced Options OpenCL Options orenci Options group box which enables e Typing the options into the text box e Selecting options from the list available on clicking the button To select several options from the list hold Ctrl See Also Configuring the Environment Installing OpenCL Runtime on Android Emulator 26 Building and Analyzing with Kernel Builder Kernel Performance Analysis Analyzing OpenCL Kernel Performance To analyze OpenCL kernel performance with the Kernel Builder for OpenCL API do the following 1 Click the Analyze 2 Click Refresh kernel s to get the list of kernels in the currently open c1 file 3 Select the target kernel from pull down menu If only one kernel is available it is selected by default 4 Click cells in the Assigned Variables column to create or add variables as kernel arguments You can assign one dimensional variables Such aS integer float char half and so on on the fly by typing single values into the table See section Creating Variables for details 5 Set number of iterations globa
99. selected OpenCL code lines in GPU cycles e Execution units occupancy and hardware thread utilization across the execution The new feature uses the Kernel Builder automatic host application feature so you only need to write an OpenCL kernel assign variables to its arguments and define the global and local group sizes You may also mark specific OpenCL code lines as IL profiling points and then use the Deep Analysis button to run the analysis NOTE To work with the Deep Kernel Analysis feature add the following key in the registry HKEY_LOCAL_MACHINE SOFTWARE Intel KMD DisableDOPClockGating dword 00000001 Profiling Kernels for Deep Kernel Analysis To profile kernels using the Deep Kernel Analysis feature of the Kernel Builder for OpenCL API do the following 1 Run the Kernel Builder 2 Open an OpenCL code file or type in your code in the editor 36 Building and Analyzing with Kernel Builder 3 Click the Analyze analysis 4 Atthe Assign Parameters tab assign parameters from previously defined variables or create them on the fly from the popup dialog 5 Define group sizes for the analysis and press the Deep Analysis button to start profiling button press the Refresh Kernel s button and select a kernel for If desired mark any of the possible OpenCL code lines for profiling by clicking the red circles on the left of your code lines The marking can be undone by clicking the filled circles toggling
100. sh the debugging session by clicking the button or pushing Ctri F5 NOTE Any combination of commands on different levels is possible during debug session See Also Using Kernel Builder Selecting Work Items and Work Groups to Debug You can select a work item to debug via e Selecting the global work item 1 Select the Select Work Item box 2 Select the requested global work item 3 Click Select e Or via selecting a local work group and work item 85 User Manual Intel SDK for OpenCL Applications 1 Select Select Local Work Group box 2 Select the requested local work group and local work item 3 Click Select Select Work Item E Select Local Workgroup Global Work Item Local Work Group Local Work Item X o3 3 X lo AERE a3 Y o 0 Y 0 al ojo 0 Zi 0 Select z 0 lo lo T o Select Upon selecting the global work item the corresponding local work group and local work item entries appear in the Local work group box and vice versa You can change the selected work item or work group during the debug session via selecting the requested work item or work group and clicking Select Work item and work group dimensions availability is determined by the group size set in the Assign Parameters tab of the Kernel Debugger debug board If the kernel is one dimensional the X value is bigger than 0 while Y and Z are set to 0 then only X axis is available when selecting work item or work group See A
101. sssssssrssrenesrrnrresrrrerrrerrerrrsrrrerrrerret 69 Creating ah ANdroid AppliGatlone c cccs cecnaseadescesnnckaden cxauaias E EA diate souevnden dacdicateneemseeeadete 71 PREVICW Features ieii a a a E E aaa 73 OpenCL 2 0 Experimental Development Environment sssssssssrssrrrerenrrrrsrrrsrrrrrrrrrrerrreree 73 OpenCL NCW Pol eC Wi2ard erionenn a a e aae a even tna ee ate AE 73 About the OpenCL New Project Wizard s ssssssrsssrrsrrrsrrrerrnrrrerrrsrrrrrrnrrrerrrsrrrrrene 73 Creating an Empty OpenCL Project for WiNdOWS ssssssssrssrrssrrrrrenrrrerrrerrrrrrrrrrene 74 Create a New OpenCL Project from OpenCL Project Template for WindowS 74 Create a New OpenCL Project from OpenCL Project Template for Android 76 open EA SCENO aan a aa a a a aae an aa a a a e aai aa a a a 78 ADOUE OpenCh SCNola sortin Eaa Nra a EA a E O N aA 78 Enabling OpenGk SCHON irriteer e E A e E E eeneedalee ye 79 OpenGl Scholar MINS eisa aaa an E E E cnn eeceenaxk 80 Debugging Kernels on Intel Graphics seiistiersiaseisierstia vanne a i ESSE SEE EEE 82 ADOUT Kernel DCDUGOED prainiana ES E EE E E E a teamnnenuoieeidertin 82 Assigning Debug Paramete Seenen ti a a E ENSA E e E N A E a 83 kernel Debugger Controls sree a a a 84 Selecting Work Items and Work Groups to Debug s sssssrsssrssrresrrrerrnrrrsrrrerrrerrerrree 85 Watching Variables and Kernel ArgumentsS ssssssrssrrserrsrrrsrrrerrrrrrer
102. t ct wisual studio 2012 Projects ConsoleApplication1l ConsoleApplicationl Debug OpenCLFile out Generated build l gt ConsoleApplicationl vexproj gt c visual studio 276127 Projects ConsoleApplicationl Debug ConsoleApplicationl e 4 e Generating and Viewing LLVM Code OpenCL API Offline Compiler plug in for Microsoft Visual Studio IDE enables generating LLVM representation of the OpenCL code To enable generating and viewing LLVM code do the following 1 Goto Project gt Properties 2 Click Configuration Properties gt I ntel SDK for OpenCL Applications gt General 3 Change the Generate LLVM Code option to Yes Configuration Active Debug Platform Active Wins2 Configuration Manager 4 Intel SDK for OpenCL Appl Include General Device CPU device CPU Math Optimizations SIMD Default simd default Warnings Generate assembly code No Command Line Generate lym code Yes llvm b Code Analysis Generate binary file No After the build you can open the generated LLVM file in the Visual Studio editor by double clicking the message in the Output view Output x Show output from Build eS amp 1 gt Build succeeded re l gt c visual studio 2612 Projects ConsoleApplication1l ConsoleApplication1 Debug OpenCLFile 11 Generated assemt l gt ct visual studio 2612 Projects ConsoleApplication1l ConsoleApplication1 Debug OpenCLFile out Generated build l gt ConsoleApplicationl vcxproj gt c visual studio 2612
103. t explorer and select Intel OpenCL gt Build or Compile After compilation completes the output appears in the Console tab of the Eclipse IDE E Problems 2 Tasks EE Console 3 E Prope OpenCL Build Console Device name Intel R CPU Device version OpenCL 1 2 Build 75216 Device vendor Intel R Corporation Kernel was not vectorized Done Build succeeded Error and warning messages appear in the Problems tab J Tasks fi Problems 2 E Properties l error 1 warning 0 others Description a Errors 1 item use of undeclared identifier this a amp Warnings Litern Fwarning this is a warning See Also Saving and Loading OpenCL Code in Eclipse IDE 15 User Manual Intel SDK for OpenCL Applications Generating Assembly Code in Eclipse IDE OpenCL API Offline Compiler plug in for Eclipse IDE enables generating and viewing files with assembly code of the input c1 files To generate and view the assembly code do the following 1 Build the OpenCL code from the Eclipse editor 2 Click the Show Assembly button or right click the ci file in the Project Explorer and select Intel OpenCL gt View Assembly Navigate Search Project Intel OpenCL m i be ee Al IL els ee See Also Building and Compiling Kernels in Eclipse IDE Linking Program Binaries in Eclipse IDE OpenCL API Offline Compiler plug in for Eclipse IDE enables linking several compiled files To link bina
104. to any patent claim thereafter drafted which includes subject matter disclosed herein INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS NO LICENSE EXPRESS OR IMPLIED BY ESTOPPEL OR OTHERWISE TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT EXCEPT AS PROVIDED IN INTEL S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY RELATING TO SALE AND OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE MERCHANTABILITY OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT A Mission Critical Application is any application in which failure of the Intel Product could result directly or indirectly in personal injury or death SHOULD YOU PURCHASE OR USE INTEL S PRODUCTS FOR ANY SUCH MISSION CRITICAL APPLICATION YOU SHALL INDEMNIFY AND HOLD INTEL AND ITS SUBSIDIARIES SUBCONTRACTORS AND AFFILIATES AND THE DIRECTORS OFFICERS AND EMPLOYEES OF EACH HARMLESS AGAINST ALL CLAIMS COSTS DAMAGES AND EXPENSES AND REASONABLE ATTORNEYS FEES ARISING OUT OF DIRECTLY OR INDIRECTLY ANY CLAIM OF PRODUCT LIABILITY PERSONAL INJ URY OR DEATH ARISING IN ANY WAY OUT OF SUCH MISSION CRITICAL APPLICATION WHETHER OR NOT INTEL OR ITS SUBCONTRACTOR WAS NEGLIGENT IN THE DESIGN MANUFACTURE OR WARNING OF THE INTEL PRODUCT OR ANY OF ITS PARTS Intel may make changes to spe
105. to saved sessions 19 User Manual Intel SDK for OpenCL Applications LLVM SPIR and Assembly Code View Kernel Builder for OpenCL API enables viewing the generated LLVM SPIR and Assembly intermediate representation IR of the OpenCL code To view the LLVM SPIR or Assembly code do the following 1 Build your kernel ros oy lt gt 2 Click Show LLVM or Show Assembly You can view the SPIR representation by selecting the corresponding tab in the LLVM View window LLYM View of x ModuleID Program T target datalayout e p 64 6 _ target triple x86 64 pc wL Function Attrs nounwind declare void BitonicSort b Function Attrs nounwind re _ a a mu vT To hide the view windows click the corresponding button again NOTE Assembly code view is available for the CPU device only See Also Building and Compiling Kernels Generating Intermediate Program Binaries The Kernel Builder for OpenCL API enables generating program binaries of OpenCL code An application can use generated program binaries to create program from binaries later clCreateProgramFromBinary 1 Build the code 2 Click the Create Program Binary ss button and select o Create Program Binary o Create linked program s binary IR See Also Building and Compiling Kernels 20 Building and Analyzing with Kernel Builder Linking Program Binaries To link OpenCL program binaries wit
106. u can change these values manually Workgroup size definitions Global size s Local size s Mi 512 16 Y 512 16 og 0 See Also Using Kernel Builder Kernel Debugger Controls You can control the debugging process using the Debug tab of the Kernel Debugger The debugger control panel contains several buttons that you can use to control the debugging process Using step over and continue commands you can perform kernel debugging in three levels e Work item level e Work group level e Kernel level 84 Preview Features Work Item Level On the work item level the Debugger runs commands for a single work item Click the ean mo nn Click the button or push F9 to use the continue command for the selected work item Work Group Level On the work group level the Debugger runs commands for a selected work group For example if the local work group size is 10 the debugger runs 10 work items that belong to the selected work group Click the button or push F6 to use the step over command for the selected work group Click the button or push F10 to use the continue command for the selected work group Kernel Level On the kernel level the Debugger runs commands for the whole set of work items as defined in the global size Click the button or push F7 to use the step over command for all work items Click the button or push F11 to use the continue command for all work items Fini
107. ues at 0 Changing Debugging Port If you receive a Protocol error message change your firewall settings or change debugging port in the OpenCL Debugger plug in for Microsoft Visual Studio IDE NOTE Default debugging port is 56203 To change the debugging port number do the following 46 Debugging with Visual Studio Plug in 1 Run the Visual Studio IDE 2 Select CODE BUILDER gt OpenCL Debugger gt Options 3 Switch to the Advanced Settings tab 4 Check the Use Custom Debugging Port check box 5 Inthe Debugging Port Number field enter the port you need NOTE If the Use Custom Debugging Port check box is unavailable switch to the Basic Settings tab and check the Enable OpenCL Kernel Debugging check box Troubleshooting the Debugger In case of issues with kernel debugging 1 Set the following environment variables TUTETE C DECI C lhl Och DSC shOCunmii es remo e st 2 Restart the Microsoft Visual Studio IDE 3 Continue debugging Using these environment variables you generate a log file Use it to determine the root cause of the issue You can submit the generated log at http software intel com en us forums intel opencl sdk API Debugging in Visual Studio OpenCL API Debugger The interface of the Microsoft Visual Studio IDE provides standard debugging capabilities for the host side of OpenCL applications while the OpenCL Debugger plug in of the Code Builder enables debugging
108. uments for the debug session refer to the Assign Parameters tab on the Debug Board Click cells in the Assigned Variable column to create or add variables as kernel arguments Use immediate values for primitive types like int float char half and so on Add comma separated immediate values for example 2 4 6 8 for a given uint4 argument for vector type If the given values don t correspond to the vector size of the given type the last specified value iS propagated to the correct size For example if you type 2 as a value to an int4 variable it turns automatically to 2 2 2 2 For complex types like arrays images and samples use the Variable Managment window which you can open by clicking cells with Click Here To Assign In the Variable Managment window select appropriate variables and click Assign 83 User Manual Intel SDK for OpenCL Applications Select Kero analyze Refi kale Assign Parameters Kernel Arguments Arg Memory Space Access Quailifier Data Type Name Assigned Variable _ global NONE int4 the rray Click Here To Assign _ private NONE uint stage 2468 o You can set group sizes by typing the requested global and local work group sizes in the Workgroup size definition group box on the Assign Parameters tab of the Kernel Debugger NOTE If a kernel contains input buffer argument or input image argument the global and local sizes are set automatically according to the sizes of the buffer image Yo
109. y command executed in your application 89 User Manual Intel SDK for OpenCL Applications choose a view Memory Commands v BitonicSort Command Name Return Value Size byte Duration ps Latency ps Start Time ps Memory Type CL COMMAND_MAP_BUFFER 0 134217728 4380 102492 177359259530056 CL_MEM_OBJECT_BUFFER CL_MEM_USE_HOST_PTR Queued Time us 177359259427564 Other Information Map Count 0 Started Time us 177359259530056 Ended Time us 177359259534436 Duration us 4380 Context ID 1 Queue ID 1 CL COMMAND_UNMAP_MEM_OBJECT 0 134217728 4088 84388 177359262258212 CL_MEM_OBJECT_BUFFER CL_MEM_USE_HOST_PTR Revising Code and Rerunning Session After you optimize your code you can rerun the profiling session and compare the data to see how your changes improve your application performance To rerun an analyze session do the following 1 Open the Analyze Sessions Explore from CODE BUILDER gt OpenCL Application Analysis gt Windows gt Analyze Session Explorer 2 Inthe Analyze Sessions Explorer right click the analyze session that you want to rerun and select Rerun 3 A new analyze session is created and launched and the profiled application starts 4 After the application is finished the new analyze session appears in the Analyze Explorer window and new reports are generated Output Files For each analysis session the analysis tool creates a session directory named with application s na

Download Pdf Manuals

image

Related Search

Related Contents

Polycom SoundPoint IP 501 User's Manual  Matériaux à empreintes 348 - Patterson Dental/Dentaire  ROUTE 66 Mobile 8 GPS Receiver User Manual  取扱いのポイント  D013-CXXZ - リズム時計工業株式会社  Bolens 769-00407 Yard Vacuum User Manual  Philips CEM5000    

Copyright © All rights reserved.
Failed to retrieve file