Legal Information
Getting Help and Support
Introduction
Coding for the Intel® Processor Graphics
Platform-Level Considerations
Application-Level Optimizations
Optimizing OpenCL™ Usage with Intel® Processor Graphics
Check-list for OpenCL™ Optimizations
Performance Debugging
Using Multiple OpenCL™ Devices
Coding for the Intel® CPU OpenCL™ Device
OpenCL™ Kernel Development for Intel® CPU OpenCL™ device
Mapping Memory Objects
Using Buffers and Images Appropriately
Using Floating Point for Calculations
Using Compiler Options for Optimizations
Using Built-In Functions
See Also
Loading and Storing Data in Greatest Chunks
Applying Shared Local Memory
Using Specialization in Branching
Considering native_ and half_ Versions of Math Built-Ins
Using the Restrict Qualifier for Kernel Arguments
Avoiding Handling Edge Conditions in Kernels
Using Shared Context for Multiple OpenCL™ Devices
Sharing Resources Efficiently
Synchronization Caveats
Writing to a Shared Resource
Partitioning the Work
Keeping Kernel Sources the Same
Basic Frequency Considerations
Eliminating Device Starvation
Limitations of Shared Context with Respect to Extensions
Why Optimizing Kernel Code Is Important?
Avoid Spurious Operations in Kernel Code
Perform Initialization in a Separate Task
Use Preprocessor for Constants
Use Signed Integer Data Types
Use Row-Wise Data Accesses
Tips for Auto-Vectorization
Local Memory Usage
Avoid Extracting Vector Components
Task-Parallel Programming Model Hints
Using Built-In Functions
OpenCL™ software technology offers a library of built-in functions, including vector variants. Using the built-in functions is typically more efficient than implementing them manually in OpenCL code. For example, consider the following code example:
int tid = get_global_id(0); c[tid] = 1/sqrt(a[tid] + b[tid]);
The following code uses the built-in rsqrt function to implement the same example more efficiently:
int tid = get_global_id(0); c[tid] = rsqrt(a[tid] + b[tid]);
See other examples of simple expressions and built-ins based equivalents below:
dx * fCos + dy * fSin == dot( (float2)(dx, dy),(float2)(fCos, fSin)) x * a - b == mad(x, a, -b) sqrt(dot(x, y)) == distance(x,y)
The only exception is using mul24 as it involves redundant overflow-handling logic:
int iSize = x*y;//prefer general multiplication, not mul24(x,y);
Also use specialized built-in versions where possible. For example, when the x value for xy is ≥0, use powr instead of pow.
See Also
The OpenCL 2.0 C Specification at https://www.khronos.org/registry/cl/specs/opencl-2.0-openclc.pdf