[Haskell-cafe] ANN: FFI bindings to cuBLAS and cuSPARSE

Ben Sherman benmsherman at gmail.com
Fri Jul 11 05:00:22 UTC 2014


I have written FFI bindings to the cuBLAS and cuSPARSE libraries, which are CUDA libraries for executing linear algebra computations on the GPU. It's a relatively straightforward translation of the C API. It's slightly novel in that I use language-c and Template Haskell to parse the C headers and create the FFI declarations, avoiding the boilerplate that may otherwise be necessary, even using a preprocessor such as c2hs.

http://hackage.haskell.org/package/cublas-0.2.0.0

I've done a similar thing with a subset of the MAGMA GPU library. It's less polished, and the installation process is more unforgiving, so I haven't put it up on Hackage.

https://github.com/bmsherman/magma-gpu

Finally, I've written a library which abstracts the immutable API of hmatrix and provides a pure, hmatrix-like interface for cuBLAS/MAGMA, enabling simultaneous development of linear algebra programs using either hmatrix or the above GPU bindings as backends. Additionally, I have written "medium-level" mutable and immutable interfaces to cuBLAS/MAGMA (in LinAlg-magma). I use a type system trick reminiscent of the ST monad to allow mutable operations to read from either immutable or mutable datatypes, so it is easy to mix pure and destructive computations in a safe manner. I really made these libraries only complete enough to suit my purposes; I imagine many improvements can be made.

https://github.com/bmsherman/LinAlg
https://github.com/bmsherman/LinAlg-magma
https://github.com/bmsherman/LinAlg-hmatrix

Any feedback, bug reports, or pull requests are most welcome!


More information about the Haskell-Cafe mailing list