Search code examples
pythonmpi4pycommunicator

mpi4py - Get process's own communicator


We are currently working on an mpi4py project where we want to group processes in different groups. We then assign these groups to their own communicators. Theses steps are done by the process 0.

Now the question is how can the other processes find out what communicator they belong to?

Please note that the groups are of different sizes, e.g. group one contains 5 processes and group two 3 ones. So, how can process 4 (in group one) get the communicator from group one.


Solution

  • We solved the issue by simply letting every process do the same initialisation, i.e. every process creates every group and communicator and assigns the processes to these groups according to the same schema. This way, the processes know their corresponding communicators.

    Interestingly we found out, that, although every process creates all the groups and communicators, they only know the communicators (and groups) they belong to. If, for instance, process 4, which belongs to communicator 1 but not 2, wants to use the communicator 2, it will crash. According to the error message, this is due because it does not know the communicator, although it initialised it at the beginning.