Singular values calculation only of a real matrix with CUDA

Besides the full SVD of a matrix, see SVD of a real matrix, by cusolverDnSgesvd, it is possible also to calculate only the singular values of a matrix.

On our GitHub website, we report a sample code with two calls to cusolverDnSgesvd, one performing the singular values calculation only

cusolverDnSgesvd(solver_handle, 'N', 'N', M, N, d_A, M, d_S, NULL, M, NULL, N, work, work_size, NULL, devInfo)

and one performing the full SVD calculation

cusolverDnSgesvd(solver_handle, 'A', 'A', M, N, d_A, M, d_S, d_U, M, d_V, N, work, work_size, NULL, devInfo)

As it can be seen, the two ‘A’ fields for the full SVD case are changed to ‘N’ in the singular values only case. Please, note that, in the singular values only case, there is no need to store space for the singular vector matrices U and V. Indeed, a NULL pointer is passed.

The singular values calculation only is faster than the full SVD calculation. On a GTX 960, for a 1000×1000 matrix, the timing has been the following:

Singular values only: 559 ms
Full SVD: 2239 ms

Of course, calculating the singular values only is significantly faster.


			

Leave a Reply

Your email address will not be published. Required fields are marked *