2004-01-25 01:51:49 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-10-15 19:31:47 +00:00
|
|
|
* $HEADER$
|
2004-01-25 01:51:49 +00:00
|
|
|
*/
|
2004-06-07 15:33:53 +00:00
|
|
|
#include "ompi_config.h"
|
2004-01-25 01:51:49 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "mpi/c/bindings.h"
|
2005-09-12 09:17:44 +00:00
|
|
|
#include "ompi/group/group.h"
|
|
|
|
#include "ompi/errhandler/errhandler.h"
|
|
|
|
#include "ompi/communicator/communicator.h"
|
|
|
|
#include "ompi/proc/proc.h"
|
2004-01-25 01:51:49 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
|
2004-01-25 01:51:49 +00:00
|
|
|
#pragma weak MPI_Group_incl = PMPI_Group_incl
|
|
|
|
#endif
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
#if OMPI_PROFILING_DEFINES
|
2004-04-20 18:50:43 +00:00
|
|
|
#include "mpi/c/profile/defines.h"
|
|
|
|
#endif
|
|
|
|
|
2004-07-30 02:58:53 +00:00
|
|
|
static const char FUNC_NAME[] = "MPI_Group_incl";
|
2004-06-22 20:21:35 +00:00
|
|
|
|
|
|
|
|
2004-02-13 19:59:34 +00:00
|
|
|
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *new_group)
|
|
|
|
{
|
|
|
|
/* local variables */
|
2004-03-22 21:42:12 +00:00
|
|
|
int proc,my_group_rank;
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_group_t *group_pointer, *new_group_pointer;
|
|
|
|
ompi_proc_t *my_proc_pointer;
|
2004-02-13 19:59:34 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
group_pointer = (ompi_group_t *)group;
|
2004-02-13 19:59:34 +00:00
|
|
|
|
|
|
|
if( MPI_PARAM_CHECK ) {
|
2004-06-22 20:21:35 +00:00
|
|
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
2004-02-13 19:59:34 +00:00
|
|
|
|
|
|
|
/* verify that group is valid group */
|
2004-03-22 21:42:12 +00:00
|
|
|
if ( (MPI_GROUP_NULL == group) || ( NULL == group)
|
|
|
|
|| NULL == ranks ) {
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
2004-06-22 20:21:35 +00:00
|
|
|
FUNC_NAME);
|
2004-02-13 19:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check that new group is no larger than old group */
|
2004-02-13 22:18:38 +00:00
|
|
|
if ( n > group_pointer->grp_proc_count) {
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
2004-06-22 20:21:35 +00:00
|
|
|
FUNC_NAME);
|
2004-02-13 19:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* end if( MPI_CHECK_ARGS) */
|
|
|
|
|
|
|
|
|
2004-08-05 22:51:34 +00:00
|
|
|
if ( 0 == n ) {
|
|
|
|
*new_group = MPI_GROUP_EMPTY;
|
|
|
|
OBJ_RETAIN(MPI_GROUP_EMPTY);
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-02-13 19:59:34 +00:00
|
|
|
/* get new group struct */
|
2004-06-07 15:33:53 +00:00
|
|
|
new_group_pointer=ompi_group_allocate(n);
|
2004-02-13 19:59:34 +00:00
|
|
|
if( NULL == new_group_pointer ) {
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
|
2004-06-22 20:21:35 +00:00
|
|
|
FUNC_NAME);
|
2004-02-13 19:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* put group elements in the list */
|
|
|
|
for (proc = 0; proc < n; proc++) {
|
|
|
|
if ((ranks[proc] < 0) ||
|
|
|
|
(ranks[proc] >= group_pointer->grp_proc_count)){
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
|
2004-06-22 20:21:35 +00:00
|
|
|
FUNC_NAME);
|
2004-02-13 19:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
new_group_pointer->grp_proc_pointers[proc] =
|
|
|
|
group_pointer->grp_proc_pointers[ranks[proc]];
|
|
|
|
|
|
|
|
} /* end proc loop */
|
|
|
|
|
2004-03-16 01:18:47 +00:00
|
|
|
/* increment proc reference counters */
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_group_increment_proc_count(new_group_pointer);
|
2004-03-16 01:18:47 +00:00
|
|
|
|
2004-02-13 19:59:34 +00:00
|
|
|
/* find my rank */
|
2004-03-16 01:18:47 +00:00
|
|
|
my_group_rank=group_pointer->grp_my_rank;
|
|
|
|
my_proc_pointer=group_pointer->grp_proc_pointers[my_group_rank];
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_set_group_rank(new_group_pointer,my_proc_pointer);
|
2004-02-13 19:59:34 +00:00
|
|
|
|
2004-02-13 22:18:38 +00:00
|
|
|
*new_group = (MPI_Group)new_group_pointer;
|
|
|
|
|
2004-01-25 01:51:49 +00:00
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|