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$
14 *
15 * Additional copyrights may follow
16 *
17 * $HEADER$
18 */
19
20 #include "ompi_config.h"
21 #include "ompi/mca/topo/base/base.h"
22 #include "ompi/communicator/communicator.h"
23
24 /*
25 * function - retrieves graph topology information associated with a
26 * communicator
27 *
28 * @param comm communicator with graph structure (handle)
29 * @param maxindex length of vector 'index' in the calling program (integer)
30 * @param maxedges length of vector 'edges' in the calling program (integer)
31 * @param nodes array of integers containing the graph structure (for details see
32 * @param edges array of integers containing the graph structure
33 *
34 * @retval MPI_SUCCESS
35 */
36
37 int mca_topo_base_graph_get(ompi_communicator_t* comm,
38 int maxindex,
39 int maxedges,
40 int *index,
41 int *edges)
42 {
43 int i, *p;
44 int nprocs = ompi_comm_size(comm);
45
46 /*
47 * Fill the nodes and edges arrays.
48 */
49 p = comm->c_topo->mtc.graph->index;
50 for (i = 0; (i < nprocs) && (i < maxindex); ++i, ++p) {
51 *index++ = *p;
52 }
53
54 p = comm->c_topo->mtc.graph->edges;
55
56 for (i = 0;
57 (i < comm->c_topo->mtc.graph->index[nprocs-1]) && (i < maxedges);
58 ++i, ++p) {
59
60 *edges++ = *p;
61
62 }
63
64 return MPI_SUCCESS;
65 }