OpenMP

OpenMP (Open Multi-Processing) is an application programming interface (API) that supports multi-platform shared-memory multiprocessing programming in C, C++, and Fortran,[3] on many platforms, instruction-set architectures and operating systems, including Solaris, AIX, FreeBSD, HP-UX, Linux, macOS, and Windows.

It consists of a set of compiler directives, library routines, and environment variables that influence run-time behavior.

[2][4][5] OpenMP is managed by the nonprofit technology consortium OpenMP Architecture Review Board (or OpenMP ARB), jointly defined by a broad swath of leading computer hardware and software vendors, including Arm, AMD, IBM, Intel, Cray, HP, Fujitsu, Nvidia, NEC, Red Hat, Texas Instruments, and Oracle Corporation.

[1] OpenMP uses a portable, scalable model that gives programmers a simple and flexible interface for developing parallel applications for platforms ranging from the standard desktop computer to the supercomputer.

[9] OpenMP is an implementation of multithreading, a method of parallelizing whereby a primary thread (a series of instructions executed consecutively) forks a specified number of sub-threads and the system divides a task among them.

The runtime environment allocates threads to processors depending on usage, machine load and other factors.

Whether printf is atomic depends on the underlying implementation[17] unlike C++11's std::cout, which is thread-safe by default.

Variant directives are one of the major features introduced in OpenMP 5.0 specification to facilitate programmers to improve performance portability.

They enable adaptation of OpenMP pragmas and user code at compile time.

But sometimes private variables are necessary to avoid race conditions and there is a need to pass values between the sequential part and the parallel region (the code block executed in parallel), so data environment management is introduced as data sharing attribute clauses by appending them to the OpenMP directive.

The different types of clauses are: Used to modify/check the number of threads, detect if the execution context is in a parallel region, how many processors in current system, set/unset locks, timing functions, etc A method to alter the execution features of OpenMP applications.

For instance, Visual C++ 2005, 2008, 2010, 2012 and 2013 support it (OpenMP 2.0, in Professional, Team System, Premium and Ultimate editions[20][21][22]), as well as Intel Parallel Studio for various processors.

A variety of benchmarks has been developed to demonstrate the use of OpenMP, test its performance and evaluate correctness.

An illustration of multithreading where the primary thread forks off a number of threads which execute blocks of code in parallel
Chart of OpenMP constructs