root/ompi/mpi/c/dist_graph_create_adjacent.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Dist_graph_create_adjacent

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2008      The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2011-2018 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
  10  * Copyright (c) 2013-2014 Los Alamos National Security, LLC.  All rights
  11  *                         reserved.
  12  * Copyright (c) 2012-2013 Inria.  All rights reserved.
  13  * Copyright (c) 2015      Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * Copyright (c) 2017      IBM Corporation. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * Author(s): Torsten Hoefler
  21  *
  22  */
  23 
  24 #include "ompi_config.h"
  25 
  26 #include "ompi/mpi/c/bindings.h"
  27 #include "ompi/runtime/params.h"
  28 #include "ompi/communicator/communicator.h"
  29 #include "ompi/errhandler/errhandler.h"
  30 #include "ompi/memchecker.h"
  31 #include "ompi/mca/topo/topo.h"
  32 #include "ompi/mca/topo/base/base.h"
  33 
  34 #if OMPI_BUILD_MPI_PROFILING
  35 #if OPAL_HAVE_WEAK_SYMBOLS
  36 #pragma weak MPI_Dist_graph_create_adjacent = PMPI_Dist_graph_create_adjacent
  37 #endif
  38 #define MPI_Dist_graph_create_adjacent PMPI_Dist_graph_create_adjacent
  39 #endif
  40 
  41 static const char FUNC_NAME[] = "MPI_Dist_graph_create_adjacent";
  42 
  43 
  44 int MPI_Dist_graph_create_adjacent(MPI_Comm comm_old,
  45                                    int indegree, const int sources[],
  46                                    const int sourceweights[], int outdegree,
  47                                    const int destinations[], const int destweights[],
  48                                    MPI_Info info, int reorder,
  49                                    MPI_Comm *comm_dist_graph)
  50 {
  51     mca_topo_base_module_t* topo;
  52     int i, comm_size, err;
  53 
  54     MEMCHECKER(
  55         memchecker_comm(comm_old);
  56     );
  57 
  58     if (MPI_PARAM_CHECK) {
  59         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  60         if (ompi_comm_invalid(comm_old)) {
  61             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  62                                           FUNC_NAME);
  63         } else if (OMPI_COMM_IS_INTER(comm_old)) {
  64             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  65                                           FUNC_NAME);
  66         } else if (indegree < 0 || outdegree < 0 || NULL == comm_dist_graph) {
  67             return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
  68                                           "MPI_Dist_graph_create_adjacent negative degree");
  69         } else if ((indegree > 0 &&
  70                     (NULL == sources || NULL == sourceweights)) ||
  71                    (outdegree > 0 &&
  72                     (NULL == destinations || NULL == destweights))) {
  73             return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG, "MPI_Dist_graph_create_adjacent mismatched sources or destinations");
  74         }
  75         comm_size = ompi_comm_size(comm_old);
  76         for (i = 0; i < indegree; ++i) {
  77             if (((sources[i] < 0) && (sources[i] != MPI_PROC_NULL)) || sources[i] >= comm_size) {
  78                 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
  79                                               "MPI_Dist_graph_create_adjacent invalid sources");
  80             } else if (MPI_UNWEIGHTED != sourceweights && sourceweights[i] < 0) {
  81                 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
  82                                               "MPI_Dist_graph_create_adjacent invalid sourceweights");
  83             }
  84         }
  85         for (i = 0; i < outdegree; ++i) {
  86             if (((destinations[i] < 0) && (destinations[i] != MPI_PROC_NULL)) || destinations[i] >= comm_size) {
  87                 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
  88                                               "MPI_Dist_graph_create_adjacent invalid destinations");
  89             } else if (MPI_UNWEIGHTED != destweights && destweights[i] < 0) {
  90                 return OMPI_ERRHANDLER_INVOKE(comm_old, MPI_ERR_ARG,
  91                                               "MPI_Dist_graph_create_adjacent invalid destweights");
  92             }
  93         }
  94     }
  95 
  96     /* Ensure there is a topo attached to this communicator */
  97     if(OMPI_SUCCESS != (err = mca_topo_base_comm_select(comm_old, NULL,
  98                                                         &topo, OMPI_COMM_DIST_GRAPH))) {
  99         return OMPI_ERRHANDLER_INVOKE(comm_old, err, FUNC_NAME);
 100     }
 101 
 102     err = topo->topo.dist_graph.dist_graph_create_adjacent(topo, comm_old, indegree,
 103                                                            sources, sourceweights, outdegree,
 104                                                            destinations, destweights, &(info->super),
 105                                                            reorder, comm_dist_graph);
 106     OMPI_ERRHANDLER_RETURN(err, comm_old, err, FUNC_NAME);
 107 }
 108 

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