Module 10: Open Multi-Processing
  Lecture 20: The “omp sections” Directive
 


The “omp sections” Directive

Clauses Supported: “sections” Directive
  • Private(list)
  • Lastprivate(list)
  • Firstprivate(list)
  • Reduction(operator:list)
  • Nowait
Questions
What happens if the number of threads and the number of sections are different? More threads than sections?

Example 1

A Parallel Section Example
#pragma omp parallel shared(n,a,b,c,d) private(i)
{
#pragma omp sections nowait
{
#pragma omp section
for (i = 0; i < n-1; i++)
b[i] = (a[i] + a[i+1])/2;
#pragma omp section
for (i = 0; i < n; i++)
d[i] = 1.0/c[i];
} /*– End of sections –*/
} /*– End of parallel region –*/
  • By default, there is a barrier at the end of the “omp sections”. Use of “nowait” clause turns off the barrier