Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<pthread.h>
  4. #include <unistd.h>
  5. #include <omp.h>
  6. #include <time.h>
  7. #include <omp.h>
  8.  
  9. int main(int argc, char *argv[]) {
  10.  
  11. int n=100000000,zarodek,i,j,k;
  12. time_t tt;
  13.  
  14.  
  15. //#pragma omp parallel for schedule(static) shared (a,b,result) private(i,j,k)
  16. double *a, *b, *result;
  17.  
  18. srand(time(NULL));
  19.  
  20.  
  21. a=malloc(n*sizeof(double));
  22. b=malloc(n*sizeof(double));
  23. result=malloc(n*sizeof(double));
  24.  
  25. for(i=0; i<n;i++){
  26. a[i]=rand()%50;
  27. b[i]=rand()%50;
  28. }
  29. double start = omp_get_wtime();
  30. for(i=0; i<n;i++)
  31. result[i]=a[i]*b[i];
  32.  
  33. double time = omp_get_wtime() - start;
  34.  
  35. printf(" CZAS BASIC: %g\n ", time);
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement