I’ve got a very strange bug while using MPI. A successfully created communicator can’t be deleted. A deleting attempt results in FATAL ERROR on all nodes except the ones that are included in communicator group. The minimal working example is below. What do you think about the reason of such strange behaviour?
#include <stdio.h>
#include <mpi.h>
int main(int argc, char* argv[])
{
MPI_Group group_world; // group of MPI_COMM_WORLD
MPI_Group group_new; // new group
MPI_Comm comm_new; // new communicator
int group_new_ranks[3]={10,20,30}; // new communicator's ranks
MPI_Init(&argc, &argv);
MPI_Comm_group(MPI_COMM_WORLD, &group_world); // get group_world - MPI_SUCCESS for all nodes
MPI_Group_incl(group_world, 3, group_new_ranks, &group_new); // get new group - MPI_SUCCESS for all nodes
MPI_Comm_create(MPI_COMM_WORLD, group_new, &comm_new); // create new communicator - MPI_SUCCESS for all nodes
MPI_Comm_free(&comm_new); // FATAL ERROR for all nodes except 10, 20, 30
MPI_Group_free(&group_new);
MPI_Group_free(&group_world);
MPI_Finalize();
return 0;
}
MPI_Comm_create()returnsMPI_COMM_NULLto all processes not within the group. You’re passingMPI_COMM_NULLtoMPI_Comm_free(), which is not allowed.