When mpi4py is imported before h.nrnmpi_init() is called, all nodes think they are node 0.
This might be because mpi4py calls MPI.Init() and MPI.Init_thread if MPI hasn't been initialized at that point.
Reproducers
nrnmpi_init first (IDs OK)
from neuron import h
h.nrnmpi_init()
pc = h.ParallelContext()
from mpi4py import MPI
print("I am MPI rank", MPI.COMM_WORLD.rank, "but have ParallelContext ID", pc.id())
h.quit()
MPI Init first (IDs not OK)
from neuron import h
from mpi4py import MPI
h.nrnmpi_init()
pc = h.ParallelContext()
print("I am MPI rank", MPI.COMM_WORLD.rank, "but have ParallelContext ID", pc.id())
h.quit()
When
mpi4pyis imported beforeh.nrnmpi_init()is called, all nodes think they are node 0.This might be because mpi4py calls
MPI.Init()andMPI.Init_threadif MPI hasn't been initialized at that point.Reproducers
nrnmpi_init first (IDs OK)
MPI Init first (IDs not OK)