Advertisement
--sas

apr22-sections.c

Apr 28th, 2022
1,784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <omp.h>
  3.  
  4. int main() {
  5. #pragma omp parallel
  6.     {
  7. #pragma omp sections
  8.         {
  9. #pragma omp section
  10.             {
  11.                 printf("*sect1* Thread #%d does this section\n", omp_get_thread_num());
  12.             }
  13. #pragma omp section
  14.             {
  15.                 printf("*sect2* Thread #%d does this section\n", omp_get_thread_num());
  16.             }
  17. #pragma omp section
  18.             {
  19.                 printf("*sect3* Thread #%d does this section\n", omp_get_thread_num());
  20.             }
  21. #pragma omp section
  22.             {
  23.                 printf("*sect4* Thread #%d does this section\n", omp_get_thread_num());
  24.             }
  25. #pragma omp section
  26.             {
  27.                 printf("*sect5* Thread #%d does this section\n", omp_get_thread_num());
  28.             }
  29. #pragma omp section
  30.             {
  31.                 printf("*sect6* Thread #%d does this section\n", omp_get_thread_num());
  32.             }
  33.         }
  34.  
  35.         printf("*nosect* Thread #%d\n", omp_get_thread_num());
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement