• 10/30/2018
  • Public Content
Contents

Mapping Memory Objects (USE_HOST_PTR)

As the host code shares the physical memory with CPU OpenCL™ device, you can do one of the following to avoid unnecessary copies:
  • Request the framework to allocate memory on the host.
  • Allocate properly aligned memory yourself and share the pointer with the framework.
  • Use calls to
    clEnqueueMapBuffer
    and
    clEnqueueUnmapBuffer
    instead of calls to
    clEnqueueReadBuffer
    or
    clEnqueueWriteBuffer
    .
If your application uses a specific memory management algorithm, or if you need more control over memory allocation, you can allocate a buffer and then pass the pointer at
clCreateBuffer
time with the
CL_MEM_USE_HOST_PTR
flag. However, the pointer must be aligned to the certain boundary. Otherwise, the framework may perform memory copies. Consider to query the required memory alignment using
clGetDeviceInfo
with
CL_DEVICE_MEM_BASE_ADDR_ALIGN
token.
You can also map image objects (for CPU OpenCL device), creating them with the
CL_MEM_USE_HOST_PTR
flag.

See Also

OpenCL™ 1.2 Specification at
Overview Presentations of the OpenCL™ Standard at

Product and Performance Information

1

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