root/ompi/mca/topo/base/topo_base_graph_neighbors.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_topo_base_graph_neighbors

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2013 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2012-2013 Inria.  All rights reserved.
  13  * Copyright (c) 2014      Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  */
  21 
  22 #include "ompi_config.h"
  23 #include "ompi/mca/topo/base/base.h"
  24 #include "ompi/communicator/communicator.h"
  25 
  26 /*
  27  * function - returns the neighbors of a node associated
  28  *            with a graph topology
  29  *
  30  * @param comm communicator with graph topology (handle)
  31  * @param rank rank of process in group of comm (integer)
  32  * @param maxneighbors size of array neighbors (integer)
  33  * @param neighbors ranks of processes that are neighbors to specified process
  34  *               (array of integer)
  35  *
  36  * @retval MPI_SUCCESS
  37  */
  38 
  39 int mca_topo_base_graph_neighbors (ompi_communicator_t* comm,
  40                                    int rank,
  41                                    int maxneighbors,
  42                                    int *neighbors)
  43 {
  44     mca_topo_base_comm_graph_2_2_0_t* graph = comm->c_topo->mtc.graph;
  45     int nnbrs, i, *p;
  46 
  47     /*
  48      * Fill the neighbours.
  49      */
  50     nnbrs = graph->index[rank];
  51     p = graph->edges;
  52 
  53     if (rank > 0) {
  54         i = graph->index[rank - 1];
  55         nnbrs -= i;
  56         p += i;
  57     }
  58 
  59     for (i = 0; (i < maxneighbors) && (i < nnbrs); ++i, ++p) {
  60         *neighbors++ = *p;
  61     }
  62 
  63     return MPI_SUCCESS;
  64 }

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