MPI发送RECV输入参数

MPI send recv input arguments

本文关键字:参数 输入 RECV 发送 MPI      更新时间:2023-10-16

我对代码的这一部分有一些问题(我将其更清楚地清楚)。

//p is the number of processor (we suppose 2)
//vett is the vector who contains the elements to send
//disp is a vector whose elements are the index of the first element to send
//elem is a vector whose elements are the number of elements to send
//local_v is the destination vector (of dimension elem[rank])
//local_n is the number of elements that have to arrive (=elem[rank])

在我的情况下,周期仅执行一次

for(unsigned int i = 1; i < p; i++){
    if(rank==0){
        MPI_Send(&vett[disp[i]], elem[i], MPI_INT, i, 0, MPI_COMM_WORLD);
    }else{
        MPI_Recv(&local_v, local_n, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
    }
}

processor1发送到另一个(在这种情况下,仅处理器2)。我不确定我是否正确使用mpi_send,特别是我不确定第一个输入参数是否正确...

在接收缓冲区后,MPI_Recv中缺少[0],这是整个行:

MPI_Recv(&local_v[0], local_n, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);