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

link to mkl libraries in parallel studio fails

mgeo
Beginner
907 Views
Hi everyone,

I am using Parallel studio XE update 1 on Ubuntu 10.04 (LTS) and I am trying to link a simple fortran90 program that uses the FFT transform of the Intel MKL libraries but I encounter 2 problems.
First, when I try to run the script mklvars_intel64.sh in order to set the enviroment variables for my architecture (Intel64) I get the following message:

marios@marios-home:~/FFT_MKL$ bash /opt/intel/composerxe-2011.2.137/mkl/bin/intel64/mklvars_intel64.sh
/opt/intel/composerxe-2011.2.137/mkl/bin/mklvars.sh: 12: Bad substitution

what does the message 12: Bad substitution mean? does anyone know why I can't run the script?

One can still link to the MKL library even without setting the enviroment variables at compile-time. For example the dynamic linking of my program fft_test.F90 and sequential version of Intel MKL supporting the LP64 interface is:

ifort -O3 fft_test.F90 -L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64 -I/opt/intel/composerxe-2011.2.137/mkl/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -o run.out

but when I do that I get the message:

fft_test.F90(6): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [MKL_DFTI]
Use MKL_DFTI
----^

seems it does not link to the mkl_dfti module.

Any ideas about the problem? I am stuck 2 days with this :(

Thanks,

Marios
0 Kudos
13 Replies
mecej4
Honored Contributor III
907 Views
You committed three errors:

i) you did not run the parent script, which is in the bin directory; that script calls the architecture-specific script, in turn. The parent script requires an argument: 'ia32' or 'intel64'.

ii) the scripts are intended to be "sourced" instead of run directly, since these are scripts that sets environmental variables that need to be exported to the calling environment. If run directly, the variables are created while the script runs, but they cease to exist when the script finishes.

Therefore, what you have to do (other than reading the documentation more carefully) is :

$ . /bin/ifortvars.sh intel64

Note the period and space at the beginning of the command.
0 Kudos
mgeo
Beginner
907 Views
Thanks for the reply,
and the note about the period and the space

I suppose you mean $ . /bin/mklvars.sh intel64 (ifortvars is for mkl?)

This seems to work but when I try to compile: ifort -O3 fft_test.F90 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -o run.out

or specifically ifort -O3 fft_test.F90 -L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64 -I/opt/intel/composerxe-2011.2.137/mkl/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -o run.out

I get the same error: fft_test.F90(6): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [MKL_DFTI]
Use MKL_DFTI
----^


???

0 Kudos
TimP
Honored Contributor III
907 Views
Compiled module files are found by -I paths set prior to the appearance of the source file which requires them. If you are looking for .mod files where they are installed by MKL, you must include the path all the way down to directory level, e.g. (as you appear to be intending to use lp64 libraries)

-I...../mkl/include/intel64/lp64/ fft_test.F90 .....
0 Kudos
mecej4
Honored Contributor III
907 Views
Sorry, I did not notice earlier that you were using MKL as a package by itself.

Did you install MKL separately from IFORT? Or did you install the bundled MKL?

If the latter, the startup script for the compiler takes care of everything. You do need to specify that your programs requires MKL, using the convenient option -mkl (/Qmkl in Windows).
0 Kudos
mgeo
Beginner
907 Views
fft_test.F90 IS NOT A MODULE it's the program I am trying to compile!
it uses the mkl_dfti module which is located in /opt/intel/composerxe-2011.2.137/mkl/include.

and I compile:
ifort -O3 fft_test.F90 -L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64 -I/opt/intel/composerxe-2011.2.137/mkl/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -o run.out
0 Kudos
mgeo
Beginner
907 Views
I installed Intel Parallel Studio XE, the installation was succesfull (even the prerequisites) . I suppose this installs fortran compiler and MKL simultaneously, even so they are located in different directories.

I state that my program requires MKL, read again my compiler command:
ifort -O3 fft_test.F90 -L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64 -I/opt/intel/composerxe-2011.2.137/mkl/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -o run.out

-L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64: for linking to mkl
-I/opt/intel/composerxe-2011.2.137/mkl/include : for including the module file
-lmkl_intel_lp64 : for the mkl library
0 Kudos
mgeo
Beginner
907 Views
I installed Intel Parallel Studio XE, the installation was succesfull (even the prerequisites) . I suppose this installs fortran compiler and MKL simultaneously, even so they are located in different directories.

I state that my program requires MKL, read again my compiler command:
ifort -O3 fft_test.F90 -L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64 -I/opt/intel/composerxe-2011.2.137/mkl/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -o run.out

-L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64: for linking to mkl
-I/opt/intel/composerxe-2011.2.137/mkl/include : for including the module file
-lmkl_intel_lp64 : for the mkl library

0 Kudos
mecej4
Honored Contributor III
907 Views
Module files are not located in the .../mkl/include directory itself, but in a subdirectory specific to the architecture, such as .../mkl/include/em64t/lp64 (this is on Windows; the details vary slightly with compiler version and platform).

As TimP wrote, you need to give this specific subdirectory as the argument to the /I option.
0 Kudos
mgeo
Beginner
907 Views
First of all, since I set the enviroment variables via : . /opt/intel/composerxe-2011.2.137/mkl/bin/mklvars.sh intel64

I don't need to include the -L/... and -I/... for dynamic linking according to MKL 10.3 User's Guide (pdf p. 40) but that seems not to be the case.

Again according to MKL 10.3 User's Guide (pdf p. 40) the -I option should be -I/opt/intel/composerxe-2011.2.137/mkl/include

and the module I need is in this directory and NOT in any subdirectory.

So I do things by the book and it doesn't work.

I tried your suggestion, typed -I/opt/intel/composerxe-2011.2.137/mkl/include/intel64/lp64 but same error.


0 Kudos
Evgueni_P_Intel
Employee
907 Views
Hi mgeo,

The MKL DFTI module must be compiled explicitly.

For you the compile line for the MKL DFTI module would be:
ifort -c /opt/intel/composerxe-2011.2.137/mkl/include/mkl_dfti.f90
This command will createmkl_dft_type.mod and mkl_dfti.mod in your working directory.

The build line for your test would be:
ifort -O3 fft_test.F90 -L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64 -I/opt/intel/composerxe-2011.2.137/mkl/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -module . -o run.out

0 Kudos
Dmitry_B_Intel
Employee
907 Views
Hi,

File mkl/include/mkl_dfti.f90 is the source code of the module needed for 'use mkl_dfti' statement. That statement needs file mkl_dfti.mod that isnot provided precompiled (that is why adding mkl/include/lp64 to module search path doesn't help).One way to solve this is to addthissource file into your project or makefile and make sure it is compiled before the files containing 'use mkl_dfti' statement. Another way is to add statement "include'mkl_dfti.f90'" as a top line into the sources containing 'use mkl_dfti'.

Thanks
Dima
0 Kudos
mgeo
Beginner
907 Views
Hi Evgueni,

I just saw your reply. You are RIGHT! I did a similar thing yesterday:

copied the mkl_dfti to my working directory and compiled it ifort -c mkl_dft.f90 and then

ifort -O3 fft_test.F90 -L/opt/intel/composerxe-2011.2.137/mkl/lib/intel64 -I/opt/intel/composerxe-2011.2.137/mkl/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -o run.out


This finally worked! But it's a pleasure to see a correct answer too :)

Thanks a lot,


Marios
0 Kudos
mgeo
Beginner
907 Views
Hi Dima,


correct answer too, thanks a lot!

Marios
0 Kudos
Reply