Advertisement
Guest User

dsada

a guest
Mar 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <mpi.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int main(int argc, char** argv) {
  6. // Initialize the MPI environment
  7. MPI_Init(NULL, NULL);
  8. // Find out rank, size
  9. int world_rank;
  10. MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
  11. int world_size;
  12. int size = 1000000;
  13. float tab[1000000];
  14. int p;
  15. for(p=0; p<size; p++)
  16. tab[p] = 1;
  17. MPI_Comm_size(MPI_COMM_WORLD, &world_size);
  18. double t1,t2;
  19. int i;
  20. for (i = 0; i<20; i++){
  21. t1 = MPI_Wtime();
  22. MPI_Bcast(tab, size, MPI_FLOAT, 0, MPI_COMM_WORLD);
  23. //MPI_Scatter( tab, size/4, MPI_FLOAT,tab,size/4,MPI_FLOAT,0,MPI_COMM_WORLD);
  24.  
  25. MPI_Barrier(MPI_COMM_WORLD);
  26. t2 = MPI_Wtime();
  27. if(world_rank == 0){
  28. printf("%lf\n",t2-t1);
  29. }
  30.  
  31. }
  32. MPI_Finalize();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement