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

What is the difference beween LAPACKE_?gesvd and ?gesvd

LinkDeng
Beginner
1,266 Views

Hi, all

  I am working on my C++ project, in which SVD (mainly use zgesvd) is one key step. Intel oneAPI provides great SVD functions with high precision and  processing speed. 

  But I feel comfused cause I do not finger out the difference between the two C interface called LAKPCE_zgesvd and zgesvd, both provided correct results. 

  So please anyone can explain the difference between the two fuctions, and the best scenario for each function interface call? Thanks.

0 Kudos
1 Solution
ShanmukhS_Intel
Moderator
1,215 Views

Hi LinkDeng,


Thanks for posting in Intel communities.


Intel oneAPI provides great SVD functions with high precision and processing speed. 

>> Thank you for the positive feedback!!!


Regarding the query about the significance of the routines mentioned by you, you could refer to the below description. You could see, that the implementations of the routines were a bit different considering matrix layouts, etc., and the corresponding interface being used.


1. zgesvd: This is the standard LAPACK function which corresponds to the Fortran interface implementation of c code. 


You could refer to the zgesvd.c source code under the MKL_examples path below.

<MKL path>\2023.2.0\examples\examples_core_c.zip\c\lapack\source


2. LAKPCE_zgesvd: LAPACKE is a C interface to LAPACK, allowing users to call LAPACK routines from C/C++ code. LAPACKE_zgesvd is a C wrapper function for zgesvd. It provides an interface that is more accessible and convenient for C and C++ programmers.


The C interfaces are implemented for most of the Intel oneAPI Math Kernel Library (oneMKL) LAPACK driver and computational routines.


In contrast to the Fortran interface, the LAPACK C interface omits workspace parameters because workspace is allocated during runtime and released upon completion of the function operation.


Intel® oneAPI Math Kernel Library (oneMKL) supports four distinct floating-point precisions. Each corresponding prototype looks similar, usually differing only in the data type. C interface LAPACK function names follow the form<?><name>[_64], where <?> is:


LAPACKE_s for float

LAPACKE_d for double

LAPACKE_c for lapack_complex_float

LAPACKE_z for lapack_complex_double


You could refer to the lapacke_zgesvd_col.c or lapacke_zgesvd_row.c source codes under the MKL_examples path below.

<MKL path>\2023.2.0\examples\examples_core_c.zip\c\lapack\source


In addition, you could go through the below link for more details regarding the syntax, description, parameters etc. regarding the API.

https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2023-2/gesvd.htmlt


C convention LAPACK_DECL: mkl_lapacke.h

lapack_int LAPACKE_zgesvd( int matrix_layout, char jobu, char jobvt,

              lapack_int m, lapack_int n, lapack_complex_double* a,

              lapack_int lda, double* s, lapack_complex_double* u,

              lapack_int ldu, lapack_complex_double* vt,

              lapack_int ldvt, double* superb );


Fortran convention zgesvd declaration: mkl_lapack.h


void zgesvd( const char* jobu, const char* jobvt, const MKL_INT* m,

       const MKL_INT* n, MKL_Complex16* a, const MKL_INT* lda, double* s,

       MKL_Complex16* u, const MKL_INT* ldu, MKL_Complex16* vt,

       const MKL_INT* ldvt, MKL_Complex16* work, const MKL_INT* lwork,

       double* rwork, MKL_INT* info ) NOTHROW;


In addition to all the information mentioned above, you could go through the below link for more details on C and Fortran interfaces.

https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2023-2/c-interface-conventions-for-lapack-routines.html


Best Regards,

Shanmukh.SS


View solution in original post

0 Kudos
3 Replies
ShanmukhS_Intel
Moderator
1,216 Views

Hi LinkDeng,


Thanks for posting in Intel communities.


Intel oneAPI provides great SVD functions with high precision and processing speed. 

>> Thank you for the positive feedback!!!


Regarding the query about the significance of the routines mentioned by you, you could refer to the below description. You could see, that the implementations of the routines were a bit different considering matrix layouts, etc., and the corresponding interface being used.


1. zgesvd: This is the standard LAPACK function which corresponds to the Fortran interface implementation of c code. 


You could refer to the zgesvd.c source code under the MKL_examples path below.

<MKL path>\2023.2.0\examples\examples_core_c.zip\c\lapack\source


2. LAKPCE_zgesvd: LAPACKE is a C interface to LAPACK, allowing users to call LAPACK routines from C/C++ code. LAPACKE_zgesvd is a C wrapper function for zgesvd. It provides an interface that is more accessible and convenient for C and C++ programmers.


The C interfaces are implemented for most of the Intel oneAPI Math Kernel Library (oneMKL) LAPACK driver and computational routines.


In contrast to the Fortran interface, the LAPACK C interface omits workspace parameters because workspace is allocated during runtime and released upon completion of the function operation.


Intel® oneAPI Math Kernel Library (oneMKL) supports four distinct floating-point precisions. Each corresponding prototype looks similar, usually differing only in the data type. C interface LAPACK function names follow the form<?><name>[_64], where <?> is:


LAPACKE_s for float

LAPACKE_d for double

LAPACKE_c for lapack_complex_float

LAPACKE_z for lapack_complex_double


You could refer to the lapacke_zgesvd_col.c or lapacke_zgesvd_row.c source codes under the MKL_examples path below.

<MKL path>\2023.2.0\examples\examples_core_c.zip\c\lapack\source


In addition, you could go through the below link for more details regarding the syntax, description, parameters etc. regarding the API.

https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2023-2/gesvd.htmlt


C convention LAPACK_DECL: mkl_lapacke.h

lapack_int LAPACKE_zgesvd( int matrix_layout, char jobu, char jobvt,

              lapack_int m, lapack_int n, lapack_complex_double* a,

              lapack_int lda, double* s, lapack_complex_double* u,

              lapack_int ldu, lapack_complex_double* vt,

              lapack_int ldvt, double* superb );


Fortran convention zgesvd declaration: mkl_lapack.h


void zgesvd( const char* jobu, const char* jobvt, const MKL_INT* m,

       const MKL_INT* n, MKL_Complex16* a, const MKL_INT* lda, double* s,

       MKL_Complex16* u, const MKL_INT* ldu, MKL_Complex16* vt,

       const MKL_INT* ldvt, MKL_Complex16* work, const MKL_INT* lwork,

       double* rwork, MKL_INT* info ) NOTHROW;


In addition to all the information mentioned above, you could go through the below link for more details on C and Fortran interfaces.

https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2023-2/c-interface-conventions-for-lapack-routines.html


Best Regards,

Shanmukh.SS


0 Kudos
LinkDeng
Beginner
1,166 Views
Hi ShanmukhS,
Thanks for your detailed reply, which answered my question very well.
Best regards,
Deng
0 Kudos
ShanmukhS_Intel
Moderator
1,127 Views

Hi LinkDeng,


It’s great to know that the issue has been resolved, in case you run into any other issues please feel free to create a new thread.


Best Regards,

Shanmukh.SS


0 Kudos
Reply