Add CUDA support for std and var reductions #1267
Merged
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.
This PR adds support for CUDA
std
andvar
reductions, both with and withoutdask
. This means that all reductions now work on CPU and GPU, with and without dask, with the exception that some reductions do not yet support antialiasing but this is work in progress which will be completed soon.The changes here rely on the use of a CUDA mutex that was recently added (#1196, #1212, #1217) which allows us to use more complicated multi-stage per-pixel operations and keep them atomic. This particular PR adds an extra layer of CUDA mutex usage via an enumerated type so that the CUDA mutex use is not just local to a single reduction (
UsesCudaMutex.Local
) but can also be global to the wholereduction.append
pipeline (UsesCudaMutex.Global
). It is necessary forstd
andvar
as their constituent sub-reductions which calculate the count, sum and variance need to be atomic so that they are not interrupted by another CUDA thread working on the same pixel.