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) 2009 Cisco Systems, Inc. All rights reserved.
13 * Copyright (c) 2012-2013 Inria. All rights reserved.
14 * $COPYRIGHT$
15 *
16 * Additional copyrights may follow
17 *
18 * $HEADER$
19 */
20
21 #include "ompi_config.h"
22 #include "ompi/mca/topo/example/topo_example.h"
23
24 #include "ompi/communicator/communicator.h"
25
26 /*
27 * function - mca_topo_example_graph_map
28 *
29 * @param comm input communicator (handle)
30 * @param nnodes number of graph nodes (integer)
31 * @param index integer array specifying the graph structure
32 * @param edges integer array specifying the graph structure
33 * @param newrank reordered rank of the calling process; 'MPI_UNDEFINED'
34 * if the calling process does not belong to
35 * graph (integer)
36 *
37 * @retval MPI_SUCCESS
38 * @retval MPI_UNDEFINED
39 */
40
41 int mca_topo_example_graph_map (ompi_communicator_t* comm,
42 int nnodes,
43 int *index,
44 int *edges,
45 int *newrank)
46 {
47 int myrank;
48
49 /*
50 * Compute my new rank. To be slightly different than the "unity"
51 * component, start with a rank that is size-my_initial_rank.
52 */
53 myrank = ompi_comm_size(comm) - 1 - ompi_comm_rank(comm);
54 *newrank =
55 ((0 > myrank) || (myrank >= nnodes)) ? MPI_UNDEFINED : myrank;
56
57 return OMPI_SUCCESS;
58 }