Abstract
- OpenMP is an Application Program Interface (API), jointly defined by a group of major computer hardware and software vendors. OpenMP provides a portable, scalable model for developers of shared memory parallel applications. The API supports C/C++ and Fortran on a wide variety of architectures.
https://hpc-tutorials.llnl.gov/openmp/
Introduction
https://www.openmp.org/resources/openmp-books/
https://www.openmp.org/wp-content/uploads/openmp-examples-6.0.pdf

OpenMP is
-
An Application Program Interface (API) that may be used to explicitly direct multi-threaded, shared memory parallelism
-
Comprised of three primary API components:
-
An abbreviation for:
- Short version: Open Multi-Processing
- Long version: Open specifications for Multi-Processing via collaborative work between interested parties from the hardware and software industry, government and academia.
OpenMP is not
-
Necessarily implemented identically by all vendors.
-
Guaranteed to make the most efficient use of shared memory.
-
Required to check for code sequences that cause a program to be classified as non-conforming.
-
Designed to guarantee that input or output to the same file is synchronous when executed in parallel. The programmer is responsible for synchronizing input and output.
-
Required to check for data dependencies, data conflicts, race conditions, or deadlocks.
-
Here’s why:
-
- OpenMP is Declarative, Not Analytic
-
OpenMP uses compiler directives (pragmas) to declare parallelism.
-
The compiler applies those directives without analyzing whether it's actually safe.
-
For example:
#pragma omp parallel for
for (int i = 0; i < N; i++) {
A[i] = A[i] + A[i-1]; // Potential race condition!
}
-
The compiler will parallelize this even though A[i] depends on A[i-1].
-
- Programmer Control = Programmer Responsibility
- OpenMP gives manual control over shared vs. private variables, synchronization (
#pragma omp critical, barrier, etc.), and scheduling.
- This flexibility comes with the burden of ensuring correctness—OpenMP trusts you know what you're doing.
-
- Runtime Performance > Safety Checks
- OpenMP prioritizes performance.
- Checking for race conditions or dependencies at compile-time or runtime would:
- Slow down compilation
- Add runtime overhead
- Reduce performance for well-written code
-
- Static Analysis Is Hard
- Detecting data races or deadlocks statically (before running the program) is often undecidable in general.
Goals of OpenMP
- Standardization
- Provide a standard among a variety of shared memory architectures/platforms.
- Jointly defined and endorsed by a group of major computer hardware and software vendors.
- Lean and Mean
- Establish a simple and limited set of directives for programming shared memory machines.
- Significant parallelism can be implemented by using just 3 or 4 directives.
- This goal is becoming less meaningful with each new release, apparently.
- Ease of Use
- Provide capability to incrementally parallelize a serial program, unlike message-passing libraries which typically require an all or nothing approach
- Provide the capability to implement both coarse-grain and fine-grain parallelism
- Portability
- The API is specified for C/C++ and Fortran
- Public forum for API and membership
- Most major platforms have been implemented including Unix/Linux platforms and Windows
OpenMP Programming Model