Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Using parallel execution, the MKL library, and static linking

blischke
Beginner
1,829 Views
I have read this thread, and I am still confused. I am trying to compile and link statically, using the MKL library for parallel execution. From the Intel Math Kernel Library for the Windows OS User's Guide, for 32 bit:

Static linking of users code myprog.f and parallel Intel MKL supporting cdecl interface:
ifort myprog.f mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib

Similarly for 64 bit:

Static linking of users code myprog.f and parallel Intel MKL supporting LP64 interface:
ifort myprog.f mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib

I've included those libraries, and after finding threads here, included the option /Qopenmp-link:static, but my users still get errors about needing libiomp5md.dll. In the thread linked to, they talk about libiomp5mt.lib. Should I be using that one too? How does that differ from libiomp5md.lib?

The OP in the linked thread talks about the option /MT. Do I need to include that option? If so, where do I put it? The User's Guide just says it's "highly recommended, but doesn't say how to use it. The release notes don't say either. Do I just add it as an additional option for linking or compiling (or both)?

Similarly, where should I put the /Qopenmp-link:static option? Again, none of the documentation says anything. Right now I have it in the Linker -> Command Line -> Additional Options section, but I'm doing something wrong since I still need the .dll file.


(and why, when I try to paste in this edit window using -v, does it pop up another window that I have to paste my text into (using -v again)? How is that helpful to anyone??)
0 Kudos
10 Replies
TimP
Honored Contributor III
1,829 Views
Would it work for you with
ifort /Qpenmp /Qopenmp-link:static myprog.f mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib ?


0 Kudos
Steven_L_Intel1
Employee
1,829 Views
You do not need to use /MT and in fact that would not help you. The default in version 11 is to link to the OpenMP libraries dynamically, even if other libraries are linked statically. This is what Intel recommends to avoid having multiple copies of the OpenMP libraries in the address space. If you want to use the static version, then you would add /Qopenmp-link:static to the "ifort" command line or under Intel Fortran > Command Line. It is not a linker option - what it does is control the default library directives that the compiler embeds in the object file.

As for CTRL-V, the idea seems to be to prevent problems with pasting formatted text. I have asked that this be removed.
0 Kudos
blischke
Beginner
1,829 Views
I've removed the /MT option from both Fortran -> Command Line and from Linker -> Command Line. I've removed /Qopenmp-link:static from Linker -> Command Line, and added it to Fortran -> Command Line. Is this correct so far?

From the link in my OP, where I had originally replied with pretty much the same post, Jennifer Jiang (also from Intel) replied, and says I need to use libiomp5mt.lib, and that libiomp5md.lib is the interface lib for dynamic dll libiomp5md.dll. Is this correct? If so, the Intel MKL User's Guide section on Selecting Libraries to Link is incorrect. It says to use libiomp5md.lib for static linking.

I'm going to try using libiomp5mt.lib instead of libiomp5md.lib.
0 Kudos
blischke
Beginner
1,829 Views
Since I need to add /Qopenmp-link:static to Fortran -> Command Line, what about libraries I compile myself and link into the project? Do I need to add /Qopenmp-link:static to each of them, and then recompile them?

Also, what does the /MT flag do, anyway? The documentation just says it is "highly recommended".
0 Kudos
Steven_L_Intel1
Employee
1,829 Views
Yes, libiomp5mt.lib is the static library and libiomp5md.lib is the DLL import library. I would recommend using /Qopenmp-link:static and not explicitly naming the library otherwise you and the compiler will fight over which library to use.
0 Kudos
blischke
Beginner
1,829 Views
Yes, libiomp5mt.lib is the static library and libiomp5md.lib is the DLL import library. I would recommend using /Qopenmp-link:static and not explicitly naming the library otherwise you and the compiler will fight over which library to use.

Any answers to the questions of my last post? Do I need to add /Qopenmp-link:static to all the libraires I compile myself and recompile? What does /MT do? Is there somewhere that this stuff is documented?

We're using parallel MKL to take advantage of a dual core/dual CPU 64 bit system. On my dual core 32 bit development system, I'm seeing use of both cores. On the 64 bit system, the same code only runs on one core of one CPU.

0 Kudos
Les_Neilson
Valued Contributor II
1,829 Views
Quoting - blischke
What does /MT do? Is there somewhere that this stuff is documented?


Sorry I can't help with the other stuff but - from the help : /MT "Tells the linker to search for unresolved references in a multithreaded, static run-time library."
I went to the Fortran help and did a search for "compiler directives" One of the topics is "Cross references of compiler options" where I found the /MT entry.
Searching for "openmp" brought up lots of references. ButI haven't got into openmp programming yet.

Les
0 Kudos
Steven_L_Intel1
Employee
1,829 Views
/MT is the Microsoft spelling of what is the default if you are using VS2005 or later - link to the static, multithreaded library. It is equivalent to /libs:static /threads. This and related switches tell the compiler to insert into the object module "default library" directives that, when the linker sees them, tells the linker to search those libraries. It is important that these lists of libraries be consistent across all the object code the linker sees - no mixing static and DLL or threaded vs. non-threaded. (Non-threaded went away in VS2005).

/Qopenmp-link:static is another one of these options that control default library directives. If you use it in compiling one source you should use it in all.

If you are building a static library yourself. I recommend using /libdir:noauto which tells the compiler not to insert ANY of these directives in the object - then it doesn't matter if you use /MT or /Qopenmp-link. It is then up to the user of the library to determine which run-time libraries to use. If the caller is Fortran, this will work fine. If the caller is C/C++, they will have to name the Fortran libraries as additional linker dependencies. Note that unlike Fortran, the C/C++ compiler generates different code depending on your choice of run-time libraries so it's trickier when building C/C++ code into a static library.
0 Kudos
asklingler
Beginner
1,829 Views
Is there a good place to find thelibiomp5md.dll? I've got a Fortran project that I'm compiling against the static libraries for ease of deployment. We'd like to make best use of the autoparallelization - don't mind distributing one or two DLLs - and (the lack of) this dll *seems* to be the major obstacle. I've read recommendations to install the trial version of the Intel MKL, but (1) it seems like there should be a simpler way and (2) having done this on one machine I don't see the dll I want there. So what's the best thing to do? I will try Qopenmp-link:static to produce a fully static-linked deployable but I know that is not recommended.
thanks
0 Kudos
Steven_L_Intel1
Employee
1,829 Views
For deployment, it is included in the redistributables installer.
0 Kudos
Reply