wo80 / csparse-interop

C# bindings for sparse matrix solvers.
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Problem with MKL #15

Closed epsi1on closed 2 years ago

epsi1on commented 2 years ago

hi I get exception while trying to use MKL:

pardiso = new CSparse.Double.Factorization.MKL.Pardiso(A);
pardiso.Factorize();

there is no details for exception. exception this is the matrix, and can be solved with CSParse.NET cholesky without any exception. It sais the MKL libraries throws an exception, can you please give me some hint on how can get exception details? or what is the problem with matrix or code? I'm using MKL redistributables from oneAPI, this is file version: mkl-ver

Thanks in advance

using

%%MatrixMarket matrix coordinate real general
12 12 110
1 1 102083333333.33
2 1 12152777777.778
3 1 -12152777777.778
4 1 -14583333333.333
5 1 14583333333.333
7 1 -38888888888.889
8 1 9722222222.2222
9 1 -9722222222.2222
10 1 -19444444444.444
11 1 -36458333333.333
12 1 2430555555.5556
1 2 12152777777.778
2 2 102083333333.33
3 2 -12152777777.778
4 2 9722222222.2222
5 2 -38888888888.889
6 2 -9722222222.2222
7 2 14583333333.333
8 2 -14583333333.333
10 2 -36458333333.333
11 2 -19444444444.444
12 2 2430555555.5556
1 3 -12152777777.778
2 3 -12152777777.778
3 3 102083333333.33
5 3 -14583333333.333
6 3 -14583333333.333
7 3 -14583333333.333
9 3 -14583333333.333
10 3 -2430555555.5556
11 3 -2430555555.5556
12 3 4861111111.1111
1 4 -14583333333.333
2 4 9722222222.2222
4 4 68055555555.556
5 4 -24305555555.556
6 4 -24305555555.556
10 4 -38888888888.889
11 4 14583333333.333
12 4 14583333333.333
1 5 14583333333.333
2 5 -38888888888.889
3 5 -14583333333.333
4 5 -24305555555.556
5 5 68055555555.556
6 5 24305555555.556
10 5 9722222222.2222
11 5 -14583333333.333
2 6 -9722222222.2222
3 6 -14583333333.333
4 6 -24305555555.556
5 6 24305555555.556
6 6 68055555555.556
10 6 9722222222.2222
12 6 -14583333333.333
1 7 -38888888888.889
2 7 14583333333.333
3 7 -14583333333.333
7 7 68055555555.556
8 7 -24305555555.556
9 7 24305555555.556
10 7 -14583333333.333
11 7 9722222222.2222
1 8 9722222222.2222
2 8 -14583333333.333
7 8 -24305555555.556
8 8 68055555555.556
9 8 -24305555555.556
10 8 14583333333.333
11 8 -38888888888.889
12 8 14583333333.333
1 9 -9722222222.2222
3 9 -14583333333.333
7 9 24305555555.556
8 9 -24305555555.556
9 9 68055555555.556
11 9 9722222222.2222
12 9 -14583333333.333
1 10 -19444444444.444
2 10 -36458333333.333
3 10 -2430555555.5556
4 10 -38888888888.889
5 10 9722222222.2222
6 10 9722222222.2222
7 10 -14583333333.333
8 10 14583333333.333
10 10 102083333333.33
11 10 12152777777.778
12 10 12152777777.778
1 11 -36458333333.333
2 11 -19444444444.444
3 11 -2430555555.5556
4 11 14583333333.333
5 11 -14583333333.333
7 11 9722222222.2222
8 11 -38888888888.889
9 11 9722222222.2222
10 11 12152777777.778
11 11 102083333333.33
12 11 12152777777.778
1 12 2430555555.5556
2 12 2430555555.5556
3 12 4861111111.1111
4 12 14583333333.333
6 12 -14583333333.333
8 12 14583333333.333
9 12 -14583333333.333
10 12 12152777777.778
11 12 12152777777.778
12 12 102083333333.33
wo80 commented 2 years ago

The input matrix and calling code is perfectly fine (though you might want to fiddle with the options).

I haven't updated my MKL libraries for a while, but Intel seems to have incremented the library version number (mkl_rt.1 to mkl_rt.2), so you'll have to update the name in the NativeMethods.cs files (or wait until I check-in the updated code - probably later today).

wo80 commented 2 years ago

Code updated. If this fixes the problem for you, the issue can be closed.

epsi1on commented 2 years ago

The input matrix and calling code is perfectly fine (though you might want to fiddle with the options).

I haven't updated my MKL libraries for a while, but Intel seems to have incremented the library version number (mkl_rt.1 to mkl_rt.2), so you'll have to update the name in the NativeMethods.cs files (or wait until I check-in the updated code - probably later today).

Thanks for reply.

I Already did update the "mkl_rt.1" to "mkl_rt.2". if i use mkl_rt.1 it give dll not found exception. But now the dll in found, i can also use successfully call the NativeMethods.mkl_get_version(ref MKLVersion version); which return me the right version of MKL, but above error still exists. I suspect MKL changed something in v2020, how can i debug that? I downloaded mkl from here: https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html?operatingsystem=window&distributions=webdownload&options=online Intel combined all stuff into one package named "OneApi". If use online installer, one can only select mkl runtime to be installed. How you think I can debug the code?

Thanks again

wo80 commented 2 years ago

I checked MKL version 2022.0 from nuget and all tests pass. Also tested your matrix - no exception thrown.

What's the ErrorCode / HResult of the SEHException?

wo80 commented 2 years ago

I took a look at your code. In MKL/NativeMethods.cs you have

const string MKL_DLL = @"C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\redist\intel64\mkl_rt.2.dll";

while in MKL/Pardiso/NativeMethods.cs you have

const string MKL_DLL = @"mkl_rt.2.dll";

You might want to test, if changing to an absolute path fixes the problem.

Hint: I put all the dynamic libraries (dlls) in a directory C:\shared\bin, static libraries in C:\shared\lib and include files/C headers in C:\shared\include. Add those directories to the Windows PATH variable and you don't have to worry about absolute paths anymore.

epsi1on commented 2 years ago

I did check with the updated code (latest code at the moment) still getting same exception. this is C#'s integer hresult: -2147467259 which equals to 0X80004005 or 0X05400080. I think it is a setup issue. so will close it for now. will post workaround if any found. Thanks

windows version: server 2019 hardware: Virtual Private Server (cloud vps) I suspect the virtualization be the reason.