0
我在fortran中使用MPI來計算我的數據。我通過打印數據證實,每個進程的計算正在按期望的頻率進行,但是,主機無法整理數據。MPI master無法接收
這裏是我試圖使其工作代碼: 編輯:創建一個標籤,它是用於發送和recv
integer :: tag
tag = 123
if(pid.ne.0) then
print *,'pid: ',pid,'sending'
DO j = start_index+1, end_index
CALL MPI_SEND(datapacket(j),1, MPI_REAL,0, tag, MPI_COMM_WORLD)
!print *,'sending'
END DO
print *,'send complete'
else
DO slave_id = 1, npe-1
rec_start_index = slave_id*population_size+1
rec_end_index = (slave_id + 1) * population_size;
IF (slave_id == npe-1) THEN
rec_end_index = total-1;
ENDIF
print *,'received 1',rec_start_index,rec_end_index
CALL MPI_RECV(datapacket(j),1,MPI_REAL,slave_id,tag,MPI_COMM_WORLD, &
& status)
!print *,'received 2',rec_start_index,rec_end_index
END DO
它從來沒有打印received
或之後任何事情MPI_RECV
電話,但不斷,我可以看到發送的情況很好,但除了依賴打印語句之外,沒有辦法驗證它。
real, dimension (:), allocatable :: datapacket
有沒有辦法,我做錯了什麼事: 變量databpacket
如下初始化?
編輯:對於測試設置所有的進程正在本地主機上運行。
謝謝,我會記MPI_gather,稍後再試吧。在curent上下文中發送和接收一個常量標籤並沒有幫助。我編輯了我目前的實施。 – Trancey
我更新了我的答案,並試圖想出一些東西,我想你正在努力實現。不過,我強烈建議你查閱MPI_Gather/MPI_Gatherv。 – haraldkl