Kuravi H
Kuravi H

Reputation: 111

Performance of MKL `dgesvd` vs MKL `LAPACKE_dgesvd`?

dgesvd seems to be a LAPACKE_dgesvd with the layout LAPACK_COL_MAJOR, but looking at the examples for dgesvd and LAPACKE_dgesvd it seems there is an extra step in the dgesvd example where an optimal workspace is queried and allocated.

  1. Is it correct to assume that this step is to figure out if the input matrix is COL_MAJOR or ROW_MAJOR?

  2. Is it correct to assume that once the optimal workspace is figured out, 'dgesvd' internally calls LAPACKE_dgesvd with the appropriate layout?

  3. If I already know the matrix layout to be COL_MAJOR is using LAPACKE_dgesvd better (faster/less expensive) than dgesvd?

Upvotes: 1

Views: 607

Answers (1)

nomem
nomem

Reputation: 1588

We have two functions here which refer to two different interfaces:

i.  dgesvd         : calls fortran interface
ii. LAPACKE_dgesvd : calls C interface

For detail see this.

  1. No it is not correct. As you will notice in the first call to dgesvd the value of lwork is set to -1 which as documented here is used for just calculating the size of lwork. So if you already know about the size of lwork you don't need to call it twice. Input matrix has to be LAPACK_COL_MAJOR for dgesvd as this is default for fortran. Also there is no way to calculate if the matrix is row major or column major.
  2. No it's not true. dgesvd is the fortran interface which was implemented first.
  3. This would depend on the compiler optimization. If the matrix is small it probably wouldn't matter. For me if its column major I would use fortran interface.

For matrix layout infotmation see this. Here is the technical paper for C interface

Upvotes: 1

Related Questions