How to use Intel fortran compiler with MKL at command line

I recently installed Intel® Parallel Studio XE Composer Edition for Fortran OS X * (Student Edition). It comes with the Math Kernel library, so I bought it. I find it difficult to get started with MKL. Here's what I did step by step.

1) Installed Intel® Parallel Studio XE Composer Edition for Fortran OS X * (no problem). I can run the "hello world" script with ifort

and drop the link command -mkl

at the end without issue (without calling any mkl commands yet).

2) Following these instructions, I set the environment variables using the script provided by intel (located at opt ​​/ intel / bin to be exact). I have Intel 64-bit architecture (as per ifort -V

) so I am using bash mklvars.sh intel64 mod ilp64

. It works without error (or any output).

3) I am writing the following code to use the MKL gemm command for fortran95. By simply multiplying 2 matrices.

program test

implicit none
real, dimension(2,2) :: testA, testB, testC

testA = 1
testB = 1
testC = 0  ! I don't think I need this line, but it shouldn't matter

call gemm(testA, testB, testC)

write(*,*) testC

end program test

      

4) I will compile ifort test_mkl.f90 -o test -mkl

. I am getting the following error:

Undefined symbols for architecture x86_64:
  "_gemm_", referenced from:
      _MAIN__ in ifortSTVOrB.o
ld: symbol(s) not found for architecture x86_64

      

5) I try ifort test_mkl.f90 -o test -L/opt/intel/mkl/lib -mkl

and get the same result.

I notice that a lot of people using MKL start their code with USE mkl95_blas, ONLY: gemm

, so I put that above implicit none

in both of the examples above and get:

    test_mkl.f90(4): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [MKL95_BLAS]
    USE mkl95_blas, ONLY: gemm
--------^
test_mkl.f90(12): error #6406: Conflicting attributes or multiple declaration of name.   [GEMM]
    call gemm(testA, testB, testC )
---------^
test_mkl.f90(4): error #6580: Name in only-list does not exist.   [GEMM]
    USE mkl95_blas, ONLY: gemm
--------------------------^
compilation aborted for test_mkl.f90 (code 1)

      

Any ideas as to what the problem is or how to fix it? I have successfully run a simple script in XCODE using MKL, so this is definitely what I am doing and not my installation.

+3


source to share


1 answer


The documentation states that you use the "source" command on the provided compilervars.sh script to make all the resources available. For example:

source // bin / compilervars.sh



This will add MKL to the include and library paths so that the compiler and linker can find them. If you need more help, please refer to https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x . You can get special help for MKL at https://software.intel.com/en-us/forums/intel-math-kernel-library

+1


source







All Articles