Bureaucrats, cc_docs_admin, cc_staff
2,879
edits
No edit summary |
|||
Line 1: | Line 1: | ||
== Description == | == Description == | ||
[http://openmp.org/wp/ OpenMP] (Open Multi-Processing) is an application programming interface for shared memory parallel computing. | [http://openmp.org/wp/ OpenMP] (Open Multi-Processing) is an application programming interface (API) for shared memory parallel computing. It is supported on numerous platforms, including Linux and Windows, and is available for the C/C++ and Fortran programming languages. The API consists of a set of directives, a software library, and environment variables. | ||
OpenMP allows | OpenMP allows one to develop fine-grained parallel applications on a multicore machine while making it possible to preserve the structure of the serial code. Although there is only one program instance running, it can execute multiple subtasks in parallel. Directives inserted into the program control the parallel execution and allow the management of the distribution of work between the subtasks. The beauty of these directives is that they are usually non-intrusive. A compiler that does not support them can still compile the program and the user can run it serially. | ||
OpenMP relies on the notion of [https://en.wikipedia.org/wiki/Thread_(computing) threads]. A thread is a bit like a light weight process or a "virtual processor, operating serially", and can formally be defined as the smallest unit of work/processing that can be scheduled by an operating system. From a programmer's point of view, if there are five threads, then that corresponds virtually to five cores that can do a computation in parallel. It is important to understand that the number of threads is independent of the number of physical cores within the computer. Two cores can, for example, run a program with ten threads. The operating system decides how to share the cores' time between threads. | |||
Conversely, one thread can ''not'' be executed by two processors at the same time, so if you have (e.g.) four cores available you must create at least four threads in order to take advantage of them all. In some cases it ''may'' be advantageous to use more threads than the number of available cores, but the usual practice is to match the number of threads to the number of cores. | |||
Another important point concerning threads is synchronization. When multiple threads | Another important point concerning threads is synchronization. When multiple threads in a program do computations at the same time, one must assume nothing about the order in which things happen. If the order matters for the correctness of the code, then the programmer must use OpenMP synchronization directives to achieve that. Also, the precise distribution of threads over cores is unknown to the programmer (although thread [https://en.wikipedia.org/wiki/Processor_affinity affinity] capabilities are available to control that). | ||
The following link points to a [http://www.admin-magazine.com/HPC/Articles/Programming-with-OpenMP tutorial for getting started with OpenMP under Linux]. | The following link points to a [http://www.admin-magazine.com/HPC/Articles/Programming-with-OpenMP tutorial for getting started with OpenMP under Linux]. |