Q. What is Work-Sharing Constructs?
A work-sharing construct distributes execution of associated region amongst the members of team which encounters it. A work-sharing construct doesn't launch new threads.
OpenMP defines three work sharing constructs: for, single and sections. In all of these constructs there is an implicit barrier at the end of construct unless a nowait clause is included.
(a) Sections
The sections construct is a no iterative work sharing construct which causes structured blocks to be shared among threads in team. Every structured block is executed one time by one of threads in team. The syntax of portions construct is:
#pragma omp sections [set of clauses.]
{
#pragma omp section
structured-bloc
#pragma omp section
structured-block
.
.
}
The clause is one of the following:
private(list)
firstprivate(list)
lastprivate(list)
reduction(operator: list)
nowait