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

Problems calling mkl_rt.dll in C# / program crashes

Philipp_W_
Beginner
866 Views

Hi,

we are using Intel MKL 11.02. since a few weeks and a first C++ example calling the includes works fine. But we have some trouble to import the mkl_rt.dll in C#. When calling the dll the program crashes without any notice. We have tried it for some functions (MKL_Set_Num_Threads, VDDIV, VDADD, DASUM, MKL_Get_Max_Threads) and always get the same result. Additionally we tested 32bit and 64bit versions of mkl_rt.dll and also the Intel C#-example "vddiv" - and result every time in a uncommented program stop.

namespace MKL_Test
public unsafe class MKL_Wrapper

[DllImport("mkl_rt.dll", CallingConvention = CallingConvention.Cdecl, ExactSpelling=true, SetLastError = false, EntryPoint = "MKL_Get_Max_Threads")]
public static extern int Get_Max_Threads();

The function is then called by:  int anzahl = MKL_Test.MKL_Wrapper.Get_Max_Threads();

---
Are there any further issues we don't have taken into account?
Our test files are attached.

Many thanks in advance,
Philipp Wollmann

0 Kudos
5 Replies
SergeyKostrov
Valued Contributor II
866 Views
>>...The function is then called by: int anzahl = MKL_Test.MKL_Wrapper.Get_Max_Threads(); I'd like to confirm that a pure C/C++ test with the function MKL_Get_Max_Threads works. Is that correct?
0 Kudos
Philipp_W_
Beginner
866 Views

Yes, a C++ test using "mkl.h" and "MKL_Get_Max_Threads();" works fine.
For the dll import in C# we used the file from the redistribution folder.

0 Kudos
SergeyKostrov
Valued Contributor II
866 Views
>>...When calling the dll the program crashes without any notice... Could you verify a list of loaded DLLs for C/C++ test and C# test? Here are instructions: - Compile debug versions of both applications - Start Debugging ( F10 ) for C/C++ application, do something and exit - Take a look at Output Window of Visual Studio for a complete list of loaded DLLs - Start Debugging ( F10 ) for C# application, do something and exit - Take a look at Output Window of Visual Studio for a complete list of loaded DLLs - Find all loaded Intel DLLs for both cases and compare ( take into account that full paths to DLLs are displayed ) Please posts results of your investigation.
0 Kudos
SergeyKostrov
Valued Contributor II
866 Views
Another verification for C# application: - Verify that a 32-bit C# application uses 32-bit Intel DLLs and - Verify that a 64-bit C# application uses 64-bit Intel DLLs
0 Kudos
Philipp_W_
Beginner
866 Views

Hi Sergey,

thanks for your advice. I checked the mentioned tasks and found, that "intel_mkl_thread.dll" was missed in the C# project - now it runs. Interestingly this dll was not indicated by an error prompt, other missed dll files were mentioned by an error message.

Many thanks for the solution!

Best regards,
Philipp

0 Kudos
Reply