From: Augustin Degomme Date: Fri, 1 Aug 2014 07:36:29 +0000 (+0200) Subject: Move group_incl code, to allow use by collective algos or internal calls X-Git-Tag: v3_12~874 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9b09b6c6cb6a092b83bb385d071d447137aac5de Move group_incl code, to allow use by collective algos or internal calls --- diff --git a/src/smpi/private.h b/src/smpi/private.h index 4b3b5f7732..b89aa3baa4 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -232,6 +232,8 @@ int smpi_group_use(MPI_Group group); int smpi_group_unuse(MPI_Group group); int smpi_group_size(MPI_Group group); int smpi_group_compare(MPI_Group group1, MPI_Group group2); +int smpi_group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup); + MPI_Topology smpi_comm_topo(MPI_Comm comm); MPI_Comm smpi_comm_new(MPI_Group group, MPI_Topology topo); diff --git a/src/smpi/smpi_group.c b/src/smpi/smpi_group.c index 921f71910e..e9ab955515 100644 --- a/src/smpi/smpi_group.c +++ b/src/smpi/smpi_group.c @@ -155,3 +155,25 @@ int smpi_group_compare(MPI_Group group1, MPI_Group group2) } return result; } + +int smpi_group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup) +{ + int i=0, index=0; + if (n == 0) { + *newgroup = MPI_GROUP_EMPTY; + } else if (n == smpi_group_size(group)) { + *newgroup = group; + if(group!= smpi_comm_group(MPI_COMM_WORLD) + && group != MPI_GROUP_NULL + && group != smpi_comm_group(MPI_COMM_SELF) + && group != MPI_GROUP_EMPTY) + smpi_group_use(group); + } else { + *newgroup = smpi_group_new(n); + for (i = 0; i < n; i++) { + index = smpi_group_index(group, ranks[i]); + smpi_group_set_mapping(*newgroup, index, i); + } + } + return MPI_SUCCESS; +} diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index d6c2616394..9a52cc9aa4 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -478,30 +478,14 @@ int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgro int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) { - int retval, i, index; + int retval; if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; } else if (newgroup == NULL) { retval = MPI_ERR_ARG; } else { - if (n == 0) { - *newgroup = MPI_GROUP_EMPTY; - } else if (n == smpi_group_size(group)) { - *newgroup = group; - if(group!= smpi_comm_group(MPI_COMM_WORLD) - && group != MPI_GROUP_NULL - && group != smpi_comm_group(MPI_COMM_SELF) - && group != MPI_GROUP_EMPTY) - smpi_group_use(group); - } else { - *newgroup = smpi_group_new(n); - for (i = 0; i < n; i++) { - index = smpi_group_index(group, ranks[i]); - smpi_group_set_mapping(*newgroup, index, i); - } - } - retval = MPI_SUCCESS; + retval = smpi_group_incl(group, n, ranks, newgroup); } return retval; }