Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mpi.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char** argv) {
- // Initialize the MPI environment
- MPI_Init(NULL, NULL);
- // Find out rank, size
- int world_rank;
- MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
- int world_size;
- int size = 1000000;
- float tab[1000000];
- int p;
- for(p=0; p<size; p++)
- tab[p] = 1;
- MPI_Comm_size(MPI_COMM_WORLD, &world_size);
- double t1,t2;
- int i;
- for (i = 0; i<20; i++){
- t1 = MPI_Wtime();
- MPI_Bcast(tab, size, MPI_FLOAT, 0, MPI_COMM_WORLD);
- //MPI_Scatter( tab, size/4, MPI_FLOAT,tab,size/4,MPI_FLOAT,0,MPI_COMM_WORLD);
- MPI_Barrier(MPI_COMM_WORLD);
- t2 = MPI_Wtime();
- if(world_rank == 0){
- printf("%lf\n",t2-t1);
- }
- }
- MPI_Finalize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement