Use fast cuda mutex available in numba 0.57 #1212
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.
Fixes #1211.
For
numba >= 0.57
there is a CUDA mutex that is lockable on a per-pixel basis whereas earliernumba
doesn't have the required functionality so there is a single lock shared between all pixels. Complicated CUDA reductions such asmax_n
need the mutex so that they work atomically; the new mutex allows the CUDA code to work in parallel very efficiently whereas the old solution forces datashader to run mostly serially.There is very little code changed here. The
numba.__version__
is used to select the appropriate mutex lock and unlock functions, and the size of thecupy
array used for the mutex. Other than that there is a new argument to theinfo
function as the canvas shape is needed. Although this argument is only needed for CUDA code running a complicated reduction such asmax_n
, I have chosen to pass it for every call rather than dynamically determine at the point of calling whether it is needed or not.As an illustration of performance, demo code:
and time the
canvas.points
call, discarding the first timing as this includesnumba
compilation. This gives the following timings (usingnumba 0.56.3
andnumba 0.57
for theslow
andfast
mutex):GPU on test system is an Nvidia Quadro T1000.