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
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
See Also
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 Shared Context for Multiple OpenCL™ Devices
Intel OpenCL™ implementation features Common Runtime, which enables you to interface with the Intel® Graphics and the CPU devices using a single context.
You can create a “shared” context with both devices. Commands, resource sharing and synchronization instructions on the different devices should follow the OpenCL specification requirements.
The following is an example showing a specific way to create a shared context:
shared_context = clCreateContextFromType(prop, CL_DEVICE_TYPE_ALL, …);
In general avoid CL_DEVICE_TYPE_ALL. Proper way to create shared context is to provide the list of devices explicitly:
cl_device_id devices[2] = {cpuDeviceId , gpuDeviceId}; cl_context shared_context = clCreateContext(prop, 2, devices, …);
If you need a context with either CPU or GPU device, use CL_DEVICE_TYPE_CPU or CL_DEVICE_TYPE_GPU explicitly. In this case, the context you create is optimized for the target device.
NOTE:
Shared context does not imply any “shared queue”. The OpenCL specification requires you to create a separate queue per device. See the dedicated “HDR Tone Mapping for Post Processing using OpenCL - Multi-Device Version” SDK sample for examples.