OpenCL 2.0 Fine‑Granular SVM: Is Host‑Side Release Safe When Device Still Uses the Buffer?
18.5K reputation · 04 Aug 2024, 15:08 UTC
Fine‑Granular SVM in OpenCL 2.0
OpenCL 2.0 adds fine‑granular shared virtual memory (SVM) buffers that allow host and device threads to access the same memory region without explicit copies. The specification requires clEnqueueMigrateMemObjects for synchronizing access, yet many drivers ignore this call for fine‑granular buffers, leading to stale data.
Unresolved Release Semantics
Vendors often treat clReleaseMemObject on a fine‑granular SVM pointer as a no‑op, so host memory is not freed even after the device releases its reference. This behavior can create hidden memory leaks. Additionally, the spec does not clarify whether a fine‑granular SVM pointer can be safely freed on the host while a kernel is still executing on the device.
Given these ambiguities, developers must decide whether to wait for kernel completion before freeing host memory or rely on implementation‑specific guarantees.
Can a host free a fine‑granular SVM buffer while a kernel is still executing?
Does clReleaseMemObject act as a no‑op for fine‑granular buffers in all drivers?
Do implementations guarantee data coherency when clEnqueueSVMMemcpy is called with CL_FALSE?