Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6956 Discussions

SVD runs very slow and sometimes doesn't return for matrices which cannot converge

Huang_X_
Beginner
672 Views

Hi Guys

I have been struggling with the MKL SVD computation recently. So I really appreciate if anyone can help out.

Basically I am using MKL SVD to calculate the first two eigenvectors for a matrix. I use the LAPACK_dgesvd method in the MKL to do the job. It runs fairly fast for matrix which can converge. But for those who can't converge, MKL SVD runs extremely slow and sometimes it never return. I am not sure what is going on behind the scene. Maybe MKL just tries exhaustively when the matrix can't converge?

My questions is:

1. If there is any method which can just compute two eigenvectors rather than all of them?

2. if there is a way to set the max iteration for SVD computation or timeout when matrix cannot converge.

 

thank you very much in advance.

0 Kudos
5 Replies
Alexander_K_Intel3
672 Views

Hello,

You also could try LAPACKE_dgesdd, which utilizes Divide and Conquer method and should be faster. If it didn't converge it returns an error.

We don't expect LAPACKE_dgesvd to hang even in worst case, it also should return convergence error. Could you please help us to reproduce the case.

We don't have functionality to extract only few singular values. And this case not much faster than full SVD since major steps of SVD have to be computed anyway.

Thanks, Alexander

0 Kudos
Huang_X_
Beginner
672 Views

Hi Alexander

Thank you so much for your reply. I think it is really helpful that you point out the dgesdd. 

Also, I am sorry for the confusion. I don't think MKL hangs, it is still running but just takes very long time to return so I had to manually kill the process. In my own SVD implementation, I set the max iteration to be 100. If the max iteration is exceeded, I will just give up the computation and return. Is there a way to do the similar thing in MKL SVD? I don't want the computation to run for very long time to get the results. If within some time or some iterations, there are no converged results, MKL can just give up and return error info. Thank you again for your help.  

0 Kudos
Ying_H_Intel
Employee
672 Views

Hello Huang X.

Could you provide us a small test case (include the input matrix) to reproduce the no-converge problem.  We doubt it may be a bug, So a test case will be helpful.If the test case is confidential, you can email us by Send Author A message.

Thanks

Ying

0 Kudos
Huang_X_
Beginner
672 Views

Hi Ying

Thank you so much for your reply. It actually turns out to be the JNI badness for the problem. dgesvd can actually return even there is no-converge. Now I moved to dgesdd and it is amazing fast. Sorry for the confusion and also thanks a lot for the help. I have one more question though, I am only using SVD computation in MKL. But I need to package the entire MKL into my application which is a bit big. Can I just package the libs needed by MKL? 

0 Kudos
Ying_H_Intel
Employee
672 Views

Hello Huang X,

Nice to know this results.

Regarding the package, how do you link the MKL into your program?  I guess, you may create a  custom dll (name it as your.dll/so), which link MKL static library.  Then you don't need packag the entire MKL into your application. And your.dll /so will support SVD computation.  

You can create your custom dll file.  Or use the build tools under MKL install directory, i.e C:\Program Files (x86)\Intel\Composer XE 2013\mkl\tools\builder, edit the user_example_list, then build.  Please see  more detials in MKL user guide.

Best Regards,
Ying

 

0 Kudos
Reply