Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

Possible issue in MKL LAPACKE interface when using LAPACK_ROW_MAJOR

$
0
0

MKL provided by Intel parallel studio xe 2019.3.

The minimal reproducing code is below:

#include <stdlib.h>
#include <stdio.h>
#include "mkl_lapacke.h"

#define N 2

int main(){
double m[N];
MKL_INT n1=N, n2=N;
MKL_INT info;
double a[N*N] = {0, 1,
                 1, 0};
info = LAPACKE_dsyevd(LAPACK_ROW_MAJOR, 'V','U', n1, a, n2, m);
printf("the eigenvalue is: %f,%f\n", m[0],m[1]);
printf("the first eigenvector is: %f,%f\n",a[0],a[2]);
printf("the second eigenvector is: %f,%f\n",a[1],a[3]);
return 0;
}

The returned eigenvectors is somehow wrong when LAPACK_ROW_MAJOR is specified, however, everything is fine when changing to LAPACK_COL_MAJOR.

The stdout with export MKL_VERBOSE=1 is shown below:

1. COL_MAJOR (correct results)

MKL_VERBOSE Intel(R) MKL 2019.0 Update 3 Product build 20190125 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) enabled processors, Lnx 2.20GHz lp64 intel_thread
MKL_VERBOSE DSYEVD(V,U,2,0x7ffee9463680,2,0x7ffee94636a0,0x7ffee9463620,-1,0x7ffee9463628,-1,0) 27.85ms CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:28
MKL_VERBOSE DSYEVD(V,U,2,0x7ffee9463680,2,0x7ffee94636a0,0x22ce000,21,0x22cdf00,13,0) 243.59us CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:28
the eigenvalue is: -1.000000,1.000000
the first eigenvector is: -0.707107,0.707107
the second eigenvector is: 0.707107,0.707107

2. ROW_MAJOR (wrong results)

MKL_VERBOSE Intel(R) MKL 2019.0 Update 3 Product build 20190125 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) enabled processors, Lnx 2.20GHz lp64 intel_thread
MKL_VERBOSE DSYEVD(V,U,2,0x7ffd6a6a3000,2,0x7ffd6a6a3020,0x7ffd6a6a2fa0,-1,0x7ffd6a6a2fa8,-1,0) 27.70ms CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:28
MKL_VERBOSE DSYEVD(V,U,2,0xd26100,2,0x7ffd6a6a3020,0xd26000,21,0xd25f00,13,0) 247.73us CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:28
the eigenvalue is: -1.000000,1.000000
the first eigenvector is: -0.707107,1.000000
the second eigenvector is: 0.707107,0.707107

Pay attention to the difference on the first eigenvector.


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>