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.

See Also

HDR Tone Mapping for Post Processing using OpenCL - Multi-Device Version

有关编译器优化的更完整信息,请参阅优化通知