这是我的代码:
from mpi4py import MPI
comm = MPI.COMM_WORLD
world_size = comm.Get_size()
world_rank = comm.Get_rank()
processor_name = MPI.Get_processor_name()
print("MPI Hello World Program")
print("Processor Name:", processor_name)
print("Processor Rank:", world_rank)
print("World Size:", world_size)
MPI.Finalize()
我的输出是:
MPI Hello World Program
Processor Name: joshua
Processor Rank: 0
World Size: 1
如果我没记错,(如果我记错了,请纠正我)此程序打印的次数不应与计算机的内核数相同吗?我的macbook pro有2个核心,当我尝试在终端中执行此程序时,出现如下错误:
Fatal error in MPI_Init_thread: Other MPI error, error stack:
MPIR_Init_thread(565)..............:
MPID_Init(224).....................: channel initialization failed
MPIDI_CH3_Init(105)................:
MPID_nem_init(324).................:
MPID_nem_tcp_init(178).............:
MPID_nem_tcp_get_business_card(425):
MPID_nem_tcp_init(384).............: gethostbyname failed, joshua (errno 1)
关于为什么它不起作用的任何想法?