Skip to content

Commit

Permalink
Create example-sections.c
Browse files Browse the repository at this point in the history
  • Loading branch information
albeertito7 committed Sep 23, 2021
1 parent 541e12d commit 6b76b32
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions OpenMP/example-sections.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <omp.h>
#include <stdio.h>

#define NT 4

int main(void)
{
int section_count=0;

omp_set_dynamic(0);
omp_set_num_threads(NT);

#pragma omp parallel firstprivate(section_count)

#pragma omp sections
{
#pragma omp section
{
section_count++;/*may print 1 or 2*/
printf("section count %d\n", section_count);
}

#pragma omp section
{
section_count++;/*may print 1 or 2*/
printf("section count %d\n", section_count);
}
}

return 0;
}

0 comments on commit 6b76b32

Please sign in to comment.