VBM select-based inverse-map decode - #2258
Open
swahtz wants to merge 3 commits into
Open
Conversation
Replace the O(nLeaves x 512) cooperative sweep in decodeInverseMaps with an O(1)-per-slot select: one thread per output slot ranks itself into its leaf via the jumpMap popcount, then locates its voxel with the leaf's 9-bit mPrefixSum plus an in-word __fns bit select. Same signature, byte-exact decode maps. Verified byte-exact on the VBM goldens for all consumers (decode/box/lap/weno) at widths 64/128/256/512, and faster for every consumer with no regression: decode-only 2.17x/1.97x/1.62x/1.42x (w6/w7/w8/w9), 7-pt Laplacian -8.5..-15.4%, box/weno -4..-9%. Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
swahtz
requested review from
Idclip,
apradhana,
danrbailey,
jmlait,
kmuseth and
richhones
as code owners
July 23, 2026 06:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces the method in inverse-map decode in the NanoVDB VoxelBlockManager (
tools/cuda/VoxelBlockManager.cuh) with an output-centric select.decodeInverseMapspreviously had every thread in the block sweep all 512 voxel slots of every leaf overlapping the block — O(nLeaves × 512) work per block. It now runs one thread per output slot: each slot ranks itself into its leaf with a jumpMap popcount, then locates its voxel via the leaf's 9-bitmPrefixSumplus an in-word__fnsbit select — O(1) per slot.The public signature is unchanged and the decoded maps are byte-identical, so every downstream stencil consumer inherits the speedup for free. Benchmarked A/B on an RTX PRO 6000 (sm_120; 50 iters / 15 warmup).
What changed
The decode is, in effect, a rank + select over the VBM's bit-vectors:
__fns— recovers the voxel offset.This removes the old sweep's data-dependent inner branch (
if (index ∈ block)) and its per-leaf full scan, and makes the decode's work independent of leaf sparsity.A/B — decode (dragon, median; BlockWidth = 2^log2width)
Decode is the shared front-end for all stencil consumers, so whole-consumer times improve too (dragon): 7-pt Laplacian −10…−15%, 27-tap box / 19-tap WENO −4…−9%, with no consumer regressing.
Validation