X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c1cfbb3b4083ee7f234f2977ce8c5e3e61f1c1ec..91bb8b44ef09735fc79f40a3d9eeb69456a46909:/src/smpi/smpi_comm.c diff --git a/src/smpi/smpi_comm.c b/src/smpi/smpi_comm.c index 8e2b9564c7..8f02e2e0ae 100644 --- a/src/smpi/smpi_comm.c +++ b/src/smpi/smpi_comm.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2010. The SimGrid Team. +/* Copyright (c) 2010-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -131,6 +131,7 @@ MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key) group_root = group_out; /* Save root's group */ } for(j = 0; j < count; j++) { + //increment refcounter in order to avoid freeing the group too quick before copy index = smpi_group_index(group, rankmap[2 * j]); smpi_group_set_mapping(group_out, index, j); } @@ -151,20 +152,20 @@ MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key) } else { if(color != MPI_UNDEFINED) { smpi_mpi_recv(&group_out, 1, MPI_PTR, 0, system_tag, comm, MPI_STATUS_IGNORE); + if(group_out){ + group_out=smpi_group_copy(group_out); + } } /* otherwise, exit with group_out == NULL */ } - if(group_out)smpi_group_use(group_out); return group_out ? smpi_comm_new(group_out) : MPI_COMM_NULL; } void smpi_comm_use(MPI_Comm comm){ comm->refcount++; - smpi_group_use(comm->group); } void smpi_comm_unuse(MPI_Comm comm){ comm->refcount--; - smpi_group_unuse(comm->group); if(comm->refcount==0) xbt_free(comm); }