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

Issues using MKL on 64bits platform

trombif
Beginner
455 Views
Hi,
I compiled mkl_custom.dll with full blas and lapack functions, I am using this dll with a c# program and it works fine on win 32 platform.
Now data is gettint bigger and bigger, I am trying to use this on win64 (windows xp 64 professionnal), so i compiled the same mkl_custom for em64t and it worked fine.
Functions I a using in MKL are mainly sgelsy and sgelsd. On win32 platforms, solutions are ok. But on win64 platforms, solver gives a solution (no error, no complain) but there are some kind of artefacts... I am working on matrix size of 70 000 * 2 000, and my solution vector should have every value close to 0 (let's say between -0.5 and 0.5). most of the values are good, but some are really weird, here is an extract of the solution :
-0,006940
-0,010935
0,001523
0,007422
0,026899
0,009920
0,022661
0,018489
-0,011563
-0,012551
-0,036893
-0,017044
-0,030079
-0,006409
-0,025176
-0,005892
-0,008131
-0,000334
-0,003728
-0,016412
-0,032180
-0,012190
-0,045385
-0,028753
-0,004136
0,000983
-0,002481
0,009529
0,003901
0,003119
-448,246521
-0,003313
448,235413
-0,007623
1130,198608
-0,002215
-1130,208740
0,003512
301,904785
0,007187
-301,911835
-0,005034
-0,019108
0,001618

Has someone ever experienced such thing (this behavior holds for both sgelsy and sgelsd) ? Has anyone an idea of how to fix this ?

Thanks a lot !
0 Kudos
7 Replies
Vladimir_Koldakov__I
New Contributor III
455 Views

Hello,

Could you please provide more details?

First of all, the native function declarations (sgelsy and sgelsd) in your C# code and command line to build custom dll both on win32 and em64t platforms. It would be fine if you provide a small test case (without the arrays data, of course).

BTW, did you check em64t results on small sizes?

-Vladimir

0 Kudos
trombif
Beginner
455 Views
Hi, thanks for the reply !

Command line to build custom dll is "nmake ia32" for win32 and "nmake em64t" for em64t. But I changed some lines in makefile : ## buf_lib=bufferoverflowu.lib (has been commented)
CB_CRT=libcmt.lib (original was msvcrt.lib, but produced errors on runtime)

native function declaration is :

[DllImport("mkl_custom", EntryPoint = "SGELSY",CallingConvention =CallingConvention.Cdecl),SuppressUnmanagedCodeSecurity]
private static extern void mkl_sgelsy (ref int m,ref int n,ref int nrhs, float[] A,ref int lda, float[] B,ref int ldb, int[] JPVT0, ref float RCond, ref int rank, float[] work,ref int lwork, ref int info);


I also use SGELSY for small test cases and there is no problem. On large arrays which lead to errors, first hundreds of values are correct, but then it starts to be some king of "alternance" between widely too big and too small values (ine the example result in my first post, values are close to 0, then 448 then 0 then -448 ?! it looks like an error reading the result or something like that, I don't know)

0 Kudos
Vladimir_Koldakov__I
New Contributor III
455 Views

Hello,

Ok, the declaration is correct. I have no idea whats wrong with it.

Please give me a simple test case. As I understand, input data are

m = 70000;
n = 20000;
nrhs = 1;
lda = 70000;
ldb = 70000;
JPVT0 = ???
RCond = ???
lwork = ???

I believe you could upload test case together with compressed data, if it fails on sizes ~1000.

-Vladimir

0 Kudos
trombif
Beginner
455 Views
concerning hardware, x86 machine is a dell desktop, windows xp, 4GB ram, proc core 2 Q9400, x64 machine is a virtual machine with windows xp64, 2GB RAM and a Xeon CPU E5520...

any clue ?
0 Kudos
Vladimir_Koldakov__I
New Contributor III
455 Views

Hello,

Please see my test. It requires your files A.txt and B.txt in the same directory.

Input matrix A is printed in the form:

: [] ;

About 1400 first my results are about 10 but others in the interval [-0.5,0.5].

Please check the test and correct it if any.

Note also: There are two different value for A[0,0]:

0 ; 0 ; 1 ;

0 ; 0 ; 0 ; (At the end of the A.txt)

-Vladimir

0 Kudos
trombif
Beginner
455 Views
Hi vladimir,
I tried your test on both machines (x86 and x64), and it seems to work correctly ... I really do not understand what is going on !!!
I am actually using ILnumerics.net as wrapper for convenience (all variables are defined inside it and best routine - sgelsy,sgetrs ...- is used considering every special case), and the problem seems to come from there, as your test case works !

thank you, I'll make a short simple wrapper to use mkl myself ... !
0 Kudos
Vladimir_Koldakov__I
New Contributor III
455 Views

Hello,

I believe ILnumerics.net uses row-major matrix order: offset = column + row * NCOLUMNS, while LAPACK uses column-major order: offset = row + column * NROWS.

-Vladimir

0 Kudos
Reply