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

Using OpenMP and MKL with Visual Studio 2005/8

alvaroafernandez
Beginner
598 Views

We are integrating both OpenMP and the Intel Math Kernel library into our product, a library of mathematical, scientific, and statistical algorithms written in C. We are using Microsoft Visual Studio 2005/8 as our development platforms. Attempts to enable multi-threading in OpenMP and the MKL simultaneously have led to crashes.

We note that Visual Studio and MKL use different threading libraries, and that information out on the Web suggests this to be the cause of the crashes. We also note that recent answers to questions on this Intel forum suggest there is no way to remedy the situation unless either (1) MKL is forced to run serially when OpenMP is running (using MKL_SEQUENTIAL) or (2) Visual Studio is abandoned as a development platform in favor of Intel compilers. The posts (and Intel manuals) all indicate that if an application using Intel MKL and OpenMP is built on Intel compilers , the Intel compilers will ensure the application code gracefully handles the thread demands of both.

However, additional reading on the Web did indicate the existence of a new library (libiomp5mt.lib) which rumor has it smiley [:-)] - will allow us to have our cake and eat it too; that is, use Visual Studio, OpenMP and MKL, e.g. post http://software.intel.com/en-us/forums/showthread.php?t=59392#60984 At least, that is our understanding of this post.

We have three questions:

  1. Can libiomp5mt.lib be used to build applications, using Visual Studio, that allow simultaneous multi-threading for both OpenMP and the MKL, allowing e.g. a call to MKL within an OpenMP pragma?
  2. Does libiomp5mt.lib replace libguide40.lib, or does it work in conjunction with it?
  3. Assuming libiomp5mt.lib is what we think it is, how does one incorporate it into a Visual Studio project? We have been wholly unsuccessful in that regard.

0 Kudos
3 Replies
TimP
Honored Contributor III
598 Views
  • Visual Studio 2005 has no OpenMP of its own. As the documents for the current Intel compilers tell you, the Intel libiomp5 libraries (also included with current MKL) are compatible with VC9 -openmp. The products which provide both libguide and libiomp5 work interchangeably with either of them (not both at the same time), when you don't use VC9 -openmp.
  • I don't know what you mean about abandoning Visual Studio (unless you mean switching to linux). Intel compilers and MKL for Windows don't work without Microsoft components; if not Visual Studio, the PPE which comes with ifort.
  • If you are using MKL with VC9, you specify the libiomp library instead of the libguide in your library dependencies. Libiomp satisfies all of the openmp library references made by VC9 or MKL.
0 Kudos
alvaroafernandez
Beginner
598 Views

1. I'm surprised that Visual Studio 2005 has no OpenMP of its own, since we have developers in house who are throwing the /openmp switch and using Visual Studio 2005 with no issues. Do you mean Visual Studio 2005 OpenMP is an Intel product...?

2. It's unclear to me how to use libiomp in this context, which is the crux of my post. Do I add it to the solution? I haven't been able to find an export library for libguide40 or libiomp*.

0 Kudos
TimP
Honored Contributor III
598 Views

The linkage with libiomp5 and VD9 is the same as you would use with MKL with no OpenMP in the VC code. It should work in accordance with MKL docs. If you have an example with libguide, replace that with libiomp5. In case it's of any use, here's my log from a 32-bit Microsoft link, where both VC9 and Intel OpenMP compilations are in use.

Microsoft Incremental Linker Version 9.00.30428.01
Copyright (C) Microsoft Corporation. All rights reserved.

-out:mains.exe
-subsystem:console
-nodefaultlib:libiompprof5mt.lib
-nodefaultlib:libiompprof5md.lib
-defaultlib:libiomp5mt.lib
mains.obj
loopstlm.obj
f90_msrdtsc.obj

If there was /openmp in VC8, I wasn't aware of it, and it may not be supported by libiomp5.

0 Kudos
Reply