To get a trial key
fill out the form below
Team License (standard version)
Enterprise License (extended version)
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
OpenMP

OpenMP

Nov. 20, 2009
Author:

The article briefly describes the OpenMP technology.

OpenMP

OpenMP (Open Multi-Processing) is a set of compiler directives, library procedures and environment variables intended for programming multi-threaded applications on multi-processor systems with shared memory (SMP-systems).

The first OpenMP standard was developed in 1997 as an API oriented on writing easy portable multi-threaded applications. At first, it was based on Fortran language but then included C and C++ as well.

OpenMP interface became one of the most popular parallel programming technologies. OpenMP is successfully exploited both in programming of supercomputer systems with many processors and in desktop user systems or, for example, Xbox 360.

OpenMP specification is developed by several large computer and software vendors whose activity is regulated by the non-profit organization "OpenMP Architecture Review Board" (ARB) [1].

OpenMP exploits the parallel execution model called "branching-merging". OpenMP program begins as a single execution thread called the initial thread. When the thread meets a parallel construction, it creates a new group of threads consisting of the initial thread itself and some other threads and becomes the main thread in the group. All the members of the new group (including the main thread) execute the code inside the parallel construction. At the end of the parallel construction, there is an implicit barrier. After the parallel construction is processed, the further execution of the user code is performed only by the main thread. A parallel area may include other parallel areas where each thread of the initial area becomes the main thread of its thread group. The embedded areas may also include areas of a deeper nesting level.

The number of threads in a group performed concurrently can be controlled by several methods. One of them is using the environment variable OMP_NUM_THREADS. Another method is to call the procedure omp_set_num_threads(). One more way is to use the expression num_threads together with parallel directive.

OpenMP and other parallel programming technologies

At present, MPI interface (Message Passing Interface) is considered to be the most flexible, portable and popular interface in parallel programming. But the Message Passing Interface:

  • is not too efficient on SMP-systems;
  • is relatively difficult to study because it demands thinking in "non-computing" terms.

POSIX-interface for threading (Pthreads) has a wide support (nearly on all UNIX-systems) but due to many reasons it does not suite the practical parallel programming:

  • Fortran is not supported;
  • its level is too low;
  • no support for data concurrency;
  • the threading mechanism was originally developed not for the purposes of computing concurrency arrangement.

OpenMP can be viewed as a high-level superstructure over Pthreads (or other similar thread libraries). Let us list the advantages OpenMP provides a developer with.

  • Due to the idea of "incremental parallelization", OpenMP is ideal for the developers wishing to quickly parallelize their applications with large parallel loops. A developer does not create a new parallel program but simply adds OpenMP-directives into the text of a serial program.
  • OpenMP is a very flexible mechanism providing the developer with great capabilities of controlling a parallel application's behavior.
  • OpenMP-program is supposed to be used as a serial one on a single-processor platform, i.e. you do not need to support both the serial and parallel versions. OpenMP-directives are simply ignored by the serial compiler and to call the OpenMP-procedures you may place stubs whose texts are given in the specifications.
  • One of OpenMP's advantages, as its developers point out, is support of the so called "orphan" directives, i.e. work synchronization and distribution directives do not necessarily need to be included directly into the lexical context of a parallel area.

OpenMP and toolkit

At present, OpenMP technology is supported by most C/C++ compilers. Yet, it is not so good with the tools of testing parallel OpenMP programs. Although analysis tools and tools for testing and optimizing parallel programs have existed for a long time, they were not too popular in the sphere of applied software development until recently. That is why they are often less convenient than other development tools.

The fullest support of parallel OpenMP-program development is provided by the package Intel Parallel Studio. It includes a tool of preliminary code analysis for detecting code fragments that can be potentially parallelized. There is a compiler with OpenMP support providing good optimization. There is also a profiler and a dynamic analysis tool for detecting parallel errors.

References

Popular related articles
The Ultimate Question of Programming, Refactoring, and Everything

Date: 04.14.2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: 10.22.2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…
The Last Line Effect

Date: 05.31.2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
The way static analyzers fight against false positives, and why they do it

Date: 03.20.2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: 07.31.2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
Free PVS-Studio for those who develops open source projects

Date: 12.22.2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…
The Evil within the Comparison Functions

Date: 05.19.2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
Appreciate Static Code Analysis!

Date: 10.16.2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
PVS-Studio ROI

Date: 01.30.2019

Author: Andrey Karpov

Occasionally, we're asked a question, what monetary value the company will receive from using PVS-Studio. We decided to draw up a response in the form of an article and provide tables, which will sho…
PVS-Studio for Java

Date: 01.17.2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…

Comments (0)

Next comments

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept