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 number of neighbors of a node
28 * associated 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 nneighbors number of neighbors of specified process (integer)
33 *
34 * @retval MPI_SUCCESS
35 */
36
37 int mca_topo_base_graph_neighbors_count (ompi_communicator_t* comm,
38 int rank,
39 int *nneighbors)
40 {
41 mca_topo_base_comm_graph_2_2_0_t* graph = comm->c_topo->mtc.graph;
42 *nneighbors = graph->index[rank];
43 if (rank > 0) {
44 *nneighbors -= graph->index[rank - 1];
45 }
46
47 return MPI_SUCCESS;
48 }