sw/lib/mpi/mpi_comm.c
// create a new communicator and copy the group list, if the current process is a member of it
create a new communicator and copy the group list, if the current process is a member of it
create a new communicator and copy the group list if the current process is a member of it
int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *new)
{
    assert(group!=_MPI_GROUP_WORLD && group!=MPI_GROUP_EMPTY && group!=MPI_GROUP_NULL);
    int rank;
    MPI_Group_rank(group, &rank);
    if (rank==MPI_UNDEFINED) {
        *new = MPI_COMM_NULL; 
        return MPI_SUCCESS;
    }
    MPI_Comm c = malloc(sizeof(mpi_communicator_t) + 2*group->size - 2); 
    c->rank = rank;
    memcpy(&c->group, group, 2*group->size+2); 
    *new = c;
    return MPI_SUCCESS;
}
int MPI_Comm_create ( MPI_Comm comm , MPI_Group group , MPI_Comm * new ) { assert ( group != _MPI_GROUP_WORLD && group != MPI_GROUP_EMPTY && group != MPI_GROUP_NULL ) ; int rank ; MPI_Group_rank ( group , & rank ) ; if ( rank == MPI_UNDEFINED ) { * new = MPI_COMM_NULL ; return MPI_SUCCESS ; } MPI_Comm c = malloc ( sizeof ( mpi_communicator_t ) + 2 * group -> size - 2 ) ; c -> rank = rank ; memcpy ( & c -> group , group , 2 * group -> size + 2 ) ; * new = c ; return MPI_SUCCESS ; }
create a new communicator and copy the group list, if the current process is a member of it
create a new communicator and copy the group list if the current process is a member of it
// search rank in group // this process is not in the group // hardcoded! // hardcoded!