NanoVDB: encode points for any resource in PointsToGrid (CUDA) - #2244
NanoVDB: encode points for any resource in PointsToGrid (CUDA)#2244harrism wants to merge 3 commits into
Conversation
The point-encode step in tools::cuda::PointsToGrid was only reachable for the default DeviceResource, because it lived in the BuildT=Point full specialization of processPoints (i.e. <Point, DeviceResource>). A Point grid built with a custom resource fell through to the generic no-op and was silently left with unencoded point data. Fold the encode into the generic processPoints and gate it with if constexpr(is_same<BuildT, Point>). The encode kernels run on device data and are independent of the resource; only the trailing d_indx deallocation routes through ResourceT. Non-Point builds and default- resource Point builds are unchanged. Add a regression test that builds a NanoGrid<Point> through a custom resource and asserts every input point is recoverable from the encoded per-voxel data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Mark Harris <mharris@nvidia.com>
|
@kmuseth friendly ping — this has been open since July 2 with no review yet. It's the smaller of the two follow-ups from #2231 (+117/-65, 2 files) and fixes a silent-wrong-output case: Both existing paths are unchanged by construction — non- Happy to rebase if it's gone stale. |
…code-resource Signed-off-by: Mark Harris <mharris@nvidia.com>
nvcc rejects an extended lambda defined directly inside the block of an if constexpr statement on some host compilers, so the nine encode launches failed to compile against MSVC while building fine with gcc and clang. Give them their own member function and have the branch call it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Mark Harris <mharris@nvidia.com>
kmuseth
left a comment
There was a problem hiding this comment.
looks good to me - good catch
Follow-up to #2231, part of #2232 (NanoVDB injectable CUDA memory resources).
What
tools::cuda::PointsToGrid<Point, ResourceT>now encodes points for any resource. Previously the point-encoder lived only in thePointsToGrid<Point>full specialization (=PointsToGrid<Point, DeviceResource>), so a Point build with a custom resource missed it and fell through to the generic no-op — silently producing a grid with no encoded point data, no error. This was the known limitation called out in #2231's follow-ups.The encoder is folded into the generic
PointsToGrid<BuildT, ResourceT>::processPoints, gated byif constexpr (util::is_same<BuildT, Point>::value); the now-redundant full specialization is removed.Why existing paths are unchanged
if constexprblock is discarded, leaving the prior no-op body verbatim.ResourceT == DeviceResource, so the same encode kernels run with the same alignment — byte-for-byte the previous path.The resource governs allocation only; the encode kernels operate on device data, so making the encoder resource-agnostic is correct.
Testing
New
TestMemoryResource.PointsToGrid_PointEncodedWithCustomResourcebuilds aNanoGrid<Point>viaPointsToGridwith a custom resource and asserts the encoded coordinates match the input — red on current code (captures the no-op), green after the fix. RTX 6000 Ada / CUDA 12.6: memory-resource suite 9/9, CPUnanovdb_test_nanovdb153/153,nanovdb_test_cuda53/53.Non-CUDA builds
No impact on
NANOVDB_USE_CUDA=OFF— the change is confined totools/cuda/PointsToGrid.cuh(#if defined(__CUDACC__)-gated) and a CUDA-only test.🤖 Generated with Claude Code