Skip to content

Comments

Add support for CUDA Array Interface for interoperability with other Python libraries (resolves #633)#675

Merged
neworderofjamie merged 11 commits intogenn-team:masterfrom
JRV7903:master
May 5, 2025
Merged

Add support for CUDA Array Interface for interoperability with other Python libraries (resolves #633)#675
neworderofjamie merged 11 commits intogenn-team:masterfrom
JRV7903:master

Conversation

@JRV7903
Copy link
Contributor

@JRV7903 JRV7903 commented May 4, 2025

  • Added the cuda_array_interface property to the Array class to expose CUDA array data for interoperation.
  • Implemented getDevicePointer() in the Array class to retrieve device pointers.
  • Updated the cudaBackend.cc and backend.h files to handle the device pointers and support CUDA-specific array operations.
  • Modified model_preprocessor.py to enable the inclusion of the cuda_array_interface property for array interoperability.
  • Created a new test file test_cuda_interface.py for verifying the changes and ensuring the correct functionality of the CUDA array interface.

Copy link
Contributor

@neworderofjamie neworderofjamie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really great - nice work! Just a few minor suggestions

@neworderofjamie neworderofjamie added this to the GeNN 5.3.0 milestone May 4, 2025
JRV7903 and others added 4 commits May 5, 2025 18:29
Co-authored-by: neworderofjamie <neworderofjamie@gmail.com>
Co-authored-by: neworderofjamie <neworderofjamie@gmail.com>
Co-authored-by: neworderofjamie <neworderofjamie@gmail.com>
- Removed unnecessary numpy dtype parameter in test_cuda_interface
- Added backend_cuda fixture for selective test execution
- Moved CUDA-specific doc comments from backend.cc to backend.h
- Made getDevicePointer inline in the header
- Fixed dtype resolution bug in model_preprocessor.py
- Added CuPy to test dependencies and CI install list
@JRV7903
Copy link
Contributor Author

JRV7903 commented May 5, 2025

Thank you for reviewing the PR. I’ve fixed the bug so that CuPy now correctly receives a NumPy datatype. I’ve also implemented the other requested changes.

Copy link
Contributor

@neworderofjamie neworderofjamie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! If you can accept my one suggestion, I will merge

Co-authored-by: neworderofjamie <neworderofjamie@gmail.com>
@JRV7903
Copy link
Contributor Author

JRV7903 commented May 5, 2025

Thanks for the review! I’ve applied the dtype fix only to the CUDA array interface implementation, where it was necessary. I reverted the change in set_array, since NumPy’s view() works correctly with string-based dtype representations. Appreciate the feedback and the learning opportunity!

@neworderofjamie neworderofjamie linked an issue May 5, 2025 that may be closed by this pull request
@neworderofjamie neworderofjamie merged commit ead9eb0 into genn-team:master May 5, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support CUDA array protocol for interopability

2 participants