映画のフレームを作成するために、いくつかのコードを並列化しました。終了条件に達したにもかかわらず、最終フレームを作成するランクを除いて、すべてのランクが while ループを終了します。また、while ループの後に CW.Barrier() を追加すると、最終フレームのみが作成されることがわかりました。それが存在しない場合は、最後から 2 番目のフレームで停止します。
rank = CW.Get_rank()
size = CW.Get_size()
rit = 0 #rank iterator. Its used to assign frames to make
while len(frames) > 0:
if rank == rit:
frame_val = frames.pop() #gets frame
orit = 0
while orit < size:
if orit != rit:
CW.send(frames, dest=orit, tag=1) #and then sends undated frame list to other ranks
orit = orit + 1
#other ranks recieve new list of frames.
if rank != rit:
frames = CW.recv(source=rit, tag=1)
if rank == rit:
#Creates frame
print 'Created frame', frame_val, 'on rank', rank
#iterates through ranks to distribute frames.
rit = rit +1
if rit == size:
rit = 0
CW.Barrier()
print "completed making movie frames on rank", rank