0 out of 1 rated this helpful - Rate this topic

A.1 Executing a Simple Loop in Parallel

The following example demonstrates how to parallelize a simple loop using the parallel for directive (Section 2.5.1 on page 16). The loop iteration variable is private by default, so it is not necessary to specify it explicitly in a private clause.

#pragma omp parallel for
    for (i=1; i<n; i++)
        b[i] = (a[i] + a[i-1]) / 2.0;
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ