Hi,
you do not send the trailing '0' which is used to determine the
stringlength. I assume that chdata[i] has at least length 5 (otherwise
you overrun your memory). Replace the "4" by "5" in MPI_Isend and
MPI_Recv and everything should work (If I get the problem right).
Dorian.
Alexey Sokolov wrote:
Hi
I'm sorry if the answer to my question is very simple, but I'm really
confused with this situation.
I got a program that now contains 1 master and 1 slave processes. Master
process sends few similar chars to the slave process with this:
for (unsigned i = 0; i < SomeVariable; i++) {
strcpy(chdata[i], "asdf");
MPI_Isend(chdata[i], 4, MPI_CHAR, SLAVE, 1, MPI_COMM_WORLD,
&req[i]);
}
And the slave process receives them with this:
for (unsigned i = 0; i < SomeVariable; i++) {
char * buf = new char[10];
MPI_Recv(buf, 4, MPI_CHAR, MASTER, 1, MPI_COMM_WORLD, &stat);
printf("Received data [%s] of length %d\n", buf, strlen(buf));
}
As I understand output should be "Received data [asdf] of length 4", but
instead of this I got my 'asdf' with additional 3 random ANSI characters
in string of length 7.
I've already spent few hours to find the mistake out but unsuccessfully.
I do successfully transfer int data in the similar way, but this case
make me crazy. Could you help me to find out where did I fail in this?
Sincerely yours, Alexey.
_______________________________________________
users mailing list
us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/users