Community
cancel
Showing results for 
Search instead for 
Did you mean: 
gabriel_i_r
Beginner
53 Views

VML crash when calling custom DLL from multiple threads on Windows 7 x64

Hello,

Im encountering crashes when calling MKL Vector Math Library (VML) functions in a custom DLL from a multithreaded C# program on 64-bit Windows 7.

The crash occurs when calling vsAdd, but not when calling cblas_saxpy, and only occurs when calling into a custom DLL (built using the makefile in the MKL builder directory). Calling mkl_rt.dll works ok. Using more than 1 thread is necessary to cause the crash, and it is not entirely deterministic.

I have put together a small, self-contained test-case to demonstrate the problem: In the attached ZIP archive, youll find two Windows batch files and a C# source file. Execute the batch files to build the custom DLL and 4 different programs, each for a slight variation of the test case (you may need to adjust the paths in the batch files and in the C# source file: I'm using MKL 10.3 update 6 installed in the default directory on Win 7 x64).

Run each of the four generated test-*.exe programs. On my system, 3 of the 4 execute and quit cleanly without errors. However test-custom-vml.exe will crash about 75% of the time. As you can see by inspecting the C# source and the batch files, the only difference among the 4 is in which MKL function is called (vsAdd vs cblas_saxpy) and whether the function resides in mkl_rt.dll or mkl_custom.dll

I've reproduced this problem on a Xeon E5335 system and on a Core i7 970 system, though the crash probability on the Core i7 system is somewhat lower than the Xeon (you'll have to try running it several times). 32-bit DLLs (built with nmake libia32) appear to have the same problem as well. Haven't tried other operating systems.

I'm not experienced with debugging non-managed code, but as best I can tell the problem occurs as the threads are shutting down. Debugging test-custom-vml.exe in Visual Studio 2010 brings up a message about heap corruption.

Any help on how I can get the VML to work from the custom DLL would be appreciated. I know the MKL is supposed to be thread-safe, and I'm even calling MKL_Set_Num_Threads(1) at the top of my program, so this crash is confusing.

Thank you in advance for your time.

Regards,

Gabriel

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
53 Views

Gabriel, thanks for the issue - we will check how it works on our side and will back soon.
Gennady_F_Intel
Moderator
53 Views

The problem has been reproduced on our side to.The root cause investigation of the problem is ongoing.
Reply