You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nanovdb python: bind DeviceBuffer/DeviceGridHandle.recordUse for external streams
The bindings' interop surface hands raw device pointers to CuPy / PyTorch /
Numba via device_ptr(), __cuda_array_interface__ and __dlpack__, and those
frameworks launch kernels on their own non-blocking streams. Such work is
invisible to the buffer's automatic upload/download use tracking, so the
cudaFreeAsync issued when the buffer is cleared or destroyed could race it —
the C++ side grew DeviceBuffer::recordUse(device, stream) for exactly this
caller, but Python had no way to reach it.
Bind recordUse(stream, device=-1) on DeviceBuffer and on DeviceGridHandle
(which owns its buffer internally and is where every real workflow's owning
buffer lives). Both forward to a shared recordUseChecked helper that
validates the device id — the C++ method indexes per-device tracking state
unchecked — raising IndexError on an out-of-range id, with -1 selecting the
current CUDA device. The device_ptr and __cuda_array_interface__ docstrings
now point callers at recordUse. Non-owning (from_external) buffers accept
the call as a no-op, matching the C++ behavior.
Add TestRecordUse to TestGpuInterop.py: a CuPy reduction enqueued on a
non-blocking stream against a zero-copy CAI view, recorded, and validated
after the handle is destroyed while the work may still be in flight; plus
default-stream/explicit-device acceptance, IndexError on a bad device id,
and the non-owning no-op.
Also normalize the cuda/ sources' includes of shared binding headers: add
the python source dir to the target's private include paths so they use
plain names ("PyGridHandle.h", "BuildTypes.def") instead of "../"-relative
paths, which the rest of the codebase does not use.
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
0 commit comments