9.2. The OpenMP programming model

OpenMP uses the fork-join model of parallel execution. Although this fork-join model can be useful for solving a variety of problems, it is somewhat tailored for large array-based applications. OpenMP is intended to support programs that will execute correctly both as parallel programs (multiple threads of execution and a full OpenMP support library) and as sequential programs (directives will be ignored and a stub library will be linked).

A program written with the OpenMP C/C++ API begins execution as a single thread of execution called the master thread. The master thread executes in a serial region until the first parallel construct is executed. In the OpenMP C/C++ API, the parallel directive constitutes a parallel construct. When a parallel construct is executed, the master thread creates a team of threads, and the master becomes master of the team. Each thread in the team executes the statements in the dynamic extent of a parallel region, except for the work-sharing constructs. Work-sharing constructs must be executed by all threads in the team in the same order, and the statements within the associated structured block are executed by one or more of the threads.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset