2014-01-31 62 views
-1

我有这部分代码的一些问题(我把它放在更清晰的地方)。MPI发送recv输入参数

//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); 
    } 
} 

处理器1发送到其他(在这种情况下,仅processor2)。我不知道如果我使用正确MPI_SEND,特别是我不知道的是,第一个输入参数是正确的......

+0

我找到了答案,以我自己的问题......在'MPI_Recv'缺少'[0]'接收缓冲器后,这是整个行:'MPI_RECV(local_v [0],local_n,MPI_INT,0,0, MPI_COMM_WORLD,MPI_STATUS_IGNORE);' – Wellen

+0

如果这确实是您的问题的答案,您应该将其作为答案发布,然后将其标记为正确(我认为最后一部分有一个等待期)。 –

回答

-1

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

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