cuda: serialise constant-memory uploads with their kernel launches - #3725
Draft
melonakos wants to merge 2 commits into
Draft
cuda: serialise constant-memory uploads with their kernel launches#3725melonakos wants to merge 2 commits into
melonakos wants to merge 2 commits into
Conversation
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 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.
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.