From 3a36fb030b9ba08f2f866cadfa35e2387d620f50 Mon Sep 17 00:00:00 2001 From: Rich Graham Date: Fri, 13 Feb 2004 19:59:34 +0000 Subject: [PATCH] implement mpi_group_incl This commit was SVN r789. --- src/include/lam_config_bottom.h | 3 ++ src/mpi/interface/c/group_incl.c | 62 ++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/include/lam_config_bottom.h b/src/include/lam_config_bottom.h index 957802f13e..c8991a187f 100644 --- a/src/include/lam_config_bottom.h +++ b/src/include/lam_config_bottom.h @@ -38,6 +38,9 @@ typedef enum { false, true } bool; */ #define LAM_HAVE_THREADS (LAM_HAVE_SOLARIS_THREADS || LAM_HAVE_POSIX_THREADS) +/* parameter indicating if to check MPI arguments */ +extern bool lam_mpi_param_check; + /* * Do we have ? */ diff --git a/src/mpi/interface/c/group_incl.c b/src/mpi/interface/c/group_incl.c index e3edb8e85e..4733412dd4 100644 --- a/src/mpi/interface/c/group_incl.c +++ b/src/mpi/interface/c/group_incl.c @@ -6,12 +6,70 @@ #include "mpi.h" #include "mpi/interface/c/bindings.h" +#include "mpi/group/group.h" #if LAM_HAVE_WEAK_SYMBOLS && LAM_PROFILING_DEFINES #pragma weak MPI_Group_incl = PMPI_Group_incl #endif -int MPI_Group_incl(MPI_Group group, int n, int *ranks, - MPI_Group *newgroup) { +int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *new_group) +{ + /* local variables */ + int return_value,proc,cnt; + lam_group_t *group_pointer, *new_group_pointer; + + return_value = MPI_SUCCESS; + group_pointer = (lam_group_t *)group; + + if( MPI_PARAM_CHECK ) { + /* including anything of the empty group is still the empty group */ + if ((group == MPI_GROUP_EMPTY) || (ranks == 0)) { + *new_group = MPI_GROUP_EMPTY; + return return_value; + } + + /* verify that group is valid group */ + if ( NULL == group ) { + return MPI_ERR_GROUP; + } + + /* check that new group is no larger than old group */ + if (ranks > group_pointer->grp_proc_count) { + return MPI_ERR_RANK; + } + + } /* end if( MPI_CHECK_ARGS) */ + + + /* get new group struct */ + new_group_pointer=group_allocate(n); + if( NULL == new_group_pointer ) { + return MPI_ERR_GROUP; + } + + /* put group elements in the list */ + for (proc = 0; proc < n; proc++) { + if ((ranks[proc] < 0) || + (ranks[proc] >= group_pointer->grp_proc_count)){ + return MPI_ERR_RANK; + } + + new_group_pointer->grp_proc_pointers[proc] = + group_pointer->grp_proc_pointers[ranks[proc]]; + + } /* end proc loop */ + + /* find my rank */ + new_group_pointer->grp_my_rank = MPI_PROC_NULL; + if( MPI_PROC_NULL != group_pointer->grp_my_rank) { + for ( proc=0 ; proc < n ; proc++ ){ + if( new_group_pointer->grp_proc_pointers[proc] == + group_pointer->grp_proc_pointers + [group_pointer->grp_my_rank]){ + new_group_pointer->grp_my_rank = proc; + } + } + } + return MPI_SUCCESS; }