-
Notifications
You must be signed in to change notification settings - Fork 10
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 array interface #42
base: master
Are you sure you want to change the base?
Cuda array interface #42
Conversation
Prior to this commit CudaDataManager::GetGPUBufferPointer() returned a pointer to the GPU buffer pointer. Its return type should have been void**. Every usage of this method across RTK and CudaCommon dereference the returned pointer pointer, so just return the buffer pointer directly as it required for future commits adding support for __cuda_array_interface__
Adapt ITK's PyBuffer approach to inject __cuda_array_interface__ in wrapped code. Closes RTKConsortium#10
@SimonRit regarding the 3rd point "Check shape order (i,j,k) (ITK-style) vs (k, j, i) (Numpy style)", it looks like cupy can handle both, but the default should probably be the numpy style (C-style). Do you think we should just reverse the shape to always use C-style, or should we introduce a class attribute to control the order expected by users. ITK provides a keep_axes parameter in GetArrayViewFromImage to control this behavior. FWIW changing the order of the order parameter in cupy.array does not seem to have impact, only the shape matters. https://docs.cupy.dev/en/stable/reference/generated/cupy.array.html#cupy-array |
Do you intend to add tests? If yes, it would be good to add it to the list... |
6fe09e2
to
ddf2c11
Compare
Adding a test requires cupy to be installed. Should we add some CMake/Python magic to automatically install it based on the detected cuda version? Or just import cupy in a try/catch statement in the test file to throw a nice error message if it is not installed? |
ITK expects numpy to be installed at runtime and just install it in CI scripts. We should do the same, but it looks like tests are not executed in the python CI workflow. This should be added in another PR, but I will add a test in the meantime |
If you need cupy to do the test, I think we should wait for a subsequent PR to implement it, when we implement helper functions such as |
ddf2c11
to
7a76f08
Compare
Sounds good! I'm attaching the script we used for testing a few types, as it could be useful later to implement the test: I'll check how much effort it is to implement |
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.
I only have minor suggestions. I think we should document the API change and export the version number (CUDACOMMON_VERSION_MAJOR, CUDACOMMON_VERSION_MINOR) to let the user adapt his / her code depending on the version.
This allows modules like RTK to easily reuse files from the CudaCommon sources, e.g. CudaImage.i.init and CudaImage.i.in
7a76f08
to
07b6a32
Compare
Sounds good. Then it will probably be version 2.0.0, and we can export it juste like CudaCommon_SOURCE_DIR for other modules to use it. Does this sounds good to you? |
Yes, also with a header like rtkConfiguration.h.in to access it from the C++ code please. |
f7da3c7
to
792d00e
Compare
Add support for __cuda_array_interface. Closes #10
TODO:
- [ ] Add test- [ ] Improve descriptor and check other elements in __cuda_array_interface dictand bump version(see RTK#617)Code used to test the approach (requires cupy-cuda12x):