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

Calling VML from Fortran

eos_pengwern
Beginner
290 Views

Hello,

I'm trying to call some VML functions from Intel Fortran 10.1; the program seems to link all right, but when I come to any VML call I get an unhandled exception. I can't think how to begin to debug this...

Some details: I'm running IVF 10.1.0.13 with MKL 10.0.2. As I have a couple of different modules that want to make use of the VML, I have created a module within my program which consists of simply:

module

MKL

include 'mkl_vml.fi'

end module MKL

...so that any module wanting to use anyVML functions can simple say 'use MKL' in its definitions. My application compiles and links without error, though it does give three warnings along the way to the effect of :

C:Program FilesIntelMKL10.0.2.019ia32libmkl_c.lib : warning LNK4003: invalid library format; library ignored

...but it's always done this, even before I tried incorporating MKL functions into my program.

At runtime,even the most trivial call to the VML, for example

oldvmlmode=vmlgetmode()

...(where oldvmlmode has been declared as an integer) is enough to provoke the error message:

Access violation reading location 0x00000000.

The most recent entry on the call stack after the latter example is:

Numerics.dll!_mkl_vml_core_ax_vml_GetMode() + 0xd bytes

(where Numerics.dll is the name of my application, which is being called by a MATLAB program). Needless to say I'm baffled by this, and can't even think what to do next in the way of debugging it. Any suggestions would be very welcome.

0 Kudos
2 Replies
eos_pengwern
Beginner
290 Views

I got this resolved by Intel Premier Support.

It turns out that my way of invoking theVML via 'mkl_vml.fi' was in fact an attempt to link the static VML library into my custom DLL. This is unsupported behaviour, as stated in the MKL 10.0 Update 2 release notes:

"Limitations to the Vector Math Library (VML) and Vector Statistical Library (VSL) functions in Intel MKL 10.0 Update 2

  • Usage of mkl_vml.fi may produce warning about TYPE ERROR_STRUCTURE length (although in my case it didn't)
  • Static Intel MKL library cannot be linked in case of VML and/or VSL functions usage from shared library
  • In case user needs to build custom DLL that contains references to Intel MKL functions, the Intel MKL DLL Builder Tool should be used. Other DLL build techniques are not supported "

...and as stated elsewhere in this same forum:

http://software.intel.com/en-us/forums/showthread.php?t=56664#51976

I'm still not quite clear whether this is a bug, or whether it is deliberate design, but either way my question has been answered and I know what to do next...

0 Kudos
Andrey_N_Intel
Employee
290 Views

Impossibility of using static MKL library in building dynamic library is caused by incompatible mechanisms of the thread safety support in Windows for static and dynamic case. We are aware of inconveniences related to this limitation, and we work to overcome it in future versions of MKL.

For more details on limitations please refer to MSDN http://msdn2.microsoft.com/en-us/library/2s9wt68x.aspx:

If a DLL declares any nonlocal data or object as __declspec( thread ), it can cause a protection fault if dynamically loaded. After the DLL is loaded with LoadLibrary, it causes system failure whenever the code references the nonlocal __declspec( thread ) data. Because the global variable space for a thread is allocated at run time, the size of this space is based on a calculation of the requirements of the application plus the requirements of all the DLLs that are statically linked. When you use LoadLibrary, there is no way to extend this space to allow for the thread local variables declared with __declspec( thread ). Use the TLS APIs, such as TlsAlloc, in your DLL to allocate TLS if the DLL might be loaded with LoadLibrary.

0 Kudos
Reply