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