在我的应用程序中,所有处理器都必须发送和接收。为了计算单个链路的带宽,我使用MPI_Send和MPI_Recv。 (不要使用MPI广播) 我的问题是,我为同一链接获得不同的带宽。就像进程0向1发送一些数据时,带宽是不同的,反之亦然。必须相同。我在这里发布代码。请帮助我为什么同一链接获得不同的带宽?
if (comm_rank==source){
for (int i = 0; i < comm_size; i++) {
if (i != comm_rank) {
// Start time for A send
start_send = MPI_Wtime();
//Send data to other processors that don't own the sub-partition
rc =MPI_Send(tmp, elem_num, MPI_DOUBLE, i, 0, comm);
rc= MPI_Recv(&recv_ack, 1, MPI_INT,i , 5, comm,&status);
// End time for A send;
end_send = MPI_Wtime();
//A send bandwidth calculation in Mb/sec
double bandwidth_send= (elem_num * sizeof(double)*1.0e-6*8)/(end_send-start_send);
if (print_communication_times_to_file) {
fprintf(dofp, "<--COMM-->: Rank[%d]: A communications(Send),(%d,%d)[%d] --> (%d,* [%d] = (%d elements)" " at index Local A(%d,%d), %f seconds, bandwidth= %8.2f\n", rank, blocki, blockj, rank,blocki,comm_world[i], elem_num, A_elem_i_local, A_elem_j_local,(end_send - start_send),bandwidth_send);
fflush(dofp);
}
}
}
}else {
// Start time for A receive
start_recv = MPI_Wtime();
rc= MPI_Recv(tmp, elem_num, MPI_DOUBLE, source, 0, comm,&status);
// End time for A receive
end_recv = MPI_Wtime();
if (rc == MPI_SUCCESS) {
recv_ack=1;
rc =MPI_Send(&recv_ack, 1, MPI_INT, source, 5, comm);}