
Programming Shared
Memory II
Dr. Cem Özdo
˘
gan
LOGIK
OpenMP: a Standard
for Directive Based
Parallel Progr amming
The OpenMP Programming
Model
The OpenMP Design
Concepts
10.5
The OpenMP Programming Model I
•
OpenMP directives provide support for concu rrency,
synchronization, and data handling while avoiding the
need for explicitly setting up mutexes, condition variables,
data scope, and initialization.
•
OpenMP directives in C is based on the #pragma compiler
directives.
•
The direc tive itself consists of a directive name followed by
clauses.
#pragma omp d i r e c t i v e [ clause l i s t ]
•
OpenMP programs execute serially until they encounter
the parallel directive.
•
This directive is responsible for creating a group of
threads.
•
The exact number of threads can be
• specified in the directive (num_threads(4)),
• set using an environment variable (export
OMP_NUM_THREADS=4 [sh, ksh, bash]),
• defined at runtime using OpenMP functions
(omp_set_num_ threads(4)).