Community
cancel
Showing results for 
Search instead for 
Did you mean: 
netphilou31
New Contributor II
74 Views

dgemm behavior difference between static and dynamic linking

Dear all,

I am currently facing a problem with the DGEMM routine from the BLAS library.

When the call to DGEMM is made in a project with static linking it works correctly but when linking with dynamic libraries it crashes my application (the application closes without any further error message). While debugging the application I found that the crash happen when the call to the DGEMM routine is made. I have got no build error messages and if I put the dgemm routine manually in the project (along with the XERBLA) the call works correctly. To be complete, I have to say that I load manually the runtime libraries (to ensure that I load the right versions) and may be I miss to load some of them.

I am using MKL version 11.1 along with Intel fortran compiler version 14.0.0.103 and the runtime libraries that I load manually are:

  • libmmd.dll
  • libifcoremdd.dll
  • libifportmd.dll
  • libiomp5md.dll
  • msvcr100d.dll
  • mkl_core.dll
  • mkl_sequential.dll
  • mkl_vml_avx.dll

Any idea about what is going on or what I am doing wrong ?

Best regards,

Phil.

 

0 Kudos
6 Replies
Zhen_Z_Intel
Employee
74 Views

Dear customer,

For your problem, I am not really understand the meaning "I load manually the runtime libraries". Is that mean you only select some dll and put them to the path of exe file? Well, we commend that you'd better put all mkl dll files into the some path of execute file. It is hard to say which dll must be used for your project, some avx/avx2/avx512 dll or def dll will be required by regarding to your machine. Thank you.

Best regards,
Fiona

netphilou31
New Contributor II
74 Views

Hi Fiona,

Thanks for your reply.

When I say "I load manually the runtime libraries" I mean I load them using the LoadLibrary function. I don't want to need to put all the MKL runtime libraries in the same folder as my application and even I want to control which dlls are loaded. I have used a viewer to identify which dlls are required (peview.exe from Process Hacker freeware) and as far as I know I have loaded all the required dlls as well as their dependencies.

The reason why I want to use the runtime libs is to reduce the size of the dlls I build because as soon as you ask to use the MKL the size of the generated dlls is absolutely huge even for a very simple numerical calculation.

Best regards,

Phil.

Zhen_Z_Intel
Employee
74 Views

Dear customer,

According to your problem, I recommend to use MKL custom dll tool (which is saved in %MKLROOT%\tools) to generate your own dll file according to your program required. You could provide a function list to generate custom dll. This dll file would only contain you required dependencies for those mkl functions, it would be the best solution for reducing size of dll files. Hope it would be useful to you.

Best regards,
Fiona

netphilou31
New Contributor II
74 Views

Dear Fiona,

Thanks for the advice.

I have quickly tried to use the tool but it's not very clear what it really does (do I need to find the libraries with the "_dll.lib" string to identify the dlls I need to load?). With the source code I have tried, it says that I need mkl_intel_s_dll.lib so I think that this is requires the mkl_intel_s.dll file which I cannot find on my computer. It's not the first time I find that I need this dll but unfortunately it doesn't seem to be installed.

Any idea?

Best regards,

Phil.

Ying_H_Intel
Employee
74 Views

Hi Phil, 

Is it possible for you upgrade the MKL? the current one is MKL 2017 update 1. 

As i understand, you may not need the mkl_intel_s.dll (for 32bit Compaq visual fortran interface).  The custom DLL build tools

was used as below I attached your one word file with screencopy. 

Please let us know if you can build one custom dll. maybe with command > nmake libia32 

Best Regards,

Ying 

Here is details about mkl_intel_s.lib.  Do you have to use the stdcall interfaces?  As i understand, if you are using  Intel fortran project direclty,  you don't need such interface too.  

If you have to use the mkl_intel_s.lib, you may need reinstall the MKL or intel fortran (using customize install to install the library)  

Using the cdecl and stdcall Interfaces

Intel MKL provides the following interfaces in its IA-32 architecture implementation:

  • stdcall
    Default Compaq Visual Fortran* (CVF) interface. Use it with the Intel® Fortran Compiler.
  • cdecl
    Default interface of the Microsoft Visual C/C++* application.

To use each of these interfaces, link with the appropriate library, as specified in the following table:

Interface

Library for Static Linking

Library for Dynamic Linking

cdecl

mkl_intel_c.lib

mkl_intel_c_dll.lib

stdcall

mkl_intel_s.lib

mkl_intel_s_dll.lib

To link with the cdecl or stdcall interface library, use appropriate calling syntax in C applications and appropriate compiler options for Fortran applications.

If you are using a C compiler, to link with the cdecl or stdcall interface library, call Intel MKL routines in your code as explained in the table below:

Interface Library

Calling Intel MKL Routines

mkl_intel_s [_dll].lib

Call a routine with the following statement:

extern __stdcall name( <prototype variable1>, <prototype variable2>, .. );

where stdcall is actually the CVF compiler default compilation, which differs from the regular stdcall compilation in the way how strings are passed to the routine. Because the default CVF format is not identical with stdcall, you must specially handle strings in the calling sequence. See how to do it in sections on interfaces in the CVF documentation.

mkl_intel_c[_dll].lib

Use the following declaration:

<type> name( <prototype variable1>, <prototype  variable2>, .. ); 
netphilou31
New Contributor II
74 Views

Hi Ying,

Thanks for your comments,

I don't want to upgrade to the latest MKL version because I prefer to upgrade both the compiler and the MKL at the same time.

Concerning my problem I use the stdcall calling convention to declare entry points of the dll I am building and I use the CVF calling convention internally.

What I am facing is a crash when I attempt to call some of the BLAS routines because it seems that the required runtime dll is not loaded but I don't know which one I have to load (using the LoadLibrary API function).

Fiona already ask me to use the custom builder to generate a dll which contains only the functions I need but I did not find it very easy to understand how it really works. I have finally included the source codes of the BLAS routines in my project to solve the problem but I think it would be better (even may be more efficient) to use the MKL dlls instead. I will may be try again in the future.

Best regards,

Phil.

Reply