-
-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring towards GPU support #794
Conversation
Currently only numpy, but will make it easier to support other numpy-like libraries
This ends up being a scalar array when called with a cupy argument
- Unify int/float/bool logic paths: - Add masked_clip_2d function that clips an array of either float or int values - Copy input data and offset in place - construct uint32 view once at the end of function rather than in branches - Don't interpolate r/g/b unnecessarily when a single color is passed as cmap.
…rather than nans) Prior structure was not compatible with the numba.cuda.atomic.add operation
These will provide a central place to handling of numpy-like (e.g. cupy) and pandas-like (e.g. cudf) objects.
This way we can later pass configuration arguments this them
I think I've figured out a way to support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of 517fc97, I've reviewed all the commits in this PR, and as far as I can tell they are all mergeable. So, once you're done with any further commits, I should be able to review those quickly and merge the whole PR. Thanks for all this!
Fix area glyph tests: Slight changes here are due to the fact that these tests are now performed in data, rather than pixel, coordinates
Ok, I did a bit more refactoring of lines in d7f3650 and area in b5dbf1d. The goal was to make it possible to support parallelization with I also managed to eliminate a fair amount of code duplication by having the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commits also look good, thanks. I have only one concern before merging: the changes to line and area handling look extensive enough that they could have performance implications. Have you run a basic performance comparison before and after this PR, to make sure nothing got terribly slower? As long as you've made some basic check like that, I'm happy to merge now.
Thanks, I've done several benchmarks and I'm seeing equivalent performance (with +-5%). e.g., for 10 million points with
|
Looks great, thanks!! |
Overview
This PR lays the foundation for adding GPU support to Datashader. It contains the refactoring portion of #793, without adding the CUDA specific code. After this PR is reviewed and merged, I'll open another PR that adds the cuda support on top of this.
Fix
While refactoring, I found the cause of #792, which is fixed in 30a2ae2. I think we could cherry pick this commit into a separate PR if folks would rather it be separated from this PR.
Changes
pandas
,dask
,xarray
) under a newdata_libraries
package. When cudf support is added, a new module will be added here. (258ceca )Glyph._compute_x_bounds
andGlyph._compute_y_bounds
methods with a singleGlyph._compute_bounds
method. The old methods assumed the input was a numpy array. The new method checks if it is a numpy array or a pandas series. When cudf is added, this method will also check if the input is acudf.Series
object. (40c3b61 )ds.count()
), an integer reduction column is used (e.g.ds.count('int_column')
), a float reduction column is used (e.g.ds.count('float_column')
). This is needed because numba's cuda mode does not seem support default arguments, and it doesn't allow the use ofisnan
on integer columns. (7b31140)np.interp
in preparation for swapping in a different implementation forcudf.ndarray
objects. (63ec2fd)np.nonzero
to an integer as thecudf
equivalent results in scalar array instead. (cc3ff21)_interpolate
function, which is called byshade
(7a10a49)masked_clip_2d
function that clips an array of either float or int values. There will be a cupy specific implementation of this later._sum_zero
reduction to compute sum from an array of zeros. The standardsum
reduction starts with an array ofnans
and the append operation has a different logic branch depending on whether a pixel starts as nan. This approach is not compatible with the cuda atomic operations. For cuda,sum
will be implemented by combining_sum_zero
withany
. (cf7f5c8)bounds
andvt
tuples in the signatures of numba functions asnumba.cuda.jit
doesn't seem to support tuples. (b57e0a9, 7fe52db).numba.cuda.jit
doesn't seem to support tuples. (b57e0a9).numpy.log
andnumpy.isnan
tomath.log
andmath.isnan
for use in numba functions becausenumba.cuda.jit
doesn't support the numpy versions. (e073961)_bases
and_temps
properties ofReduction
objects into methods (_build_bases
,_build_temps
). This way we can pass configuration options to them (like whether or not to operate in cuda mode). (517fc97)