| 1 | [[PageOutline]] |
| 2 | |
| 3 | = OpenMP = |
| 4 | |
| 5 | * What is OpenMP? |
| 6 | * The OpenMP is an Application Program Interface (API) that supports shared-memory parallel programming. |
| 7 | * What is the shared-memory? |
| 8 | * The memory space that is accessible from multiple CPUs without an operating system call involvement. |
| 9 | * Limitation |
| 10 | * The number of CPUs on a single compute node bounds the number of threads. (<->Distributed Memory Cluster) |
| 11 | |
| 12 | [[Image(CypressNode.png)]] |
| 13 | == A Programmer’s View of OpenMP == |
| 14 | * OpenMP is a portable, threaded, shared-memory programming specification with “light” syntax |
| 15 | * Exact behavior depends on OpenMP implementation! |
| 16 | * Requires compiler support (C or Fortran) |
| 17 | * OpenMP will: |
| 18 | * Allow a programmer to separate a program into serial regions and parallel regions. |
| 19 | * OpenMP will not: |
| 20 | * Parallelize automatically |
| 21 | * Guarantee speedup |
| 22 | |
| 23 | == OpenMP's Execution Model == |
| 24 | * OpenMP is built around a shared memory space and generates concurrent threads – this is how the parallelism is facilitated. |
| 25 | * CPUs that share memory are called “symmetric multi-processors”, or SMP for short. |
| 26 | * Each thread is typically run on its own processor, though it is becoming common for each CPU or “core” to handle more than one thread “simultaneously”; this is called “hyper-threading”. |
| 27 | * Thread (process) communication is implicit, and uses variables pointing to shared memory locations; this is in contrast with MPI, which uses explicit messages passed among processes. |
| 28 | * These days, most major compilers do support OpenMP directives for most platforms (IBM's XL suite, Intel, even GCC ≥ 4.2). |
| 29 | * A fork is when a single thread is made into multiple, concurrently executing threads. |
| 30 | * A join is when the concurrently executing threads synchronize back into a single thread. |
| 31 | * During the overall execution, threads may communicate with one another through shared variables. |
| 32 | * OpenMP programs essentially consist of a series of forks and joins. |
| 33 | |
| 34 | [[Image(OMPexecModel.png)]] |
| 35 | == Brief Tutorials for Programming Languages == |
| 36 | * [[cypress/Programming/Cexamples/OpenMp|C]] |
| 37 | * [[cypress/Programming/CppExamples/OpenMpCpp|C++]] |
| 38 | * [[cypress/Programming/FortranExamples/OpenMpFortran|Fortran]] |