root/ompi/mpi/c/group_excl.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Group_excl

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2006      University of Houston. All rights reserved.
  14  * Copyright (c) 2006-2009 Cisco Systems, Inc.  All rights reserved.
  15  * Copyright (c) 2012-2013 Los Alamos Nat Security, LLC. All rights reserved.
  16  * Copyright (c) 2015      Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 #include "ompi_config.h"
  25 #include <stdio.h>
  26 
  27 #include "ompi/mpi/c/bindings.h"
  28 #include "ompi/runtime/params.h"
  29 #include "ompi/group/group.h"
  30 #include "ompi/errhandler/errhandler.h"
  31 #include "ompi/communicator/communicator.h"
  32 
  33 #if OMPI_BUILD_MPI_PROFILING
  34 #if OPAL_HAVE_WEAK_SYMBOLS
  35 #pragma weak MPI_Group_excl = PMPI_Group_excl
  36 #endif
  37 #define MPI_Group_excl PMPI_Group_excl
  38 #endif
  39 
  40 static const char FUNC_NAME[] = "MPI_Group_excl";
  41 
  42 
  43 int MPI_Group_excl(MPI_Group group, int n, const int ranks[],
  44                    MPI_Group *new_group)
  45 {
  46     ompi_group_t *group_pointer = (ompi_group_t *)group;
  47     int i, err, group_size;
  48 
  49     group_size = ompi_group_size ( group_pointer);
  50     if( MPI_PARAM_CHECK ) {
  51         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  52 
  53         /* verify that group is valid group */
  54         if ( (MPI_GROUP_NULL == group)  || (NULL == group) ||
  55              (NULL == new_group) ) {
  56             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
  57                                           FUNC_NAME);
  58         } else if (NULL == ranks && n > 0) {
  59             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  60                                           FUNC_NAME);
  61         }
  62 
  63         /* check that new group is no larger than old group */
  64         if ( n > group_size) {
  65             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_GROUP,
  66                                           FUNC_NAME);
  67         }
  68 
  69         /* check to see if procs are within range */
  70         for( i=0 ; i  < n ; i++ ) {
  71             if( ( 0 > ranks[i] ) || (ranks[i] >= group_size)){
  72                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_RANK,
  73                                               FUNC_NAME );
  74             }
  75         }
  76 
  77     }  /* end if( MPI_PARAM_CHECK ) */
  78 
  79     if ( n == group_size ) {
  80         *new_group = MPI_GROUP_EMPTY;
  81         OBJ_RETAIN(MPI_GROUP_EMPTY);
  82         return MPI_SUCCESS;
  83     }
  84 
  85     OPAL_CR_ENTER_LIBRARY();
  86 
  87     err = ompi_group_excl ( group, n, ranks, new_group );
  88     OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME );
  89 }

/* [<][>][^][v][top][bottom][index][help] */