References:
Like the communicator routines, the group routines are methods of the objects, but they can also be called statically (MPI.Group) by passing the object as a parameter.
A communicator's group can be easily accessed through the group attribute, as shown below:
from mpi4py import MPI
comm = MPI.COMM_WORLD
worldGroup = comm.group
But it can also be accessed through the Get_group method:
from mpi4py import MPI
comm = MPI.COMM_WORLD
worldGroup = comm.Get_group()
The group size can be accessed through the size attribute, as shown below:
from mpi4py import MPI
comm = MPI.COMM_WORLD
worldGroup = comm.group
groupSize = worldGroup.size
print(groupSize)
But it can also be accessed through the Get_size method:
from mpi4py import MPI
comm = MPI.COMM_WORLD
worldGroup = comm.group
groupSize = worldGroup.Get_size()
print(groupSize)
Output (for both cases):
It works the same way as standard MPI.