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

Add support for passing cupy arrays to "C" lang #226

Merged

Conversation

bouweandela
Copy link
Contributor

Add support for passing cupy arrays to "C" lang compiler.

Closes #224

@bouweandela bouweandela marked this pull request as ready for review November 8, 2023 13:19
@bouweandela
Copy link
Contributor Author

bouweandela commented Nov 8, 2023

I'm not entirely sure where to update the documentation and examples. I think e.g. this example
https://github.com/bouweandela/kernel_tuner/blob/4719acdf4ff096a6e9586e0148c6a9753335393d/examples/cuda/convolution_streams.py#L22-L23
could be simplified by using cupyx.zeros_pinned to allocate the memory. Please let me know if I missed anything.

@benvanwerkhoven
Copy link
Collaborator

Thanks a lot for your work on this Bouwe!

I think actually the Point-in-Polygon example might be easier to adapt:
https://github.com/kerneltuner/kernel_tuner/blob/master/examples/cuda/pnpoly.py
The current example uses PyCUDA and indeed passes a GPU memory allocated created using PyCUDA to the Compiler backend. So you could create a variant of that using CuPy instead of PyCUDA, now that you've made this possible. The advantage of only changing the point-in-polygon example is that you don't need to change the CUDA code.

For the time being, I think it's fine to just copy the old example to a new file and call this pnpoly_cupy.py. Perhaps at some point we should consider grouping examples into directories by what backend they are using.

Copy link

sonarcloud bot commented Nov 14, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@bouweandela
Copy link
Contributor Author

For the time being, I think it's fine to just copy the old example to a new file and call this pnpoly_cupy.py.

Done in 303ef3a

@benvanwerkhoven
Copy link
Collaborator

Thanks a lot @bouweandela ! I've extensively tested everything in this pull request, it all seems to work perfectly!

@benvanwerkhoven benvanwerkhoven merged commit e76b774 into KernelTuner:master Nov 27, 2023
4 checks passed
@bouweandela bouweandela deleted the add-compiler-cupy-array-support branch December 30, 2023 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing cupy arrays to the compiler backend
2 participants