Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Employee
265 Views

Linking Intel MKL is easy

[bash]icl prog.c /Qmkl[/bash]

or,

[bash]ifort prog.f /Qmkl[/bash]

That's the easiest way if you are using one of the latest Intel compilers on Windows*. There are similar compiler options for Linux* and Mac OS* X as well.

Another easy way is to use our new dynamic linking model which requires a link to just one library. Add mkl_rt.lib to your Windows* link line or add -lmkl_rt to your Linux* or Mac OS* X link line.

These new options willwork for the cases usedby most users. Those who use less common interfaces or threading models may still want to visit the Link Line Advisor to find the right set of libraries.
 

0 Kudos
29 Replies
Highlighted
Employee
4 Views

Here is an article about custom static linkage for those people who cannot employ the the begin-group / end-group linker options e.g., due to a legacy build system.

0 Kudos
Highlighted
Beginner
4 Views

mecej4 wrote:

Quote:

arantesb wrote:I can't understand way -lmkl_lapack95 is needed after -mkl; that worked fine for a simple gemm test.

The Fortran-95 routines are wrappers around the Fortran-77 routines. As the MKL documentation states, the former have shorter argument lists, may have optional arguments, and a single generic procedure name covers arguments of various real and complex types. Some glue code is needed to decode the input arguments, fill in default values of optional arguments that are not present, allocate work arrays as needed, select and call the Fortran-77 routines that are appropriate for the argument types, and map the results back to the Fortran-95 arguments. This glue code is present in the mkl_lapack95 and mkl_blas95 libraries. If your code makes any calls to routines in these libraries, you must explicitly specify them in the linking command.

I am using MKL 10.3 in Visual Studio 2010 with Composer XE 2011. I am able to use the F77 interfaces to lapack, but could not figure out how to use the F95 interfaces. What shoould I do in Visual Studio so the linker finds the F95 interface?

0 Kudos
Highlighted
Black Belt
4 Views

In order to use the Lapack95 library, you need to

  1. Add appropriate INCLUDE and/or USE statements in your source code,
  2. Add the directory containing the Lapack95 module (.MOD) files to the compiler's include path list, or to the INCLUDE environment variable
  3. Add the directory containing the Lapack95 libraries to the linker's search path, or to the LIB environment variable.
  4. Add the Lapack95 libraries to the list of additional libraries to search at link time.
0 Kudos
Highlighted
Beginner
4 Views

I am using Visual Studio 2008, C++.  I have followed the instructions to set environment variables.  When I use the Link Advisor

cl -D"%MKLROOT%\include" dgemm_example.cpp mkl_intel_ilp64.lib mkl_core.lib mkl_sequential.lib

I receive the following link errors:

dgemm_example.obj : error LNK2019: unresolved external symbol _MKL_free referenced in function _main
dgemm_example.obj : error LNK2019: unresolved external symbol _MKL_malloc referenced in function _main

 

0 Kudos
Highlighted
Employee
4 Views

Hi Emmet, 

I guess, the possible problem is that cl.exe is for 32bit application and mkl library is for 64bit application.  You can check it by  enter command > cl

If it show something like  Microsoft (R) 32-bit C/C++ Optimizing

Then you can try the command: 

C:\MKL_issue>"C:\Program Files (x86)\Intel\Composer XE 2013_SP1\mkl\bin\mklvars.bat" ia32

>cl dgemm_example.cpp mkl_intel_c.lib mkl_core.lib mkl_sequential.lib

Best Regards,

Ying 

P.S : Some on-line article about the IA32 architecture and 64 architecture. Please see

1. http://software.intel.com/en-us/articles/how-to-build-mkl-application-in-intel-visual-fotran-msvc200...  

2.  http://software.intel.com/en-us/articles/ia-32-intelr-64-ia-64-architecture-mean/

3.  http://software.intel.com/en-us/forums/showthread.php?t=105918

 

0 Kudos
Highlighted
Black Belt
4 Views

Emmett B: Try using [cpp]cl -I"%MKLROOT%\include"[/cpp] instead of [cpp]cl -D"%MKLROOT%\include" [/cpp]In other words, specify the directory for additional include files, rather than define a symbol that is never invoked in the program source.

0 Kudos
Highlighted
Beginner
4 Views

I wrote a Console App in VS 2010, Fortran XE, Win32, Debug. The MKL are installed together w/XE. 

In VS2010 I set Project> Properties> Fortran> Libraries> Use MKL> yes.

I get: 

Error    1     error LNK2019: unresolved external symbol _SBGVX referenced in function _MAIN__    Console1.obj    

What am I missing?

 

 

0 Kudos
Highlighted
Employee
4 Views

Hello Ever,

What Fortran XE version are you installed?  Not sure if there is integration issue.  I checked the latest Visual Fortran Composer XE 2013 update 2 and VS2010.  It seems work fine.

The error itself hints the MKL library is not linked in your program or in wrong path.

You can fix the problem by set the library and library path manually, like the step 3.2 and 3.3.

http://software.intel.com/en-us/articles/how-to-build-mkl-application-in-intel-visual-fotran-msvc200...

and check why the Use MKL  Parallel /Qmkl:Parallel ( you mentioned it is Use MKL > yes, could you please attach one screenshot to us?)  as my reply in http://software.intel.com/en-us/forums/topic/506620

Best Regards,

Ying

0 Kudos
Highlighted
Black Belt
4 Views

Ever B.: The symbol _SBGVX is not present in the MKL_Lapack95 library, because that is only an F95 interface name. If you apply Dumpbin to the .OBJ file that the compiler produced, you will find that the "specific" symbol name is _DSBGVX_MKL95 (this is for Windows-32; the name decoration varies with the target architecture and the OS).

When the documentation names a subroutine or function with "Syntax ... Fortran 95", especially when that subroutine or function takes optional arguments, take that as a hint that an implicit interface will not be sufficient. The necessary explicit interface may be provided conveniently by adding a USE statement. In this particular case, use mkl95_lapack is what you need. Please refer to my response to your other post, MKL LAPACK SBGVX example.

0 Kudos
Highlighted
Beginner
4 Views

The problem can be solved like this: The heading of the program unit should contain this

    include 'lapack.f90'    ! interfaces for .f90, .f95 are here
    program EigenVal
    use mkl95_lapack        ! variables needed are defined here
    implicit none
    ! Variables
    ! http://software.intel.com/sites/products/documentation/hpc/mkl/mklman/index.htm#GUID-659297EE-D35B-4... 

Band storage is defined here:

    !copy to band form using 
    !http://software.intel.com/sites/products/documentation/hpc/mkl/mklman/index.htm#GUID-659297EE-D35B-428C-ABBE-1A7EBE2B0F6E.htm#GUID-659297EE-D35B-428C-ABBE-1A7EBE2B0F6E
    KGB = 0 !band storage
    KMB = 0 !band storage
    do i=1,N
        do j=1,N
            if (i.ge.max(1,j-ku).and.i.le.min(N,j+kl)) KGB(ku+1+i-j,j) = KG(i,j)    !from full to band storage
            if (i.ge.max(1,j-ku).and.i.le.min(N,j+kl)) KMB(ku+1+i-j,j) = KM(i,j)    !from full to band storage
        enddo
    enddo

Then, use the F95 calling syntax:

    call sbgvx(KGB, KMB, w)     ! .f95 syntax calling. Optional arguments can be added as needed. 

Thank you all for your help !

0 Kudos