Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

How to Use LAPACK95

$
0
0

Intel® Math Kernal Library (Intel MKL) provide the Fortran 95 interface of Linear Algebra PACKage (LAPACK) routines, which uses simplified routine calls with shorter argument lists, comparing with the respective generic (FORTRAN 77) interface to LAPACK computational and driver routines. The pre-compiled LAPACK95/BLAS95 library and lapack95/blas95 modules by Intel fotran Compiler are including Intel MKL package. Users are able to use LAPACK95 routines in program directly. The following provides the information for how to usinge Lapack95 routines:

We take the Microsoft* Visual Studio* 2012 and Intel® Visual Fortran Compiler, 64bit as example

1. Make sure the LAPACK95/BLAS95 modules and libraries were availiable in your develop environment.

By default,the pre-compiled modules: blas95.mod, f95_precision.mod, lapack96.mod mkl_service.mod are in the directory: C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.1.146\windows\mkl\include\intel64\lp64

The lapack95/blas95 libraries: mkl_lapack95_lp64.lib (mkl_lapack95.lib 32bit) and mkl_lapack95_ilp64.lib are in

C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.1.146\windows\mkl\lib\intel64_win

2. Prepare the lapack95 program.

For example, one from the forum thread the sample code

Program main
    USE LAPACK95, ONLY: GESV
    integer, parameter :: n = 4
    real(8) :: b(n) = [-1.,-0.5,0.5,1.], x(n)
    real(8) :: A(n,n)
    do i = 1, n
     A(i,1:i-1) = -1d0
     A(i,i+1:n) = -1d0
     A(i,i) = 5d0
     b(i)   = i
    end do
    x = b
    call gesv(A,x)
    print *,x
end

Or Intel MKL provide lapack 95 sample codes in C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.1.146\windows\mkl\examples.

Copy and unzip the sample to your working folder.

3. Link lapack 95 in Property page in Microsoft* Visual Studio* 2012 and Intel® Visual Fortran Compiler (see the screecopy in https://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-build-intel-mkl-program-with-intel-fortran-in-microsoft-visual-studio/)

  1. 3.1) In project Properties page, select Fortran » General, and then in the Additional Include Directories item, add the Intel MKL path:

    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.1.146\windows\mkl\include\intel64\lp64

    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.1.146\windows\mkl\include

    3.2) In Properties page, select Linker » General, and then in the Additional Library Directories item, add the Library path

    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.1.146\windows\mkl\lib\intel64_win

    3.3) Select Linker » Input, and then in Additional Dependencies add the Intel® MKL libraries:

    mkl_lapack95_lp64.lib mkl_intel_lp64.lib mkl_core.lib mkl_intel_thread.lib libiomp5md.lib

    As the figure, we list the explicit  intel MKL libraries  in the link line. 

    Optional: link mkl_lapack95_lp64.lib + quick intel compiler option Qmkl:parallel  should be other alternative to use lapack95. But users have to use either of them. Mixed usages may bring unexpected error.

4. Notes
4.1) some possible error message if without include path setting

>C:\Users\yhu5\Desktop\11.3\mkl_example\lapack95\lapack95\gesv95.f90(2): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [LAPACK95]

4.2) Unresoved external symbol error if without lapack95 library linking

gesv95.obj : error LNK2019: unresolved external symbol DGESV1_F95 referenced in function MAIN__
1>x64\Debug\lapack95.exe : fatal error LNK1120: 1 unresolved externals

4.3) omp error if without libiomp5md.lib, which is Intel OpenMP multithread runtime library from intel compiler

mkl_intel_thread.lib(dimatcopy_par_omp.obj) : error LNK2019: unresolved external symbol omp_get_thread_num referenced in function mkl_trans_mkl_dimatcopy_square_t_par

>mkl_intel_thread.lib(domatcopy2_par_omp.obj) : error LNK2001: unresolved external symbol omp_get_thread_num

In the Intel MKL package, they are prebuilt for the Intel Fortran compiler. If you are using a different compiler, build these libraries before using the interface. Please refer to MKL user guide.


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>