Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. GNU nano 2.2.6 Plik: sekcje.c
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <omp.h>
  7.  
  8. #ifndef _OPENMP
  9. #define omp_get_num_threads() 1
  10. #define omp_get_thread_num() 0
  11. #define omp_get_wtime() 0
  12. #endif
  13.  
  14. int main()
  15. {
  16. double czas_wtime1, czas_wtime2;
  17. czas_wtime1 = omp_get_wtime();
  18. #pragma omp parallel
  19. {
  20. printf("Ilosc wszystkich watkow wynosi %d\n", omp_get_num_threads());
  21. #pragma omp sections
  22. {
  23. #pragma omp section
  24. {
  25. printf("Numer watku wykonujacy sekcje 1 to %d\n", omp_get_thread_num());
  26. sleep(1);
  27. }
  28. #pragma omp section
  29. {
  30. printf("Numer watku wykonujacy sekcje 2 to %d\n", omp_get_thread_num());
  31. sleep(1);
  32. }
  33. #pragma omp section
  34. {
  35. printf("Numer watku wykonujacy sekcje 3 to %d\n", omp_get_thread_num());
  36. sleep(1);
  37. }
  38. }
  39. }
  40. czas_wtime2 = omp_get_wtime();
  41. printf("Czas wykonania wtime wynosi %lf s\n", (czas_wtime2 - czas_wtime1));
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement