Closed drodarie closed 4 weeks ago
As a more general question: Shall we create an option to force bsb not to use MPI ? In the cases the user wants only to load the bsb circuit in a MPI context: e.g. to be the used as robot controller.
The BSB already accepts an MPI COMM object that it will use. You can split off an MPI COMM with only that rank in it, and then that rank will communicate only with itself :) This is the most generic solution possible and lets the user set up as many different communication pools as they want inside the MPI world. The feature should be tested (I'm 100% sure it's broken), and you should double check if it is respected everywhere, and propagates to the storage and pool.
IN THEORY, this should work:
world = mpi4py.MPI.COMM_WORLD
excl_not_self = [i != world.Get_rank() for i in range(world.Get_size())]
group = world.Excl(excl_not_self)
comm = world.Create(group)
if world.Get_rank() == 0:
network = Scaffold(config, storage, comm)
This should create a communicator that only contains itself on each rank of your mpi world.
But again the entire codebase should be audited for references to the global MPI communicator instead of the current Scaffold.comm instance.
There are likely going to be several cases that should use the Scaffold comm, but don't have access to the current Scaffold. For those cases it might be the right time to introduce a context pattern to access the current Scaffold.
Running the following python script with MPI (at least 2 cores):
The script gets stuck. Bsb seems to be waiting for every MPI core to be ready.