Skip to content
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

CUDA functions do not support tuple expansion #6532

Open
philippjfr opened this issue Dec 1, 2020 · 2 comments
Open

CUDA functions do not support tuple expansion #6532

philippjfr opened this issue Dec 1, 2020 · 2 comments
Labels
CUDA CUDA related issue/PR feature_request

Comments

@philippjfr
Copy link

In Datashader we recently ran into an issue with a function that uses tuple expansion, which would compile for CPU targets but not on CUDA. This seemed to be because it didn't expand out the tuple and would then perform the wrong operation. Specifically this was this function:

def _bresenham(i, sx, tx, sy, ty, xmin, xmax, ymin, ymax, segment_start,
                  x0, x1, y0, y1, clipped, append, *aggs_and_cols
                 ):
    ...
    append(i, x0, y0, *aggs_and_cols)

This would fail during compilation with this error:

 >>> add(Tuple(int32, int64, int64), array(uint32, 2d, C))
There are 12 candidate implementations:
      - Of which 2 did not match due to:
      Operator Overload in function 'add': File: unknown: Line unknown.
        With argument(s): '(Tuple(int32, int64, int64), array(uint32, 2d, C))':
       No match for registered cases:
        * (int64, int64) -> int64
        * (int64, uint64) -> int64
        * (uint64, int64) -> int64
        * (uint64, uint64) -> uint64
        * (float32, float32) -> float32
        * (float64, float64) -> float64
        * (complex64, complex64) -> complex64
        * (complex128, complex128) -> complex128
      - Of which 10 did not match due to:
      Overload of function 'add': File: <numerous>: Line N/A.
        With argument(s): '(Tuple(int32, int64, int64), array(uint32, 2d, C))':
       No match.
During: typing of intrinsic-call at /home/philippjfr/development/datashader/datashader/glyphs/line.py (736)

Presumably because the aggs_and_cols tuple was not being unpacked causing append to try to add the whole tuple to 2D array, which would fail the type check. If CUDA could support tuple unpacking that would be great although not hugely important for datashader since we have a macro that automatically expands out functions using tuple unpacking by manipulating the AST and recompiling a fully expanded function (which we implemented for optimization reasons).

@philippjfr philippjfr changed the title CUDA functions do not expand tuples CUDA functions do not support tuple expansion Dec 1, 2020
@stuartarchibald stuartarchibald added CUDA CUDA related issue/PR needtriage labels Dec 1, 2020
@stuartarchibald
Copy link
Contributor

Thanks for the report.

CC @gmarkall

@gmarkall
Copy link
Member

Thanks for the report - I'll mark this as a feature request for CUDA. I think this is something that could be looked at once the work on making the CUDA dispatcher share more infrastructure with the CPU dispatcher is more complete (e.g. #6432).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CUDA CUDA related issue/PR feature_request
Projects
None yet
Development

No branches or pull requests

3 participants