interfacing cuSolver with MATLAB - matlab

I like to use cuSolver code for Eigen value decomposition of complex matrix in Matlab.
I am using MATLAB CUDA kernel and it seems that its not possible to interface cuSolver with MATLAB as the cuSolver contains the code for host as well as for device (as mentioned here: http://docs.nvidia.com/cuda/cusolver/#syevd-example1)
while MATLAB CUDA kernel works only for the kernel function..
Please comment.
Any other idea to compute Eigenvalue decomposition of large no of matrices containing complex data in parallel on GPU by using Matlab environment?

You almost certainly need to use the MEX interface. This allows you to take in gpuArray data, and call kernels and other CUDA library functions.
See the doc: http://uk.mathworks.com/help/distcomp/run-mex-functions-containing-cuda-code.html for more.

Related

CUDA implementation for MATLAB code

I have recently purchased a P100 GPU in hopes of speeding up parallel code and need some help deciding how to translate MATLAB code into a CUDA code ( I've moved away from plain gpuarrays in MATLAB ). I have experimented with .ptx kernels and MEX-files and have run into some roadblocks with both.
The parallel code has elementwise exponentiation, elementwise multiplication, and FFT and IFFT calls. It also incorporates complex numbers.
Are .ptx files compiled from CUDA-kernels or MEX CUDA files easier to work with and which will allow me to perform my necessary FFT, IFFT, exp, and mult calls?
It's simple really. You have to use MEX because you want to call into the NVIDIA cufft library, which you can only do from the host. However, there are basically no circumstances in which you will get a reasonable speed-up over calling FFT and IFFT from MATLAB, because those functions just call directly into cufft, with the added advantage of MATLAB's GPU memory pool and FFT plan cache. So maybe you should focus on the element-wise kernels.

What algorithm does MATLAB use to find eigenvectors?

So I am using MATLAB for a project and am discussing the use of the power method for finding stationary distributions of Markov chains and its convergence rate. I was wondering what method/algorithms MATLAB's eig() function uses to find the eigenvectors of a matrix?
Normally Matlab is using LAPACK routines to do calculation. With that in mind I guess that from here you will be able to find the code that matlab runs. Be Aware LAPACK is in Fortran.
MATLAB Incorporates LAPACK

matlab parallel eigenvalue decomposition

It's been a wile I'm trying to come up with an algorithm for parallel eigenvalue decomposition, but non of the algorithms I tried can beat matlab's eig algorithm, so is there anyone who knows which algorithm does matlab use for the eig function ?
or is can anyone suggest me a good parallel algorithm for eigenvalue decomposition ?
MATLAB uses LAPACK for its higher level linear algebra. According to MATLAB's version command, it is Intel's Math Kernel Library (MKL):
>> version('-lapack')
ans =
Intel(R) Math Kernel Library Version 11.0.2 Product Build 20130124 for Intel(R) 64 architecture applications
Linear Algebra PACKage Version 3.4.1
Intel MKL includes very fast implementations of BLAS and LAPACK, but it is not free. For open source options, try Eigen and Armadillo. Their APIs are very intuitive and they are quite fast. And if you believe Eigen's claims, they are the fastest open BLAS available with a superior API to the reference netlib LAPACK (IMO the API claim is pretty obvious once you take a look at the Fortran version!)
You can use Armadillo with OpenBLAS. Both are open source. Recent versions of OpenBLAS also provide LAPACK functions. OpenBLAS uses multiple cores (ie. runs in parallel).
When using Armadillo's eig_sym() function, specify that the divide-and-conquer method is to be used. This makes a big difference on large matrices. For example:
eig_sym(eigval, eigvec, X, "dc")
btw, you can also link Armadillo based code with Intel MKL instead of OpenBLAS. MKL also provides highly optimised LAPACK functions.

Can a Matlab function be used in a CUDA kernel?

The lsqcurvefit Matlab function is used to fit the paramaters of a model curve to a real curve (acquired data from experiment or observation) so that de square differences are minimized. lsqcurvefit
The function is time consuming, and maybe prohibitive if used on large set of curves.
Can it be straightforwardly used inside a CUDA kernel, being then all the program coded in Matlab? (Edit: this is, without writing a custom version of lsqcurvefit in C for the kernel. For instance: write the kernel code in Matlab (using there "any" matlab function like lsqcurvefit()), then compile the kernel with a Matlab provided tool, and finally execute the kernel in the GPU, called from matlab host code).
Thanks
There are many ways to combine the capabilities of matlab with GPUs, but there isn't any matlab code that can be used in a CUDA kernel.

Lapack SPPTRF available?

do you know if MATLAB supports the LAPACK spptrf function.
This function is quite a bargain when you gotta compute Cholesky factorization of a huge positive definite symmetric matrix.
It allows for the factorization by only giving the upper triangular matrix, stored as uni-dimensional matrix, as input.
Or, else, is chol built-in function already using spptrf internally?
EDIT
I have been able to find the lapack library on the File Exchange http://www.mathworks.com/matlabcentral/fileexchange/16777-lapack, with the desired implementation of the spptrf function.
EDIT 2
MATLAB running on my machine is fatally crashing each time I call spptrf.
Is there any alternative way to directly handle this function?