Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Yevhen
Novice
742 Views

LAPACK DGESVD function returns different results in Intel.MKL 2019.3 and 2020.1

Jump to solution

Hello, 

I am using DGESVD function that resides in MKL for singular value decomposition computation.

Depending on the version of MKL (2019.3 and 2020.1 and more) it produces different results for the given input matrix which causes incorrect computation further.

Win10, Visual Studio 2019

int main()
{
const int M = 190;
const int N = 1;
vector<double> A(M * N);

A[0] = 14.027672183415461;
A[1] = 14.271506473085537;
A[2] = -13.729785060214454;
A[3] = 15.524688699645367;
A[4] = 15.445376113335442;
A[5] = -14.172529497344613;
A[6] = -5.7952594275545835;
A[7] = -8.1701419871944836;
A[8] = -2.3841752466646540;
A[9] = -19.803263347094571;
A[10] = 10.564733137325447;
A[11] = 13.898020550125466;
A[12] = 12.214638326445538;
A[13] = -16.201380689154576;
A[14] = 17.761747945155321;
A[15] = -14.947460698254645;
A[16] = -5.9930485055845111;
A[17] = -10.335093295624574;
A[18] = -12.019419226504624;
A[19] = 5.5044959242954974;
A[20] = 14.591021877005460;
A[21] = -14.468099494074522;
A[22] = -0.065979535384485644;
A[23] = -10.863177204174463;
A[24] = -17.974913503974676;
A[25] = 7.3548477988954346;
A[26] = -4.4859031785945263;
A[27] = 4.6534642513354356;
A[28] = 8.4441942835253485;
A[29] = 1.6973326801353323;
A[30] = -11.800251135954568;
A[31] = 3.0218253210355215;
A[32] = 2.8023521015954884;
A[33] = -0.46622980573465611;
A[34] = -10.456956370754597;
A[35] = -1.3750361327645351;
A[36] = 15.669548544415420;
A[37] = -20.068090382394530;
A[38] = -9.5402340528146397;
A[39] = 6.1431045100853225;
A[40] = 8.7318690852155214;
A[41] = -7.2271357923345931;
A[42] = 15.878826475285450;
A[43] = -7.7460188994245982;
A[44] = 8.0802273106153280;
A[45] = 5.8984453333255260;
A[46] = -14.340252252644632;
A[47] = -20.397261099474463;
A[48] = -7.8273963319045379;
A[49] = -13.559321187064597;
A[50] = -16.247039817044651;
A[51] = -13.057559628324498;
A[52] = 16.137574076135479;
A[53] = -19.286131854954647;
A[54] = 7.2416528336455031;
A[55] = -18.997882968504655;
A[56] = 0.67080271714553419;
A[57] = 6.4191788137354706;
A[58] = 16.958462428265420;
A[59] = -3.3700241977744554;
A[60] = 16.738328279705456;
A[61] = -15.053646459914489;
A[62] = 13.550732017995415;
A[63] = 7.1315089740053281;
A[64] = 13.106416775045545;
A[65] = -3.0954045641344692;
A[66] = 14.504717015695405;
A[67] = -8.4381157728846574;
A[68] = 5.7400097284353251;
A[69] = 10.637020197475522;
A[70] = -9.0674134036846681;
A[71] = 4.0124356437154347;
A[72] = -3.1482973981346731;
A[73] = 11.828897428955543;
A[74] = 10.410704379805338;
A[75] = 13.215585063135450;
A[76] = -11.945969998134615;
A[77] = -18.162408395824514;
A[78] = -6.1489618808645901;
A[79] = 12.365647089475488;
A[80] = -4.0706679815045845;
A[81] = -12.823539698904597;
A[82] = 2.5089323827753560;
A[83] = -7.4643823822445938;
A[84] = 0.38388295269533046;
A[85] = -6.8452413462446202;
A[86] = -12.530094161424586;
A[87] = -15.346752136264513;
A[88] = -5.3812197615145578;
A[89] = 11.925447003355430;
A[90] = -9.7687584717145910;
A[91] = 1.5536005304354603;
A[92] = 2.8570292152753609;
A[93] = 0.57107666045544647;
A[94] = -0.92655510671465890;
A[95] = -8.8461874964345952;
A[96] = 4.7679851468853940;
A[97] = 9.3278753607853560;
A[98] = 4.4119991498055242;
A[99] = 5.3620183775353780;
A[100] = 14.784732817705390;
A[101] = -19.056168295314592;
A[102] = 8.3988512835653637;
A[103] = 3.6719412236855078;
A[104] = 16.267481703765498;
A[105] = 10.263582418435362;
A[106] = -11.417571146044565;
A[107] = -6.5040854169344584;
A[108] = -5.1870211553346053;
A[109] = -2.2303128580845168;
A[110] = 8.2697809905355371;
A[111] = -3.5370261349046359;
A[112] = -10.635652520494659;
A[113] = -1.1150987096045810;
A[114] = 16.080802383075479;
A[115] = -17.609704147364482;
A[116] = 3.8520722664354707;
A[117] = -7.1155038881345263;
A[118] = 5.0992335982655277;
A[119] = 0.11057046029532103;
A[120] = -16.996283197734556;
A[121] = -2.8142611188445699;
A[122] = 1.3972514502254398;
A[123] = -5.6288263172245934;
A[124] = -8.0411324089345726;
A[125] = 4.3721951115353477;
A[126] = 13.281794683085536;
A[127] = 0.80339037801536506;
A[128] = 8.8392435102655327;
A[129] = -9.2784137934445425;
A[130] = 5.9920036958353649;
A[131] = 16.517919442315360;
A[132] = 15.185567550845462;
A[133] = -6.2802865990645387;
A[134] = 10.837377362575353;
A[135] = -18.837689358944544;
A[136] = -11.206747343964480;
A[137] = -6.6212829135445190;
A[138] = -14.022911338184485;
A[139] = -3.7686574583344736;
A[140] = 8.9123917797253398;
A[141] = 16.612753642085409;
A[142] = 7.8819161164153684;
A[143] = 0.25562784110547909;
A[144] = -8.6980048893544790;
A[145] = -6.9574707040644626;
A[146] = 10.117602745665408;
A[147] = 11.294667040675449;
A[148] = 1.7739188755654141;
A[149] = 7.7365305676853495;
A[150] = -0.26382349191453613;
A[151] = 11.221091171565376;
A[152] = -13.112256783064595;
A[153] = 1.2354644818553879;
A[154] = -8.9861684378445261;
A[155] = 15.004131388505357;
A[156] = 3.4457460135054134;
A[157] = 17.950488604925340;
A[158] = -8.2946981690145094;
A[159] = 18.096192080405444;
A[160] = -12.438535945684634;
A[161] = -1.7835740069745043;
A[162] = 11.457478779445410;
A[163] = 17.032609385085379;
A[164] = 17.355757650765327;
A[165] = -20.147741400644463;
A[166] = 4.1238928866753213;
A[167] = 17.527394913215403;
A[168] = 9.6365622387154417;
A[169] = -5.5453338553545564;
A[170] = 1.0512247617755293;
A[171] = -4.2047804091346279;
A[172] = -20.851080074404535;
A[173] = 3.3407996964854192;
A[174] = -10.000678896884665;
A[175] = 11.625892422995321;
A[176] = -2.1548938094945242;
A[177] = 2.4555019403853748;
A[178] = 7.6153756161154433;
A[179] = 12.636285923075320;
A[180] = -17.797677427524604;
A[181] = 6.6154713386154071;
A[182] = -18.407989765574484;
A[183] = 13.669161739755509;
A[184] = -15.145117448884548;
A[185] = -3.6193665255045744;
A[186] = -4.7283175172144638;
A[187] = 6.8457056196255053;
A[188] = 9.9167900620454930;
A[189] = 2.2885350802555422;

double* U = NULL; // U is NOT used, the U data is written to array A

auto* S = new double(1);

vector<double> VT(N * N);

const char jobu = 'O'; // the first min(m,n) columns of U (the left singular vectors) are overwritten on the array A;
const char jobVt = 'A'; // all N rows of V**T are returned in the array VT;

const int lda = M; // The leading dimension of the matrix a.
const int ldvt = N; // Right singular vector matrix

double worksize;
int info = 0;

int lwork = -1; // this triggers the required workspace calculation below

DGESVD(FORTSTRINGARG(&jobu), FORTSTRINGARG(&jobVt),
&M, &N, &A[0], &lda, &S[0], U, &lda, &VT[0], &ldvt, &worksize, &lwork, &info);

lwork = static_cast<int>(worksize);
vector<double> work(lwork); // allocate necessary workspace for subsequent SVD calculation

DGESVD(FORTSTRINGARG(&jobu), FORTSTRINGARG(&jobVt),
&M, &N, &A[0], &lda, &S[0], U, &lda, &VT[0], &ldvt, &work[0], &lwork, &info);
for (int i = 0; i < A.size(); ++i)
{
std::cout << "A[" << i << "] = " << A[i] << " \n";  /*For 2020.1 matrix contains all 0, except of first element which is 1. For 2019.3 - not 0 values*/
}

return 0;
}
0 Kudos
1 Solution
Gennady_F_Intel
Moderator
415 Views

Hello Yevhen,

The fix of the problem has been released in oneMKL v.2021.1 which available for download.



View solution in original post

14 Replies
Gennady_F_Intel
Moderator
714 Views

Do you expect to obtain bit to bit outputs?

I checked the 3 updates of the 2019 version and see the same results.

See, the outputs when this case has been linked against MKL 2019 update 0, 2, and 4 and MKL v.2020 u2 attached ( _2019u0.res _2019u2.res _2019u4.res _2020u2.res correspondingly).

Testing system: Linux, RH71, AVX2 based system, OpenMP threading, lp64 mode.



Gennady_F_Intel
Moderator
710 Views

The output results are attached.

Yevhen
Novice
697 Views

Hi Gennady,

Thank you very much for trying!

Is it possible if you try it on Win with 2020.1 version (not updated one)?

Maybe there is something wrong when running on windows.

Thank you!

Gennady_F_Intel
Moderator
684 Views

Ok, I have tried to link with mkl 2020 u2 available on win10 OS, AVX2 based system. 

The attached _2020u2_win.txt results show the same outputs as we had on linux (RH7.1) OS when linked against MKL 2019 and 2020.

Yevhen
Novice
660 Views

Good day Gennady,

Thank you for your help once again.

I found out what caused the difference in my case. I installed the latest intel.mkl update, created VS 2019 console project from scratch and tried to play with MKL settings. When I selected Use Intel MKL:  Parallel , I received correct results. While choosing Sequential gives me bunch of zeros.

While googling I found out that one other guys had similar problem and you responded to that

https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/lt-Parallel-vs-Sequencial-gt-issues-...

Though in my case I don't understand why there is a difference here and how to switch mode in production to run it in parallel.

Thank you!

 

 

Gennady_F_Intel
Moderator
647 Views

Hello,

thanks for the update, The results you obtained looks very strangely. I will check the problem and get back asap.


Gennady_F_Intel
Moderator
640 Views

yes, I reproduced the problem and we will check what's going wrong with this case. We will keep you updated on the status of the problem.

Regards,

Gennady


Yevhen
Novice
567 Views

Hello Gennady!

Is there any information regarding this issue?

Thanks

Gennady_F_Intel
Moderator
564 Views

Hello Yevhen,

the problem has been confirmed but I ( we) couldn't share which version/update of mkl would contain the fix of the problem.



Gennady_F_Intel
Moderator
567 Views

my bad, sorry, please forget the previous message. The fix of the problem is planning to be available for the next ( nearest) release of MKL.

Regards,

Gennady


Yevhen
Novice
559 Views

Good news! Thanks!

Gennady_F_Intel
Moderator
416 Views

Hello Yevhen,

The fix of the problem has been released in oneMKL v.2021.1 which available for download.



View solution in original post

Yevhen
Novice
330 Views

Amazing news!

I can confirm it works on our side.

Thank you very much!

Tags (1)
Gennady_F_Intel
Moderator
298 Views

Yevhen, thanks for the update.

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only. 



Reply