... | ... | @@ -230,21 +230,19 @@ int main( int argc, char *argv[] ) |
|
|
MPI_Comm_rank (MPI_COMM_WORLD, &myrank);
|
|
|
MPI_Get_processor_name (processor_name, &namelen);
|
|
|
|
|
|
sprintf( greeting, "Hello world, from process %d of %d on %s",
|
|
|
myrank, numprocs, processor_name );
|
|
|
sprintf (greeting, "Hello world, from process %d of %d on %s", myrank, numprocs, processor_name);
|
|
|
|
|
|
if ( myrank == 0 ) {
|
|
|
if (myrank == 0)
|
|
|
{
|
|
|
printf ("%s\n", greeting);
|
|
|
for ( i = 1; i < numprocs; i++ ) {
|
|
|
MPI_Recv( greeting, sizeof( greeting ), MPI_CHAR,
|
|
|
i, 1, MPI_COMM_WORLD, &status );
|
|
|
for (i = 1; i < numprocs; i++ )
|
|
|
{
|
|
|
MPI_Recv (greeting, sizeof (greeting), MPI_CHAR, i, 1, MPI_COMM_WORLD, &status);
|
|
|
printf ("%s\n", greeting);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
MPI_Send( greeting, strlen( greeting ) + 1, MPI_CHAR,
|
|
|
0, 1, MPI_COMM_WORLD );
|
|
|
}
|
|
|
else
|
|
|
MPI_Send (greeting, strlen (greeting) + 1, MPI_CHAR, 0, 1, MPI_COMM_WORLD);
|
|
|
|
|
|
MPI_Finalize ();
|
|
|
return 0;
|
... | ... | |