Message Passing Interface: Difference between revisions

Content deleted Content added
Example program: : sizeof won't work if the datatype isn't char. Let it be explicit?
Line 250:
{
sprintf(buf, "Hello %i!", other_rank);
MPI_Send(buf, sizeof(buf)256, MPI_CHAR, other_rank,
0, MPI_COMM_WORLD);
}
Line 257:
for (other_rank = 1; other_rank < num_procs; other_rank++)
{
MPI_Recv(buf, sizeof(buf)256, MPI_CHAR, other_rank,
0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("%s\n", buf);
Line 265:
 
/* Receive message from process #0 */
MPI_Recv(buf, sizeof(buf)256, MPI_CHAR, 0,
0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
assert(memcmp(buf, "Hello ", 6) == 0);
Line 271:
/* Send message to process #0 */
sprintf(buf, "Process %i reporting for duty.", my_rank);
MPI_Send(buf, sizeof(buf)256, MPI_CHAR, 0,
0, MPI_COMM_WORLD);