2014-01-31 90 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);