1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2005 The University of Tennessee and The University
7 * of Tennessee Research Foundation. All rights
8 * reserved.
9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 * University of Stuttgart. All rights reserved.
11 * Copyright (c) 2004-2005 The Regents of the University of California.
12 * All rights reserved.
13 * Copyright (c) 2006-2007 University of Houston. All rights reserved.
14 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
15 * reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 */
22
23 #include "ompi_config.h"
24 #include "ompi/group/group.h"
25 #include "ompi/constants.h"
26
27 /*
28 * Set group rank in a group structure.
29 */
30 void ompi_set_group_rank(ompi_group_t *group, struct ompi_proc_t *proc_pointer)
31 {
32 /* local variables */
33 int proc;
34
35 /* set the rank to MPI_UNDEFINED, just in case this process is not
36 * in this group
37 */
38 group->grp_my_rank = MPI_UNDEFINED;
39 if (NULL != proc_pointer) {
40 /* loop over all procs in the group */
41 for (proc = 0; proc < group->grp_proc_count; proc++) {
42 /* check and see if this proc pointer matches proc_pointer
43 */
44 if (ompi_group_peer_lookup_existing (group, proc) == proc_pointer) {
45 group->grp_my_rank = proc;
46 break;
47 }
48 } /* end proc loop */
49 }
50 }