9
$\begingroup$

I am looking for GPU libraries to accelerate a code I have, whose primary "high performance" regions have singular value decomposition, QR factorization and Eigen values, Eigenvectors computation. I have looked through Nvidia's website on its tools like CuBLAS,Magma etc., but I do not want to write the code in Cuda.

it would be wonderful if there are any libraries out there which I can just "call" from my main C code for things like SVD,QR etc., and the computation would be done on the GPUs. So in summary, I have a normal C code, in which the intensive linear algebra operations are accelerated. Does anyone know of an open source (preferably) library which can do this?

Thanks.

$\endgroup$

3 Answers 3

8
$\begingroup$

For [CU]BLAS, there is a wrapper called 'thunking' in the CUDA toolkit (src/fortran_thunking.{c,h}) that takes pointers from CPU memory and does all the GPU allocation/copying for you. You can plug it into your code with a preprocessor statements like

#define ZGEMV CUBLAS_ZGEMV
#define ZGEMM CUBLAS_ZGEMM
...

For LAPACK, Magma has CPU-side interfaces for most, if not all, of its functionality (they tend to be implemented first) so, like with thunking, you just swap calls. In some cases the interfaces or workspace requirements might be a bit different, so you'll want to be a bit more careful than with thunking.

The necessary disclaimer is that there is no free lunch: if you're not willing to at least handle the memory copies explicitly, your performance is going to be limited to large problems with high computational intensity (flops / bytes). If your problems are small and/or batched, I'd highly recommend that you write some control code to stream the memory copies and library calls to overlap memory copies and computation. This isn't really CUDA, as much as an API, since you don't need to write kernels. Both CUBLAS and Magma provide API calls for specifying streams.

$\endgroup$
4
$\begingroup$

Karl Rupp, who writes ViennaCL (http://viennacl.sourceforge.net/) and is on Computational Sci StackEx, might be able to chime in here - their library has multiple matrix decompositions including SVD, LU, eigendecomp, etc. It's also a header-only library, and should play well with C++ (not sure about C) code.

An example of it in use with LU factorizations - http://viennacl.sourceforge.net/viennacl-examples-dense-matrix.html.

$\endgroup$
2
  • $\begingroup$ See for his previous description. scicomp.stackexchange.com/questions/376/… $\endgroup$
    – Jesse Chan
    Commented Sep 30, 2013 at 6:58
  • $\begingroup$ We are about to open ViennaCL up to languages other than C++. A pure C-interface for BLAS operations will become available with the upcoming 1.5.0 release, and more of the factorization algorithms with 1.6.0. $\endgroup$
    – Karl Rupp
    Commented Oct 15, 2013 at 8:33
3
$\begingroup$

You may want to have a look at the CULA library, which implements a number of the most common LAPACK/BLAS operations in single precision (free edition) and double precision (full edition, i.e. paying version).

The library works as a direct replacement for LAPACK/BLAS, so if you already use these functions in your original code, you shouldn't have to change anything.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.