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

VML - user DLL

vikrantca
Beginner
1,298 Views
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
0 Kudos
25 Replies
Andrey_G_Intel2
Employee
1,073 Views
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
0 Kudos
vikrantca
Beginner
1,073 Views
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
0 Kudos
Andrey_G_Intel2
Employee
1,073 Views

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.

0 Kudos
vikrantca
Beginner
1,073 Views
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
0 Kudos
Andrey_G_Intel2
Employee
1,073 Views

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?

0 Kudos
vikrantca
Beginner
1,073 Views
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


0 Kudos
Andrey_G_Intel2
Employee
1,073 Views
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.
0 Kudos
vikrantca
Beginner
1,073 Views
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
0 Kudos
Andrey_G_Intel2
Employee
1,073 Views
I can`t give advice to you right now. Some consultations with solvers and lapack developers needed.
0 Kudos
vikrantca
Beginner
1,073 Views

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

0 Kudos
Andrey_G_Intel2
Employee
1,073 Views
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.
0 Kudos
rockballad
Beginner
1,073 Views
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.
0 Kudos
Andrey_G_Intel2
Employee
1,073 Views

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.

0 Kudos
rockballad
Beginner
1,073 Views
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!


0 Kudos
Andrey_G_Intel2
Employee
1,073 Views

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.)?

0 Kudos
rockballad
Beginner
1,073 Views
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!

0 Kudos
Andrey_G_Intel2
Employee
1,073 Views
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?
0 Kudos
rockballad
Beginner
1,073 Views
Yes, I do. But I'm sorry, I don't know I'm using CDECL. Please tell me?
0 Kudos
Andrey_G_Intel2
Employee
1,073 Views

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)

0 Kudos
rockballad
Beginner
957 Views
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!
0 Kudos
Reply