Repository navigation
P0a: the CUDA volume cache per device, shared by the apps the host hands it to - #1281
Merged
Merged
Conversation
Roadmap 9 item 5, settled 2026-11-14: "The CUDA volume cache becomes per device, owned by whichever object owns the device (not duplicated per app)". It was one cache per app, its blocks keyed by device under one budget. - cuda_device_caches holds one resident cache per CUDA device, each with its own budget (512 MB by default), made when a render first runs on that device. - raycast_cuda_cache, the app's slot, is a handle on the caches its renders use: its own by default, so apps share nothing unless the host says so; share(caches) points it at caches another app or the host holds. No global and no allowlist line: the host owns them. - Content-generation stamps come from the caches' counter, not the app's. Two apps sharing caches and a voxel buffer, each with its own counter, could both stamp an in-place write 1 and the second would get the block staged before its write. share() therefore comes before an app's first render, and throws once its caches have staged a block or drawn a stamp. - A render holds the caches (a shared_ptr copy) for its length, so a share() on another thread never frees blocks a kernel is reading; the caches outlive the app that made them. - clear, forget_host, set_budget and the destructor make the cache's device current while they free (device_scope), so a block is freed on the device that allocated it whichever thread calls. Tests: VolrenMultiApp.AppsShareDeviceCachesOnlyWhenHandedThem and SharedDeviceCachesOutliveTheirMakerAndServeThreadsAtOnce (every build); VolrenCudaTest.AppsHandedOneDeviceCachesShareTheirBlocks and SharedCachesNeverServeAStaleBlockAcrossApps (with a CUDA device). VOLREN_API.md and the roadmap say who shares the caches.
The device caches keep the budget each new device cache starts with, so cuda_device_caches::budget() reads that; nvcc warned (#177) that the per-device cache's own accessor was never referenced.
transfix
enabled auto-merge
November 15, 2026 23:25
#1276 moved _arihost's lent relay onto the module's own state, so server_link() became server_link(self). #1302 (bridged users) was tested on a base without #1276 and added five calls in the old form: room, bridge_presence, bridge_absent, bridge_post and listen_chat. Master has not compiled arisrvx since #1302 landed (pycvc-linux / cp312 on #1281, run 43951076345: "too few arguments to function server_link"). Name each one's module parameter self and pass it, as their neighbours do.
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.
The CUDA volume cache is per device, and the apps the host hands it to share it. This is the last open part of roadmap §9 item 5, which Joe settled on 2026-11-14 ("The CUDA volume cache becomes per device, owned by whichever object owns the device (not duplicated per app)"). It adds no global and no allowlist line: the host owns the caches, as it owns the device.
Branched from #1276's head (1c465e1). Until #1276 merges, this diff also shows #1276's commits; the change here is the last two commits. Please merge after #1276, with a merge commit.
What changed
cuda_device_caches(raycaster_cuda.h): one resident cache per CUDA device, each with a budget of its own (default 512 MB per device), made the first time a render runs on that device.set_budget()sets every device's;resident()anduploaded()add up all devices.raycast_cuda_cache, the app's slot, is now a handle on the caches its renders use:cuda_device_cachesby default, so apps share nothing unless the host says so;share(caches)points it at caches another app (or the host) holds. Passraycast_cuda_cache_of(a).caches()to share appa's;set_budget,budget,resident,uploaded,forget_hostandclearact on those caches, as before.invalidate_device_volume) come from the caches' counter, not the app's. With a counter per app, two apps sharing caches and a voxel buffer could each stamp an in-place write1, and the second would be served the block staged before its write.share()comes before the app's first render. It throwsstd::logic_erroronce the app's caches have staged a block or drawn a stamp, because the stamps its raycasters hold mean nothing in other caches. Null throwsstd::invalid_argument; sharing the same caches again does nothing.shared_ptrcopy), so ashare()on another thread swaps the handle without pulling blocks out from under a running kernel. The caches outlive the app that made them.clear,forget_host,set_budgetand the destructor can run on any thread, so each per-device cache makes its device current while it frees (device_scope), then puts the caller's back.Behaviour changes to review
raycast_cuda_cache::implandget()are gone;cuda_device_caches::get()replaces them. Nothing outsideraycast.cuused them.Tests
VolrenMultiApp.AppsShareDeviceCachesOnlyWhenHandedThem(every build): two apps handed one app's caches draw their stamps from the shared counter; a third app keeps its own; each renders what it renders alone;share()after a stamp andshare(nullptr)throw.VolrenMultiApp.SharedDeviceCachesOutliveTheirMakerAndServeThreadsAtOnce(every build): caches whose maker is gone serve three apps rendering at once on threads, each as it would alone.VolrenCudaTest.AppsHandedOneDeviceCachesShareTheirBlocks(CUDA device): a volume one app staged is not uploaded again for the other; a budget set through one app is the other's; the blocks survive the first app; an app not handed the caches stages its own copy.VolrenCudaTest.SharedCachesNeverServeAStaleBlockAcrossApps(CUDA device): two apps sharing caches and one buffer each announce an in-place write; every render matches a clean app's render of the current bytes.VolrenMultiApp.*andVolrenCudaTest.EachAppHasItsOwnResidentCachestill hold, since apps share nothing by default.Testing
VolrenMultiApptests among them.cuda-toolkitrecipe):volren_cuda_test: 28 of 28 pass on the device, the two new tests among them (run, not skipped);VolrenMultiApp.*: 5 of 5, andmulti_app_integration_test: 5 of 5, with the CUDA backend.SharedCachesNeverServeAStaleBlockAcrossAppsfails ("b was served the block staged before its write"). With the shared counter it passes.budget()was removed after nvcc's warning 177, "declared but never referenced").package-linux / libcvc-release-grpc, which has no GPU), and more than one GPU. This machine has one, so the split across devices and the frees on each block's own device are exercised only on device 0.