sections Directive
- Updated2023-02-21
- 1 minute(s) read
sections Directive
Specifies that the region contains sections of code to divide among the threads. The threads then execute their assigned sections of code.
Binding thread set: current team
Format
#pragma omp sections [clause[ [,]clause] ..] newline
{
#pragma omp section
{
code block
}
}
Example
int main()
{
#pragma omp parallel
{
#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());
}
}