Message Truncated in MPI_Recv

15,808

It appears that your problem is that your buffer is too small to receive the message that's being sent. From your explanation, it sounds like you're doing the right thing, but my guess is that somewhere along the way, the order in which you think the messages should be arriving is not the actual order in which they're arriving. You should try to match things up yourself and make sure that everything matches correctly.

If you need more help, you should post your actual code, though you should also trim it down to a Minimal Working Example (http://sscce.org).

Share:
15,808

Related videos on Youtube

Matei
Author by

Matei

Updated on June 30, 2022

Comments

  • Matei
    Matei almost 2 years

    I have the adjacency matrix and the following code:

    if (is_broadcast_message) {
        MPI_Send(&broadcast_message,1,MPI_INT,j,3,MPI_COMM_WORLD);
        MPI_Send(&message,20,MPI_CHAR,j,3,MPI_COMM_WORLD);
    }
    

    Where broadcast_message=128(random number just to know when I'm receiving, that this was a broadcast message )

    Message is defined as char[20].

    else if (i have to send only to a node) {
        MPI_Send(&destination,1,MPI_INT,next_hop[destination],3,MPI_COMM_WORLD);
        MPI_Send(&message,20, MPI_CHAR, next_hop[destination],3,MPI_COMM_WORLD);
    }
    

    When I'm receiving I first check if recv_payload is 128 (broadcast value) or other value:

    MPI_Recv(&recv_material,1,MPI_INT,MPI_ANY_SOURCE,3,MPI_COMM_WORLD,&status2);
    

    If is it 128, then:

    MPI_Recv(&message,20,MPI_CHAR,from_d,3,MPI_COMM_WORLD,&status2);
    

    and I'm forwarding the message to all the processes

    MPI_Send(&message,20,MPI_CHAR,j,3,MPI_COMM_WORLD);
    

    If it's not 128, I'm checking if i am the destination :

    if(recv_material == rank)
        MPI_Recv(&mesaj,20,MPI_CHAR,from_d,3,MPI_COMM_WORLD,&status2);
    

    Else, I'm sending on nexthop[recv_material]

    MPI_Send(&mesaj,20,MPI_CHAR,next_hop[recv_material],3,MPI_COMM_WORLD);
    

    The problem is that i get the following error and I don't know why :

    Fatal error in MPI_Recv: Message truncated, error stack:
    MPI_Recv(186).....................: MPI_Recv(buf=0x7fffbce8f2a4, count=1, MPI_INT
    src=MPI_ANY_SOURCE, tag=3, MPI_COMM_WORLD, status=0x7fffbce8f250) failed
    MPIDI_CH3U_Receive_data_found(129): Message from rank 7 and tag 3 truncated;
    20 bytes   received but buffer size is 4
    
  • Matei
    Matei over 10 years
    I can't really post my actual code because this is a homework.
  • Wesley Bland
    Wesley Bland over 10 years
    Sorry. Without more info it's going to be hard to fix this.