Ahmed -
Bcast does the sending and receiving in itself. You do not need to
explicitly make a call to MPI_Recv from the other nodes. If everyone
makes the MPI_Bcast call, then the message will be sent from the
"MASTER", designated by the fourth parameter. Only the process with the
rank of "MASTER" will do a send, all other processes will do a receive.
Try the following:
#define MASTER 0
main(int argc, char **argv )
{
char message[20];
int i,rank, size, type=99;
MPI_Status status;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD,&size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0) { strcpy(message, "Hello, world"); }
/* MPI_Bcast(void* buffer, int count, MPI_Datatype type, int
root, MPI_Comm comm */
MPI_Bcast(message,20,MPI_CHAR,MASTER,MPI_COMM_WORLD);
printf( "Message to node =%d : %.13s\n", rank,message);
MPI_Finalize();
return 0;
}
------------------------------
Joshua Stewart
Software Engineer
Applied Optimization
joshua.stewart_at_[hidden]
-----Original Message-----
From: lam-bounces_at_[hidden] [mailto:lam-bounces_at_[hidden]] On Behalf
Of Imran Ahmed khan
Sent: Wednesday, September 29, 2004 11:38 AM
To: lam_at_[hidden]
Subject: LAM: B_cast error
hi,
when i run the following program ,i get the following error :
#include <stddef.h>
#include <stdlib.h>
#include "mpi.h"
#include<string.h>
main(int argc, char **argv )
{
char message[20];
int i,rank, size, type=99;
MPI_Status status;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD,&size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
strcpy(message, "Hello, world");
MPI_Bcast(message,20,MPI_CHAR,0,MPI_COMM_WORLD);
}
else
{
MPI_Recv(message, 20, MPI_CHAR, 0,type, MPI_COMM_WORLD,
&status);
printf( "Message to node =%d : %.13s\n", rank,message);
}
MPI_Finalize();
return 0;
}
I got this error :
MPI_Recv: process in local group is dead (rank 2, MPI_COMM_WORLD)
MPI_Recv: process in local group is dead (rank 1, MPI_COMM_WORLD)
Rank (1, MPI_COMM_WORLD): Call stack within LAM:
Rank (1, MPI_COMM_WORLD): - MPI_Recv()
Rank (2, MPI_COMM_WORLD): Call stack within LAM:
Rank (2, MPI_COMM_WORLD): - MPI_Recv()
Rank (2, MPI_COMM_WORLD): - main()
Rank (1, MPI_COMM_WORLD): - main()
Rank (2, MPI_COMM_WORLD): - main()
------------------------------------------------------------------------
-----
One of the processes started by mpirun has exited with a nonzero exit
code. This typically indicates that the process finished in error.
If your process did not finish in error, be sure to include a "return
0" or "exit(0)" in your C code before exiting the application.
PID 2393 failed on node n2 (192.168.11.27) with exit status 1.
------------------------------------------------------------------------
-----
send and recieve method is working fine...but this program is not
working..
plz help
thanx
Imran
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
_______________________________________________
This list is archived at http://www.lam-mpi.org/MailArchives/lam/
|