next up previous contents
Next: 3 OpenMP Blocking Execution Up: ADAPTOR OpenMP Programmers Guide Previous: 1 Overview   Contents

2 OpenMP Parallel Execution Model

OpenMP uses the ``fork-join'' model of parallel execution with threads sharing variables. Lightweight threads are part of the POSIX standard so are efficiently implemented in most UNIX operating systems. OpenMP simply provides a Fortran API to manage these threads. C and C++ APIs have also been released. Program execution begins with a ``master'' thread. Sections of the program are executed by a ``team'' of threads between directives. The master becomes a member of the team, e.g.

! one thread only here
      ...
!$OMP parallel
! this is a parallel section
! everything is shared across a team
! of threads with the program replicated
      ...
!$OMP end parallel
! threads joined
! now only one thread again
      ...

Figure 1: OpenMP Execution Model for Parallel Regions.
\includegraphics[height=50mm]{master_slave.eps}

Furthermore, OpenMP provides additional directives for the work sharing of computations within parallel regions, for the synchronization and for the definition of the data environment.

The ADAPTOR compilation system translates an OpenMP program to a program using explict POSIX threads. ADAPTOR is a source-to-source translation and therefore needs an additional Fortran compiler. Additionally, ADAPTOR provides runtime support that is written in C and has to be linked with the compiled Fortran program.

Figure 2: ADAPTOR OpenMP Fortran compilation for SM architectures.
\includegraphics[height=54mm]{omp_compilation.eps}

If the ADAPTOR system has been installed with runtime support for PThreads, the compilation of an OpenMP program is started as follows:

    adaptor -openmp <prog>.f 
    adaptor -omp -sm <prog>.f

The compiler driver adaptor invokes the source-to-source translation fadapt, the native Fortran compiler (that does not have to support OpenMP), and links the object file with ADAPTOR OpenMP runtime and the PThreads library.

    fadapt -omp -sm <prog>.f
    ifc -auto -O3 <prog>_adp.f -c -o <prog.o>
    ifc -o <executable> <prog>.o -L$(PHOME) -ladp_sm_pthreads -lpthread


next up previous contents
Next: 3 OpenMP Blocking Execution Up: ADAPTOR OpenMP Programmers Guide Previous: 1 Overview   Contents
Thomas Brandes 2004-03-18