Parallel Programming in OpenMP

3.2: Form and Usage of the parallel do Directive

3.2 Form and Usage of the parallel do Directive

Figure 3.1 shows a high-level view of the syntax of the parallel do directive in Fortran, while Figure 3.2 shows the corresponding syntax of the parallel for directive in C and C++. The square bracket notation ([ ]) is used to identify information that is optional, such as the clauses or the end parallel do directive. Details about the contents of the clauses are presented in subsequent sections in this chapter.

    <b class="bold">!$omp parallel do [clause [,] [clause ...]]</b>        do index = first, last [, stride]            body of the loop        enddo    [<b class="bold">!$omp end parallel do</b>]

Figure 3.1: Fortran syntax for the parallel do directive.
    <b class="bold">#pragma omp parallel for [clause [clause ...]]</b>        for (index = first ; test_expr ; increment_expr) {            body of the loop        }

Figure 3.2: C/C++ syntax for the parallel for directive.

In Fortran, the parallel do directive parallelizes the loop that immediately follows it, which means there must be a statement following the directive, and that statement must be a do loop. Similarly, in C and...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Temperature Controllers
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.