sections-openmp
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| sections-openmp [June 11, 2026 at 09:20] – created - external edit 127.0.0.1 | sections-openmp [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | # Sections (OpenMP) | ||
| - | Suppose you have a few independent operations — compress a buffer, encrypt a header, write a log — that share no data and could run simultaneously. A loop doesn' | ||
| - | |||
| - | ```c | ||
| - | #pragma omp parallel sections | ||
| - | { | ||
| - | #pragma omp section | ||
| - | compress(data); | ||
| - | |||
| - | #pragma omp section | ||
| - | encrypt(header); | ||
| - | |||
| - | #pragma omp section | ||
| - | write_log(meta); | ||
| - | } | ||
| - | ``` | ||
| - | |||
| - | If there are more `section` blocks than threads, the excess blocks are queued and picked up as threads become free. If there are fewer blocks than threads, the extra threads sit idle. For a large or dynamic number of tasks, [[tasks-openmp|tasks]] are more flexible; `sections` is simpler when the count is small and fixed. | ||
sections-openmp.1781169601.md.gz · Last modified: by 127.0.0.1
