X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/45c3f1cfee86fb48c96d53f8267f99b6db6e3d7a..290e19f26b10dc49485d7d7b06859edff32fd1e1:/src/smpi/smpi_group.c diff --git a/src/smpi/smpi_group.c b/src/smpi/smpi_group.c index 587ab1df5e..e9ab955515 100644 --- a/src/smpi/smpi_group.c +++ b/src/smpi/smpi_group.c @@ -30,7 +30,7 @@ MPI_Group smpi_group_new(int size) MPI_Group group; int i, count; - count = smpi_process_count(); + count = SIMIX_process_count(); group = xbt_new(s_smpi_mpi_group_t, 1); group->size = size; group->rank_to_index_map = xbt_new(int, size); @@ -84,7 +84,7 @@ void smpi_group_destroy(MPI_Group group) void smpi_group_set_mapping(MPI_Group group, int index, int rank) { - if (rank < group->size && index < smpi_process_count()) { + if (rank < group->size && index < SIMIX_process_count()) { group->rank_to_index_map[rank] = index; if(index!=MPI_UNDEFINED)group->index_to_rank_map[index] = rank; } @@ -103,10 +103,7 @@ int smpi_group_index(MPI_Group group, int rank) int smpi_group_rank(MPI_Group group, int index) { int rank = MPI_UNDEFINED; - - if (index < smpi_process_count()) { - rank = group->index_to_rank_map[index]; - } + rank = group->index_to_rank_map[index]; return rank; } @@ -158,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; +}