single-openmp
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| single-openmp [June 11, 2026 at 07:42] – created - external edit 127.0.0.1 | single-openmp [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | # Single (OpenMP) | ||
| - | **Single** is an OpenMP directive that runs the enclosed block on exactly one thread, whichever arrives first. All other threads skip the block and wait at an implicit barrier at the end, so the whole team is synchronised before continuing. It is commonly used for initialisation, | ||
| - | |||
| - | ```c | ||
| - | #pragma omp parallel | ||
| - | { | ||
| - | #pragma omp single | ||
| - | initialise(); | ||
| - | |||
| - | process(); | ||
| - | } | ||
| - | ``` | ||
| - | |||
| - | The `nowait` clause removes the implicit barrier (`#pragma omp single nowait`), but is only safe when the rest of the parallel block does not depend on what the single block produced. | ||
single-openmp.1781163764.md.gz · Last modified: by 127.0.0.1
