OpenMP directives exploit shared memory parallelism by defining various types of parallel regions. Parallel regions can include both iterative and non-iterative segments of program code.
Pragmas fall into four general categories:
OpenMP directive syntax .-,----------. V | >>-#pragma omp--pragma_name----+--------+-+--statement_block--->< '-clause-'
Pragma directives generally appear immediately before the section of code to which they apply. For example, the following example defines a parallel region in which iterations of a for loop can run in parallel:
#pragma omp parallel { #pragma omp for for (i=0; i<n; i++) ... }
This example defines a parallel region in which two or more non-iterative sections of program code can run in parallel:
#pragma omp sections { #pragma omp section structured_block_1 ... #pragma omp section structured_block_2 ... .... }
For a pragma-by-pragma description of the OpenMP directives, refer to "Pragma directives for parallel processing".