如何正确完成 python MPI 脚本?

问题描述 投票:0回答:0

我正在使用 mpi4py 编写 python 代码,除非我手动取消作业,否则它不会完成。我的代码是这样的:

from mpi4py import MPI
if __name__ == "__main__":
    comm = MPI.COMM_WORLD
    size = MPI.COMM_WORLD.Get_size()
    rank = MPI.COMM_WORLD.Get_rank()
    if (rank == 0):
        print("MPI WORLD SIZE: ", size)
        res = fun()
        # print out results
        print(res)
        MPI.Finalize()
        exit(0)
    else :
        fun_worker(rank)

结果已打印,但脚本未完成执行。

python mpi mpi4py
© www.soinside.com 2019 - 2024. All rights reserved.