Showing results for 
Search instead for 
Did you mean: 

Calling 'pbtrf' and 'pbtrs' directly from a C# .Net Core library

I'm currently porting a small Fortran FE solver to C#. The solver uses MKL, and I'm trying to get the best of both worlds by calling the MKL functions in question directly from C#.
According to Intels documentation, this can be done by using the DllImport statement in C# and calling the relevant function in mkl_rt.dll directly. This Intel tutorial gives a short description of how this can be done, and even provides some C# code examples.

The examples provided compile on my computer, What I want to do is basically exactly the same, only targeting the functions 'pbtrf' and 'pbtrs'. But it seems these functions are not exposed from mkl_rt.dll. Using Dependency Walker, I looked into mkl_rt.dll and found that only the F77-versions are available. So I tried setting up a function call using 'dpbtrf' and 'dpbtrs' instead. These require several more arguments than the F95-versions.

About the case:

My setup is in the attached .cs file (also shown in below image). Some input is hardcoded for testing purposes. The actual case is not provided, but it is a simple static FE problem with a stiffness matrix and a load vector. Mathematically, the stiffness matrix is a band matrix of size n x n. In the code, it is written in compact form as a matrix of size (nSuperDiagonals + 1) x n, that is 4 x n. Only one right hand side is used, i.e. the load vector of length n.

The call does not throw any error messages; I get info=1 in return (not 0) and the stiffness matrix is never factorized.

I know that this specific case will run when the whole shebang is coded in Fortran on the same computer.

.Any thoughts on what the issue could be?

LaPack in CSharp.png


0 Kudos
0 Replies