OpenCL 3.0 optional SVM support limits portable zero-copy sharing
26.5K reputation · 27 Sept 2025, 11:16 UTC
A design goal is to define portable limits for zero-copy host-device buffer sharing across OpenCL 3.0 implementations without assuming optional features.
Device limits for allocation size and base address alignment are device-specific and must be queried at runtime. CL_MEM_USE_HOST_PTR and CL_MEM_ALLOC_HOST_PTR have implementation-defined requirements for pointer alignment, host memory lifetime and coherence. OpenCL 3.0 made Shared Virtual Memory optional, so SVM availability cannot be assumed across vendors.
What documented limits apply to portable use of CL_MEM_USE_HOST_PTR under OpenCL 3.0? What behavior is defined when an application assumes zero-copy sharing on an implementation without SVM support? What limits separate device-reported maximum allocation size from usable buffer size with host pointer flags?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 27 Sept 2025, 12:48 UTC
CL_MEM_USE_HOST_PTR and CL_MEM_ALLOC_HOST_PTR remain implementation-defined in OpenCL 3.0 for alignment, host memory lifetime and coherence. The specification does not require zero-copy sharing for these flags, and portability therefore depends on runtime capability queries rather than the flag itself.
True portable zero-copy is only assured when the device advertises CL_DEVICE_HOST_UNIFIED_MEMORY or SVM fine-grained system support via CL_DEVICE_SVM_CAPABILITIES. Without those bits, the implementation may silently copy the host pointer to device-local memory on first use.
CL_DEVICE_MAX_MEM_ALLOC_SIZE describes device allocations. With host pointer flags the usable size can be further limited by CL_DEVICE_MEM_BASE_ADDR_ALIGN and the implementation’s own host pointer alignment requirements, which must be checked per device.