You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
559 B
C
21 lines
559 B
C
2 years ago
|
#include "mpi.h"
|
||
|
#include <string.h>
|
||
|
#include <stdio.h>
|
||
|
int main( int argc, char **argv){
|
||
|
char message[20];
|
||
|
int myrank;
|
||
|
MPI_Status status;
|
||
|
MPI_Init( &argc, &argv );
|
||
|
MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
|
||
|
if (myrank == 0){ /* code for process zero */
|
||
|
strcpy(message,"Hello, there");
|
||
|
MPI_Send(message, strlen(message)+1, MPI_CHAR, 1, 99, MPI_COMM_WORLD);
|
||
|
}
|
||
|
else if (myrank == 1){ /* code for process one */
|
||
|
MPI_Recv(message, 20, MPI_CHAR, 0, 99, MPI_COMM_WORLD, &status);
|
||
|
printf("received :%s:\n", message);
|
||
|
}
|
||
|
MPI_Finalize();
|
||
|
return 0;
|
||
|
}
|