parallel sections Directive
- Updated2023-02-21
- 1 minute(s) read
parallel sections Directive
Specifies a parallel region containing one sections directive. The parallel sections directive is a shortcut for the parallel directive followed immediately by a sections directive. The shortcut creates a team of threads and divides the sections between the threads at the same time.
Binding thread set: encountering thread
Format
#pragma omp parallel sections [clause[ [,]clause] ..] newline
{
#pragma omp section
{
code block
}
}
Example
int main()
{
#pragma omp parallel sections
{
#pragma omp section
printf("This is from thread %d\n", omp_get_thread_num());
#pragma omp section
printf("This is from thread %d\n", omp_get_thread_num());
}
}