Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mpi.h>
- #include <stdio.h>
- //#include <math.h>
- int main( int argc, char *argv[] )
- {
- int i;
- int numproc,myid;
- int from,to,tag, count;
- int r_count, r_source, r_tag;
- double data[100];
- MPI_Status status;
- MPI_Init(&argc,&argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &myid);
- MPI_Comm_size(MPI_COMM_WORLD, &numproc);
- if( myid == 0 )
- {
- for(i = 0; i < 100; i++)
- {
- data[i] = (double)i;
- }
- count = 9;
- to = 3;
- tag = 2012;
- MPI_Send(data, count, MPI_DOUBLE, to, tag, MPI_COMM_WORLD);
- }
- else if (myid == 3)
- {
- count = 100;
- from = MPI_ANY_SOURCE;
- tag = MPI_ANY_TAG;
- MPI_Recv(data,count,MPI_DOUBLE,from,tag,MPI_COMM_WORLD,&status);
- MPI_Get_count(&status, MPI_DOUBLE, &r_count);
- r_source = status.MPI_SOURCE;
- r_tag = status.MPI_TAG;
- printf("Zmienna status - informacje;\n");
- printf("Pochodzenie komunikatu i proces: %d\n", r_source);
- printf("Znacznik komunikatu: %d\n", r_tag);
- printf("Liczba elementow: %d\n", r_count);
- printf("Proces %d odebral: \n", myid);
- for( i = 0; i < r_count; i++ )
- {
- printf("%f ", data[i]);
- }
- printf("\n");
- }
- else {}
- MPI_Finalize();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment