マスタープロセスでしか実行できない操作を実行する必要があります。スレーブは実際には何もできませんが、マスターが終了するのを待ちます。したがって、私は次のことを行いました(擬似コード、ほとんどのルーチンをラップするため、実際のMPIコードを思い付くのに苦労します。コメントが私が行っていることを説明するのに十分明確であることを願っています)
def routine():
if not isMaster():
# I am a slave. I just sit here, waiting for the master to finish.
# wait for a string from the master explaining the state
string = MPI_Bcast("whatever", 0)
return (string == "SUCCESS")
<master does its long running business>
string = MPI_Bcast("SUCCESS", 0) # tell the slaves it worked fine.
return True
これは機能しますか、それとも私は放送を誤用していますか?