Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <omp.h>
  3. using namespace std;
  4. void A()
  5. {
  6. printf("A\n");
  7. }
  8. void B()
  9. {
  10. printf("B\n");
  11. }
  12. void C()
  13. {
  14. printf("C\n");
  15. }
  16. void D()
  17. {
  18. printf("D\n");
  19. }
  20. void E()
  21. {
  22. printf("E\n");
  23. }
  24.  
  25. int main(void)
  26. {
  27.  
  28. #pragma omp parallel num_threads(10)
  29. {
  30. int id_thr = omp_get_thread_num();
  31. if (id_thr == 0)
  32. {
  33. A();
  34. }
  35. else if (id_thr == 1)
  36. {
  37. B();
  38. }
  39. else if (id_thr == 2)
  40. {
  41. C();
  42. }
  43.  
  44. #pragma omp barrier
  45. { if (id_thr == 4)
  46. {
  47. D();
  48. }
  49. #pragma omp barrier
  50. if (id_thr == 5)
  51. {
  52. E();
  53. }
  54. }
  55. }
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement