0
votes

Some folks and me are trying to make a simulation of an amusement park and we have almost everything done except one thing: we need to implement a barrier for sync but we need a comunicator fot that, and it needs to encompass evey process except the one with rank zero. I'm using MPI_Group_excl() to tell that a group should not have process zero. Here is a fragment of my code that creates the group and the comunicator:

MPI_Group nonzero_group, world;
MPI_Comm_group(MPI_COMM_WORLD,&world);
int zero[1];
zero[0]=0;
MPI_Group_excl(world,1,zero,&nonzero_group);
MPI_Comm nonzero;
MPI_Comm_create(MPI_COMM_WORLD,world,&nonzero);

But when I test my program using a MPI_Bcast() from process 1 to all process in 'nonzero' communicator, process zero performs the broadcast and gets the buffer.

How can I make a group that has all proces from 1 to N without process zero?

1

1 Answers

2
votes

That can be achieved with MPI_Comm_split()

int world_rank;
MPI_Comm comm;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_split(MPI_COMM_WORLD, (0 == rank)?MPI_UNDEFINED:0, 0, &comm);

on MPI_COMM_WORLD rank 0, comm is MPI_COMM_NULL. It is the valid communicator you expect on the other ranks.