Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Create group in a non-collective way
From: Yiannis Papadopoulos (giannis.papadopoulos_at_[hidden])
Date: 2010-01-31 13:41:38


Hi,

In my code I need to specify for some processes to create a group.
Now, in general the way of doing that is (correct me if I'm wrong):

int ranks[] = { 1,2,3 };
int rank;
MPI_Group world_group = MPI_GROUP_NULL;
MPI_Group subgroup = MPI_GROUP_NULL;
MPI_Comm subcomm = MPI_COMM_NULL;

MPI_Comm_rank(MPI_COMM_WORLD, &rank); // local operation
MPI_Comm_group(MPI_COMM_WORLD, &world_group); // local operation
MPI_Group_incl(world_group, 3, ranks, &subgroup); // local operation
MPI_Comm_create(MPI_COMM_WORLD, subgroup, &subcomm); // collective
operation on MPI_COMM_WORLD

if (rank>0 rank<4) {
  // do something with subcomm
}

// cleanup

Is there any way to create the communicator inside the if?

Thanks