scikit-cuda
scikit-cuda copied to clipboard
Wrapping tridiagonal methods from cuSPARSE
As suggested by @wingkitlee0 , I'm opening a fresh issue based my post here: #44 .
I need cusparseSgtsv2StridedBatch and cusparseSgtsvInterleavedBatch wrapped (which probably also requires wrapping cusparseSgtsv2StridedBatch_bufferSizeExt): https://docs.nvidia.com/cuda/cusparse/index.html#gtsv2stridedbatch .
I expect these wouldn't be hard to wrap, because their arguments are actually just specially formatted dense matrices, so using them shouldn't depend on any other cuSPARSE functions. But I don't know where to start. Does anyone have time to wrap them?
If not, what's the best way for me to learn how to wrap them for skcuda? I see that, for example, s._libcusparse.cusparseDgtsv2StridedBatch is a well-defined function pointer. Is it as simple as defining restypes and argtypes? If so, is there a skcuda module that would be a best-practices example?
BTW: import skcuda.cusparse fails for me, at the import cuda line. There's no cuda. anywhere the module, so I assume this is an oversight. If I remove that line, I can import the module and run some of the simple functions within.
Hi @RyanGutenkunst,
First, this project has very few traffic and very few people to maintain. So the task depends on how much time you put on it. Last time it took us about a week or so to wrap some functions (see #289 ) when I had some free time. I probably don't have time to contribute code for this but I am happy to answer questions.
If not, what's the best way for me to learn how to wrap them for skcuda?
I think cublas.py
should be a good place to start. You are basically right about restypes
and argtypes
. I suggest you prepare some test cases to check the code.
import skcuda.cusparse fails for me, at the import cuda line.
It should be from . import cuda
as in other files. Probably a Python 3 change.
Thanks @wingkitlee !
I've created a fork to work from: https://github.com/RyanGutenkunst/scikit-cuda . I'll get started and post here when I hit problems and need help or (hopefully) make progress and need feedback.
I've implemented the methods I care about in cuSPARSE. There are unit tests for them in tests/test_cusparse.py . A few things I could use input on below. If it's more appropriate, I can submit a pull request at this point for feedback.
- My only box with an NVIDIA GPU is Windows, so I haven't been able to test in other environments. Can someone help with that?
- I tried creating the appropriate file in docs to get the methods I implemented documented, but I'm getting a bunch of errors when I try to run Sphinx, and the docs aren't getting fully created. I'm not experience with Sphinx. Can anyone help with debugging that?
- I removed the incomplete previously existing methods from cusparse.py . I don't know if that's preferred to keep the source clean, or whether I should put them back to preserve that incomplete work.
Sounds like you got it working already!
Maybe @lebedov (the owner of this repo) can answer your questions about OS, sphinx, and pull request.