The OpenMP Programming Model

Figure 6.9: A sample OpenMP program along with its Pthreads translation that might be performed by an OpenMP compiler.
\includegraphics[scale=1]{figures/openmppthread.ps}

\includegraphics[scale=1.2]{figures/8-6}

Using the parallel directive;

\includegraphics[scale=1.2]{figures/8-7}

Using the reduction clause;

\includegraphics[scale=1.2]{figures/8-9}

\includegraphics[scale=1.2]{figures/8-10}
Note that this program is much easier to write in terms of specifying creation and termination of threads compared to the corresponding POSIX threaded program.
Cem Ozdogan 2010-12-27