Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GNU nano 2.2.6 Plik: /home/student/RafalS/lab11_l1.c
- #include <stdio.h>
- #include <mpi.h>
- #include <string.h>
- #include <stdlib.h>
- int main(int argc, char* argv[])
- {
- int id, p;
- int to, from, tag;
- int i;
- char data[100];
- MPI_Status status;
- MPI_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &id);
- MPI_Comm_size(MPI_COMM_WORLD, &p);
- if(id!=0){
- to=0;
- tag=2017;
- sprintf(data,"Pozdrowienia od procesu %d\n",id);
- MPI_Send(&data,strlen(data)+1, MPI_CHAR, to, tag, MPI_COMM_WORLD);
- }
- if (id == 0) {
- for(from=1;from<p;from++)
- {
- MPI_Recv(&data,100,MPI_CHAR,from,tag,MPI_COMM_WORLD,&status);
- printf("%s\n",data);
- }
- }
- MPI_Finalize();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement