Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <omp.h>
  3.  
  4. #define W 400
  5. #define N 555
  6. #define M 600
  7.  
  8. void main()
  9. {
  10. int i, j , k;
  11. int losowa = 0;
  12. double start, end;
  13. int tab1[W][N], tab2[N][M], tab3[W][M];
  14.  
  15. for(i = 0; i < W; i++)
  16. for(j = 0; j < N; j++)
  17. tab1[i][j] = losowa++;
  18.  
  19. for(i = 0; i < N; i++)
  20. for(j = 0; j < M; j++)
  21. tab2[i][j] = losowa--;
  22.  
  23. start = omp_get_wtime();
  24.  
  25. #pragma omp parallel for num_threads(4) schedule(dynamic)
  26. for(i = 0; i < W; i++)
  27. //#pragma omp parallel for num_threads(4) schedule(dynamic)
  28. for(j = 0; j < M; j++){
  29. tab3[i][j] = 0;
  30. // #pragma omp parallel for num_threads(4) schedule(dynamic)
  31. for(k = 0; k < N; k++)
  32. tab3[i][j] = tab3[i][j] + tab1[i][k] * tab2[k][j];
  33.  
  34. }
  35. end = omp_get_wtime();
  36.  
  37. /*
  38. for(i = 0; i < W; i++){
  39. for(j = 0; j < N; j++)
  40. printf("%d ",tab1[i][j]);
  41. printf("\n");
  42.  
  43. }
  44. printf("\n");
  45. for(i = 0; i < N; i++){
  46. for(j = 0; j < M; j++)
  47. printf("%d ",tab2[i][j]);
  48. printf("\n");
  49. }
  50. printf("\n");
  51.  
  52. for(i = 0; i < W; i++){
  53. for(j = 0; j < M; j++)
  54. printf("%d ",tab3[i][j]);
  55. printf("\n");
  56. }
  57. printf("\n");
  58. */
  59. printf("Czas - %lf\n", end - start);
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement