0

我已经并行化了一些代码来制作电影的帧。所有排名都退出 while 循环,除了创建最后一帧的那一个,尽管它达到了结束条件。我还发现,如果我在 while 循环之后添加 CW.Barrier(),它只会生成最后一帧。如果那不存在,那么它会停在倒数第二帧。

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
4

1 回答 1

0

Derp,所以我没有在我的问题中提供足够的信息。在里面

if rank == rit: #Creates frame print 'Created frame', frame_val, 'on rank', rank

它实际上看起来更像:

if rank == rit: CW.Barrier() #Creates frame print 'Created frame', frame_val, 'on rank', rank

因为在某些等级上,while 查找已经退出,并不是所有等级都在最后一帧到达这个 CW.Barrier() 函数。这个结界其实在这个地方根本不需要,所以它固定了!

于 2016-02-02T03:31:49.617 回答