Sharing Resources Efficiently

Objects, allocated at the context level, are shared between devices in the context. For example, both buffers and images created with regular clCreateBuffer/ clCreateImage2D are effectively shared by default, so no implicit copying/synchronization happens between devices or between the devices and the host on Map/Unmap calls.

NOTE: Shared memory objects cannot be written concurrently by different command queues. Use explicit synchronization of the write access with OpenCL* synchronization objects, such as events.

You can also avoid implicit copying when you share data with the host, as explained in the “Mapping Memory Objects” section (see Related Documents).

NOTE: You need to properly align the pointer to the memory referenced with CL_MEM_USE_HOST_PTR; otherwise explicit copying might happen between host and devices on Map/Unmap.

The following table demonstrates the cases were the application can benefit from zero-copy sharing with host using CL_MEM_USE_HOST_PTR:

Memory Object

 

CPU-Only Context

Processor Graphics

Only Context

CPU+Processor Graphics

Shared Context

Buffer

True sharing when hostptr is aligned

to CPU device CL_MEM_BASE_ADDR_ALIGN

Always True Sharing

True Sharing

when hostptr is aligned

to 128 Bytes

Image True Sharing when hostptr is aligned to the image’s element size No True Sharing

True sharing

when hostptr is aligned to 4K

Other resources that are shared automatically across all devices, include program and kernel objects.

See Also


Synchronization Caveats (suggested next topic)
Mapping Memory Objects
Related Documents
The OpenCL* 1.1 Specification at http://www.khronos.org portal [PDF]
Overview Presentations of the OpenCL* Standard at http://www.khronos.org portal [Online Article]
Optimization Notice

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804


Submit feedback on this help topic

Copyright © 2010-2012, Intel Corporation. All rights reserved.