VML - user DLL

VML - user DLL

Hello,

Previously, there was an issue with the VML - i.e. not being able to build user/custom dll with VML with static linking.
Is this issue still present in 9.1 ?

I am trying to build a dll which requires the optimization solver and the VML. Turns out, the optimization solver requires static linking, but then, ALL my routines that call VML fail.
If I comment out the optimization solver calls and link dynamically, the VML calls work (the optimization calls dont work, ofcourse).

Any help is appreciated ?
Thank you.
vikrantca

26 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I think, you are trying to create your own DLL directly from static libraries. Am I right? It`s incorrect way for VML&VSL functions. If you want to create your own DLL - use custom DLL builder feature

Yes, you are right.
But, the optimization solver (which I also need in my custom dll) does not work with the dynamic linking, since there is no DLL version of the solver. Therein lies the problem.

-VA

Custom dll builder tool is designed for helping to resolve the same tasks as your task - produce dll library from statical libraries. You need just to put list of needed functionsto the tool (for detailed description of custom dll builder see MKL manual).

You can`t produce your own DLL directly from statical libraries in case of VML&VSL because we have Threading Safe mechanism and it can`t be implemented in samemanner for statical and dynamical librariesin windows.

I think I am misinterpreting what you said. Let me know give some more details -

I have a VC++ DLL (VS 2005) project and I am linking it to mkl_c_dll.lib and libguide40.lib.
When I call the optimization solver, I get these linker errors, so I link to the following:
mkl_c.lib, libguide.lib and mkl_solver.lib.
After this step, I get runtime errors on all VML calls in my code, due to the TLS allocation issue.

Now, as per your solutions - I should be doing the following:

Build a custom dll with all the optimization solver calls into some dll as optsol.dll. And then dynamically link my VC++ dll to the optsol.lib file.
Is my understanding correct ?

Thanks alot for your advice.
-VA

Hmmm... Looks like I incorrectly understood your problem. To fix it I need answers at two folloving questions:

1) What is result of your project: Dll, Exe, Lib or something else?

2) Can you send text of linker error message then you trying to build your project with mkl_c_dll.lib and libguide40.lib?

Below are the answers:
1. The result of my project is a DLL that is used by a couple of exe's.
2. The error messages are:

******************

1>mkl_solver.lib(d_tr_trialstep_nlsqp_withMP.obj)
: error LNK2019: unresolved external symbol _mkl_lapack_dpotrs
referenced in function _dmintr_ls_pd_withmp
1>mkl_solver.lib(d_tr_trialstep_nlsqp_withoutMP.obj) : error LNK2001: unresolved external symbol _mkl_lapack_dpotrs
1>mkl_solver.lib(d_tr_trialstep_bc_subP_withMP.obj) : error LNK2001: unresolved external symbol _mkl_lapack_dpotrs
1>mkl_solver.lib(d_tr_trialstep_bc_subP_withoutMP.obj) : error LNK2001: unresolved external symbol _mkl_lapack_dpotrs
1>mkl_solver.lib(d_tr_trialstep_nlsqp_withMP.obj)
: error LNK2019: unresolved external symbol _mkl_lapack_dtrtrs
referenced in function _dmintr_ls_pd_withmp
1>mkl_solver.lib(d_tr_trialstep_nlsqp_withoutMP.obj) : error LNK2001: unresolved external symbol _mkl_lapack_dtrtrs
1>mkl_solver.lib(d_tr_trialstep_bc_subP_withMP.obj) : error LNK2001: unresolved external symbol _mkl_lapack_dtrtrs
1>mkl_solver.lib(d_tr_trialstep_bc_subP_withoutMP.obj) : error LNK2001: unresolved external symbol _mkl_lapack_dtrtrs
1>mkl_solver.lib(d_tr_trialstep_utils.obj)
: error LNK2019: unresolved external symbol _mkl_blas_dasum referenced
in function _dgrgbound

**************************

All of these go away, once I link to the mkl_c.lib and libguide.lib.

Just to add - I have raised this as an issue , asking for the DLL version of the solver, but havent received anything yet.

Thank you.

-VA

If result of your project is DLL - you shoul link mkl_c_dll.lib and libguide40.lib against mkl_c.lib and libguide.lib. Only in this case your DLL will work properly. Add lapacklibrary to link string and problem with unresolved symbols will disappear.

Thanks for the prompt reply - agilev.
Now the errors have reduced to the following:

1>mkl_solver.lib(d_tr_trialstep_utils.obj) : error LNK2019: unresolved external symbol _mkl_blas_dasum referenced in function _dgrgbound
1>mkl_lapack.lib(dpotrs.obj) : error LNK2019: unresolved external symbol _mkl_serv_lsame referenced in function _mkl_lapack_dpotrs
1>mkl_lapack.lib(dtrtrs.obj) : error LNK2001: unresolved external symbol _mkl_serv_lsame

Thanks again for your patience.

-VA

I can`t give advice to you right now. Some consultations with solvers and lapack developers needed.

I linked with mkl_ia32.lib and the remaining errors went away.

Interestingly, the documentation does not mention linking to mkl_ia32.lib anywhere.

-VA

In on of threads at this forum you already receive answer about unavailability of solvers in dynamical variant of MKL libraries because someperformance reasons exists. Then you linking mkl_ia32.lib you are use statical MKL libraries.

Thanks you both, your discussion make me understand more about MKL. Andrey, I still dealing with the problem. As you said at http://software.intel.com/en-us/forums/showthread.php?t=55340#47656, in anyway, we should use lib files (in ia32lib). So what's the purpose of the DLL files (in ia32dll) ?

I still need DLLs to use in Borland, namely VML (trigonometry math). I don't know how to use MKL DLLs. And as you said, we should use LIB files to let it detect the proper DLL used for my own CPU. So I concentrate on LIBs. I intend to wrap that LIB file into DLLs and then use DLL for Borland (using IMPLIB). But what's the right LIB I should use, mkl_c.lib OR mkl_s_dll.lib ? And other LIB? What's necessary for using VML?

After reading this thread, looks like I have to use custom dll builder (MKL's tool) to make DLLs (rather than wrap LIB into DLL). Is it right? But the simple command line hereafter doesn't work: nmake ia32 interface=stdcall
I use stdcall in other to have it work with Borland.
But I just get the error:

user_def_file.def : warning LNK4022: cannot find unique match for symbol "DDOT"
user_def_file.def : warning LNK4002: _DDOT defined in ....ia32libmkl_s.lib
user_def_file.def : warning LNK4002: _DDOT@20 defined in ....ia32libmkl_s.lib
user_def_file.def : warning LNK4022: cannot find unique match for symbol "DGEMM"
user_def_file.def : warning LNK4002: _DGEMM defined in ....ia32libmkl_s.lib
user_def_file.def : warning LNK4002: _DGEMM@60 defined in ....ia32libmkl_s.lib
user_def_file.def : warning LNK4022: cannot find unique match for symbol "DGETRF"
user_def_file.def : warning LNK4002: _DGETRF defined in ....ia32libmkl_s.lib
user_def_file.def : warning LNK4002: _DGETRF@24 defined in ....ia32libmkl_s.lib
user_def_file.def : error LNK2001: unresolved external symbol cblas_dgemmmkl_custom.lib : fatal error LNK1120: 1 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file
NMAKE : fatal error U1077: 'link' : return code '0x475'
Stop.

I may have ask you too much, but I'm so confused, if you can, please help me. Thanks very much!

Look forward to your answer.

rockballad,

yes, you can use "custom dll builder tool" for your needs. By using this tool you can create dll which you can use by LoadDll function. You also can create import library for this dll.

The usage model of "custom dll builder tool" is pretty simple. You should specify two things: target architecture (ia32/em64t/ipf) and file with list of functions which you plan to use. For example: if you want to VML functions only and plan to use them at IA32 architecture, run "custom dll builder tool"usingfollowing command line

nmake ia32 interface=stdcall export=vml_vsl_stdcall_list

vml_vsl_stdcall_list - contains list of all VML&VSL functions with stdcall interface.

As result, you will receive mkl_custom.dll. You can use this library for your needs.

Great! Many thanks to you! My command didn't work because I used "export=functions_list" as exampled in userguild.pdf. Now I get the DLL for VML, Using tdump I can see many trigonometry function here with the undercore sign.

---
Exports from mkl_custom.dll
663 exported name(s), 663 export addresse(s). Ordinal base is 1.
Sorted by Name:
RVA Ord. Hint Name
-------- ---- ---- ----
000049C4 1 0000 _VCACOS@12
00005228 2 0001 _VCACOSH@12
00005A94 3 0002 _VCASIN@12
000062F8 4 0003 _VCASINH@12
00006B64 5 0004 _VCATAN@12
000073C8 6 0005 _VCATANH@12
00007C34 7 0006 _VCCOS@12
00008490 8 0007 _VCCOSH@12
00008CEC 9 0008 _VCEXP@12
00009548 10 0009 _VCLN@12
00009DA4 11 000A _VCLOG10@12
0000A64C 12 000B _VCPOW@16
0000AF60 13 000C _VCPOWX@16
0000B804 14 000D _VCSIN@12
0000C068 15 000E _VCSINH@12
0000C8D4 16 000F _VCSQRT@12
0000D130 17 0010 _VCTAN@12
0000D994 18 0011 _VCTANH@12
0000E208 19 0012 _VDACOS@12
0000EA7C 20 0013 _VDACOSH@12
0000F2F0 21 0014 _VDASIN@12
...

But I see warnings of dupicated functions in that DLL. Do you know the reason why? And when I compile your vssin.c file in Borland, it's still the error
[Linker Error] Error: Unresolved external '_vsSin' referenced from ...

Looks strange. All functions are already prefixed by "_" as expected. So what's wrong you can figure out?

Thanks for your help!

As I can see, you receive needed MKL dll. Can you explain step-by-step your next actions (what are you doing with this dll, how are you include dll to your project and ect.)?

Yes. I need to use VML in Borland C++ Builder. I usually test with VS2005 first, and import library to use in BCB (using implib). To be simply, I ask for your help to use this custom dll in VS2005.

Here is my step-by-step action in using VS2005.

1/ Create a console application

2/ Copy func_interv.h, mkl_custom.lib, mkl_custom.dll into project folder

3/ Alt+F7 to get Project Setting.

* C/C++ branch:
[Additional Include Dir:] c:Program FilesIntelMKL9.1.027include
* Linker:
[Additional Lib Dir:] c:Program FilesIntelMKL9.1.027ia32lib
and [Additional Dependencies:] mkl_custom.lib

The main function is the same as vssin.c in MKL example.

Everything seems OK. but there's a error LNK2019: unresolved external symbol _vsSin referenced in function _wmain

It's Friday at my time, I hope to get your help to solve it before this weekend. Could you please check it for me? Thanks very much!

Do you remember what at previuos step you are created mkl_custom.lib with with functions with STDCALL calling conventions? Why you are using CDECL in your current project?

Yes, I do. But I'm sorry, I don't know I'm using CDECL. Please tell me?

From one side - you are built and tryed to use STDCALL library. From another site - all function in includemkl_vml_functions.h declared as CDECL. Some conflict have place here. I see two ways to resolve this problem:

1) define macro MKL_VML_STDCALL (and use STDCALL library). after that, all function (in includemkl_vml_functions.h)will be declared as STDCALL.

2) build and use CDECL library (nmake ia32 interface=cdecl export=vml_vsl_cdecl_list)

Oh, I see! Thanks for your help! The second way, I have tried, but got no success. I'll report to you as soon as I have done the first way.

Thanks again!

Oops, I don't have the source code, how can I modify the header file and recompile the library? Fortunately I have done successfully with the second way in VS2005, but the DLL is in CDECL calling convention. I still need the STDCALL version, dear Andrey.

project -> properties -> c/c++ -> preprocessor

put MKL_VML_STDCALL to the "preprocessor definitions" field.

Thanks a lot! Very simple, right? I was so confused :-P

Thank you so much! I'll return with the Borland VML HowTo if I succeed!

Have a nice weekend!

OK. I found out the way to use MKL in Borland, using DLLs. Here's the progress:

  1. Building the custom DLL using MKL's tool. Run this command line in the directory <%MKL_ROOT%>9.1.027 oolsuilder:
    nmakeia32interface=cdeclname=mkl_vmlexport=vml_vsl_cdecl_listYou'll get a file named mkl_vml.dll - This file will be used at run-time.

  2. Using IMPLIB utility as usual to import the lib for using at compile-time:
    IMPLIB-a-f-cmkl_vml.libmkl_vml.dll
  3. Create a console application in Borland to test. Save this project to a specific directory.
  4. The main function can be copied as <%MKL_ROOT%>9.1.027examplesvmlcsourcevdsin.c
    Notice, vssin using float array, vdsin using double, vzsin and vcsin using MKL_Complex type.
  5. Alt+F7
    to access Project Setting. [C/C++ Compiler] -> [Path and defines]
    add the include dir to [Include search path], e.g. c:Program
    FilesIntelMKL9.1.027include

  6. Compile app now to let
    it create the output folder. Copy mkl_vml.dll to that output folder,
    copy mkl_vml.lib to the project folder.

  7. Right click at the project, [Add...] to add this lib file
  8. Run the project to test

I'd like to thank Andery very much for your help! Hope this quick HowTo will help someone who had the same problem.

Have a nice day!

Thank you for HowTo! :-)

Leave a Comment

Please sign in to add a comment. Not a member? Join today