-
Notifications
You must be signed in to change notification settings - Fork 123
Description
A question I wasn't able to answer using the spec is whether clSetKernelArg
with (e.g.) a buffer will increase the reference count of the buffer and/or keep the buffer alive while it is set as an argument. The spec for clSetKernelArg
doesn't seem to say much.
Perhaps the most informative section I found was the glossary entry on reference counts, which isn't very precise, but seems to require life support to enable in-flight operations to complete:
Implementations may also modify the reference count, e.g. to track attached objects or to ensure correct operation of in-progress or scheduled activities. The object becomes inaccessible to host code when the number of release operations performed matches the number of retain operations plus the allocation of the object. At this point the reference count may be zero but this is not guaranteed.
This has an impact on users of the interface, as it determines for what length of time they need to keep buffers alive. (just from set-arg to enqueue, or until kernel completion)
Empirically, PyOpenCL releases early, but has never had buffer life time issues until I tried the same thing with SVM. A "straw poll" of the reference counts (allowing for the fact that those might not be the full story) among implementations using this script yielded:
- pocl 1.7rc1: refcount 2
- intel-compute-runtime-21.17.19709-h4bd325d_0: refcount 1
- intel-oclcpuexp-2019.8.7.0.0725_rel.icd: refcount 1
- Nvidia 460.73.01: refcount 1
x-ref: inducer/pyopencl#450