Commit 14613ce
committed
Fork a small set of nanoVDB headers to share PyTorch's allocator
Add an override directory at `src/fvdb/nanovdb_overrides/` that holds
modified copies of a few upstream nanoVDB headers. The build prepends
this directory to the include search path so that, e.g.,
`#include <nanovdb/cuda/DeviceBuffer.h>` resolves to the forked copy
under `src/fvdb/nanovdb_overrides/`, while the rest of nanoVDB
continues to come from the upstream source tree.
Forked headers:
- `nanovdb/cuda/DeviceBuffer.h` and `nanovdb/cuda/DeviceResource.h`
route device-side allocations through
`c10::cuda::CUDACachingAllocator` (PyTorch's caching allocator)
instead of `cudaMallocAsync` / `cudaFreeAsync`. This keeps
transient scratch allocations made by nanoVDB internals
(MergeGrids, TopologyBuilder, DilateGrid, ...) inside the same
pool that fvdb / PyTorch tensors use. Without this, the two
pools fragment each other and large workloads such as
multi-frame TSDF integration hit a clean OOM even when the GPU
still has free memory in aggregate.
- `nanovdb/tools/cuda/TopologyBuilder.cuh` adds an opt-in debug
trace gated on the `FVDB_NANOVDB_TRACE_ALLOCS` env var that
prints tile count and per-call scratch size from
`allocateInternalMaskBuffers`. Useful for diagnosing topology-op
memory blowup on large scenes; off by default and otherwise
byte-identical with upstream.
Each forked header carries a short `FVDB FORK:` banner documenting
what diverges from upstream and why, with inline `// FVDB FORK:`
tags on every non-trivial change so `git blame` and text search make
the delta obvious. `src/fvdb/nanovdb_overrides/README.md` documents
the resync and add-an-override procedures.
CMake wiring lives in `src/cmake/get_nanovdb.cmake`, with mirror
include-path orderings in `src/CMakeLists.txt` (fvdb target) and
the top-level `CMakeLists.txt` (_fvdb_cpp pybind module).
Signed-off-by: Francis Williams <francis@fwilliams.info>1 parent 7e8213e commit 14613ce
7 files changed
Lines changed: 1229 additions & 1 deletion
File tree
- src
- cmake
- fvdb/nanovdb_overrides
- nanovdb
- cuda
- tools/cuda
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
14 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
15 | 30 | | |
16 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
17 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
0 commit comments