各ノードに 16 個のプロセッサがあるクラスターで作業しています。私の Open MPI のバージョンは 1.5.3 です。Fortran で次の簡単なコードを書きました。
program MAIN
implicit none
include 'mpif.h'
integer status(MPI_STATUS_SIZE)
integer ierr,my_rank,size
integer irep, nrep, iex
character*1 task
!Initialize MPI
call mpi_init(ierr)
call mpi_comm_rank(MPI_COMM_WORLD,my_rank,ierr)
call mpi_comm_size(MPI_COMM_WORLD,size,ierr)
do iex=1,2
if(my_rank.eq.0) then
!Task for the master
nrep = size
do irep=1,nrep-1
task='q'
print *, 'master',iex,task
call mpi_send(task,1,MPI_BYTE,irep,irep+1,
& MPI_COMM_WORLD,ierr)
enddo
else
!Here are the tasks for the slaves
!Receive the task sent by the master node
call mpi_recv(task,1,MPI_BYTE,0,my_rank+1,
& MPI_COMM_WORLD,status,ierr)
print *, 'slaves', my_rank,task
endif
enddo
call mpi_finalize(ierr)
end
次に、コードを次のようにコンパイルします。
/usr/lib64/openmpi/bin/mpif77 -o test2 test2.f
そしてそれを実行します
/usr/lib64/openmpi/bin/mpirun -np 32 -hostfile nodefile test2
私のノードファイルは次のようになります。
node1
node1
...
node2
node2
...
node1 と node2 をそれぞれ 16 回繰り返します。
正常にコンパイルできます。-np 16 (ノードが 1 つだけ) で実行すると、正常に動作します。各スレーブがタスクを終了し、ターミナルにプロンプトが返されます。しかし、-np 32 を試すと、すべてのスレーブが作業を終了するわけではなく、16 個だけです。
実際には 32 ノードの場合、プログラムからプロンプトが返されないため、プログラムがどこかにスタックされ、何らかのタスクが実行されるのを待っていると思います。
この些細な問題に時間を費やした限り、コメントをお待ちしています。
ありがとう。