GeezerVison is showing github.com — cuda: serialise constant-memory uploads with their kernel launches by melonakos · Pull Request #3725 · arrayfire/arrayfire
Conversation
melonakos
commented
Sep 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Calling af::convolve from several host threads on the CUDA backend can silently return results computed with another thread's filter (#3711). convolve, morph and transform stage per-call data through a constant symbol of a cached module, and the upload and the launch are both asynchronous on the single stream every host thread shares, so two threads can interleave upload, upload, launch, launch. A lock is now held from the upload through the launch enqueue at all seven sites and released before the post-launch check, which synchronises the stream in debug builds and with synchronous calls enabled. Adds a threading test with a distinct filter per thread at the file's usual 32 threads and 1000 iterations.
Draft because there is no NVIDIA GPU here: the backend compiles under CUDA 13 apart from the master breakages #3715 fixes, and the test passes on the CPU backend, but it has not been seen to fail on the unfixed CUDA code. canny and floodFill keep a per-call flag in a device variable and have the same class of bug; not covered here, noted in the mutex comment, and to be filed separately.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
convolve, morph and transform stage per-call data through a __constant__ symbol of a cached module, and both the upload and the launch are asynchronous on the one stream shared by every host thread. Two threads could interleave upload, upload, launch, launch and the first launch ran with the second thread's filter, silently. Hold a lock from the upload through the launch enqueue at all seven sites, and add a threading test that runs a distinct filter per thread. Fixes #3711.
POST_LAUNCH_CHECK synchronises the stream in debug builds and whenever
synchronous calls are enabled, so the guard now ends before it. The
threading test uses the file's THREAD_COUNT and ITERATION_COUNT, the kernel
headers include platform.hpp for the declaration, and the mutex comment says
that the per-call flags in canny and flood_fill are not covered.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.