Compartilhar via


Using OpenMP in Visual C++.NET 2005.

The OpenMP (Open Multi-Processing) is an application programming interface (API) that supports multi-platform shared memory multiprocessing programming in C/C++ and FORTRAN on much architecture, including UNIX and Microsoft Windows platforms. It consists of a set of compiler directives, library routines, and environment variables that influence run-time behavior.

OpenMP is a portable, scalable model that gives programmers a simple and flexible interface for developing parallel applications for platforms ranging from the desktop to the supercomputer

The Visual C++ fully supports the OpenMP 2.0 standard. The OpenMP API consists of many directives (https://msdn2.microsoft.com/en-us/library/0ca2w8dk(VS.80).aspx) and Clauses (https://msdn2.microsoft.com/en-us/library/2kwb957d(VS.80).aspx) which are fully supported by VC++.

The OpenMP also provides the libraries which are required for using the OpenMP directives and Clauses in your application. For example VCOMP.LIB (multithreaded library used for release version of the application and VCOMPD.LIB (for the debug version). You can find these libraries in your machine (e.g. <drive :> \Program Files\Microsoft Visual Studio 8\VC\lib). You will also need to use the /openmp switch for compilation of your application to use the /openmp features.

The OpenMP also supports Data Types , Environment variables and Functions (https://msdn2.microsoft.com/en-us/library/6f86t44e(VS.80).aspx) which can be used to optimized the performance of your application.

Comments

  • Anonymous
    April 05, 2007
    This is real nice article.

  • Anonymous
    October 23, 2007
    Great article, I just wonder if you can give me a tip: I am developing using Visual Studio 2003 where OpenMP is not included. Is there any way I can upgrate Developer 2003? Many thanks! Cheers Marco

  • Anonymous
    December 21, 2007
    Hi Marco, OpenMP is not supported for VC++ 2003..

  • Anonymous
    June 25, 2009
    Maybe you can install Windows SDK Update for Vista to get the OpenMP headers and libs?

  • Anonymous
    March 04, 2011
    hi Please help me Can i use openmp in my windows application program(with visualc++)?? (Form application)

  • Anonymous
    March 29, 2012
    It is true that OpenMP is not supported in VS2003 but it can be easily integrated. I already tried and it works, all you have to do is make a dll that exports methods that use openmp (did it in CodeBlocks with updated MinGW) than load the dll in your VS2003 project and use those functions: // build DLL with GCC in codeblocks with static linking (if legal), use -fopenmp flag set and don't forget to tell linker where the dll's are #include "main.h" typedef void* (stdcall *SOMEFUNCTION)(); SOMEFUNCTION someFunc; HINSTANCE hinstDLL; ...  hinstDLL = LoadLibrary("your.dll");  if(hinstDLL != 0)  {      someFunc = (SOMEFUNCTION)GetProcAddress(hinstDLL, "SomeFunction");      if (someFunc_)      {          someFunc_();      }  }  FreeLibrary(hinstDLL); ...