LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error when using VML functions of Intel MKL v9.0 with LabVIEW 8.2.1

Hi,

 

I have created a DLL in Visual Studio 2005 which uses functions from the Intel Math Kernel Library (MKL) v9.0. The DLL works perfectly when I run it in VS 2005, but when I use it in the LabVIEW environment, I receive the error 1097 [An exception occurred within the external code called by a Call Library Function Node.].

 

It seems that the VML function vdPowX(), which raises each element of a vector

to the constant power, creates an access violation reading at location 0x00000000.

 

Unhandled exception at 0x0652d545 (OptimisationDLL_Intel.dll) in LabVIEW.exe: 0xC0000005: Access violation reading location 0x00000000.

 

When I trace it with VS2005, it seems to read at 0x00 when they check for the mode of the function (HA or LA) to see if the function will uses High Accuracy or Low Accuracy. You can reproduce the bug by simply trying to read the Mode with the Intel Function vmlGetMode().

 

I'm not sure why I only get the crash in LabVIEW and not in VS2005. The other function from the MKL that I use, daSum(), works correctly in VS2005 and LabVIEW. It doesn't have an accuracy mode since it's not in the VML family, that's probably why.

 

I've included the source code in C that causes the crash when the DLL is used in LabVIEW (Corellation_Intel.c).

 

When you attach the LabVIEW process to Visual Studio Debug mode, the execution stops at eax,dword ptr [edx+ecx*4]:

 

_mkl_vml_core_w7_vml_GetMode:

023D528C  mov         ecx,dword ptr [__tls_index (240EA0Ch)]

023D5292  mov         edx,dword ptr fs:[2Ch]

023D5299  mov         eax,dword ptr [edx+ecx*4]

 

Anyone had this kind of error or have any idea what I might have done wrong? I uses mkl_c.lib and libguide.lib libraries in the i32 of Intel MKL.

 

Thanks a lot for your help and feel free to contact me if you need more information.

 

Regards,

 

Mat

0 Kudos
Message 1 of 5
(3,669 Views)

Hi, Mat,

Could you please provide more information about your problem? If possible, could you please attach your VI? Thanks!

0 Kudos
Message 3 of 5
(3,610 Views)
Dear Mat,
 
While more details are desirable to give precise answer I guess that I know the origins of the problem. VML functions are thread-safe. VML engineers use Mircosoft TLS mechanism to maintain thread safety of VML global variables. The TLS use is different for static and dynamic case. This implies that it is impossible to use MKL static library which contains TLS stuff to build dynamic library. Indeed, your DllMain function must have VML TLS initialization/processing/finalization stuff (for details see http://msdn2.microsoft.com/en-us/library/ms686997.aspx). In case VML TLS stuff is absent in your DllMain routine you will see Access Violation on any attempt to access VML global variables.
 
VML engeneers are seeking for possible solutions/workarounds. Thus far they don't see any elegant way of solving this with existing technologies. Specifically, _mkl_vml_core_w7_vml_GetMode routine does access one of VML global variables.
 
There is a possibility to build custom VML DLL from static MKL library using MKL Builder Tool. The limitation is that the built DLL cannot contain non-MKL stuff (recalling DllMain issue, MKL Builder Tool cannot put into DllMain routine user's stuff).
 
Feel free to go to Intel MKL web forum or contact Intel Tech Support in case you have additional questions.
 
I will keep you informed.
 
Regards,
Sergey Maidanov
Intel Corporation
0 Kudos
Message 4 of 5
(3,507 Views)

For the most effective communication on MKL related issues I encourage you to go directly to one of the following links:

Other Intel MKL Support Resources http://www3.intel.com/cd/software/products/asmo-na/eng/345618.htm 

0 Kudos
Message 5 of 5
(3,499 Views)