Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Missmatch between sent and recieved data
From: Alexey Sokolov (gabbear_at_[hidden])
Date: 2009-07-24 10:41:06


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.