11/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22/*
3- * Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
3+ * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
44 * reserved.
55 * Copyright (c) 2015 Research Organization for Information Science
66 * and Technology (RIST). All rights reserved.
2222
2323#include "ompi/mca/bml/base/base.h"
2424
25- #define NODE_ID_TO_RANK (module , node_id ) (( node_id) * ((ompi_comm_size ((module)->comm) + (module )->node_count - 1) / (module)->node_count) )
25+ #define NODE_ID_TO_RANK (module , peer_data , node_id ) ((int)(peer_data )->len )
2626
2727/**
2828 * @brief find the btl endpoint for a process
@@ -102,7 +102,7 @@ static int ompi_osc_rdma_peer_setup (ompi_osc_rdma_module_t *module, ompi_osc_rd
102102 ompi_osc_rdma_rank_data_t rank_data ;
103103 int registration_handle_size = 0 ;
104104 int node_id , node_rank , array_index ;
105- int ret , disp_unit ;
105+ int ret , disp_unit , comm_size ;
106106 char * peer_data ;
107107
108108 OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_DEBUG , "configuring peer for rank %d" , peer -> rank );
@@ -111,13 +111,18 @@ static int ompi_osc_rdma_peer_setup (ompi_osc_rdma_module_t *module, ompi_osc_rd
111111 registration_handle_size = module -> selected_btl -> btl_registration_handle_size ;
112112 }
113113
114+ comm_size = ompi_comm_size (module -> comm );
115+
114116 /* each node is responsible for holding a part of the rank -> node/local rank mapping array. this code
115117 * calculates the node and offset the mapping can be found. once the mapping has been read the state
116118 * part of the peer structure can be initialized. */
117- node_id = (peer -> rank * module -> node_count ) / ompi_comm_size (module -> comm );
118- node_rank = NODE_ID_TO_RANK (module , node_id );
119- array_index = peer -> rank - node_rank ;
119+ node_id = (peer -> rank * module -> node_count ) / comm_size ;
120120 array_peer_data = (ompi_osc_rdma_region_t * ) ((intptr_t ) module -> node_comm_info + node_id * module -> region_size );
121+
122+ /* the node leader rank is stored in the length field */
123+ node_rank = NODE_ID_TO_RANK (module , array_peer_data , node_id );
124+ array_index = peer -> rank % ((comm_size + module -> node_count - 1 ) / module -> node_count );
125+
121126 array_pointer = array_peer_data -> base + array_index * sizeof (rank_data );
122127
123128 /* lookup the btl endpoint needed to retrieve the mapping */
@@ -126,8 +131,8 @@ static int ompi_osc_rdma_peer_setup (ompi_osc_rdma_module_t *module, ompi_osc_rd
126131 return OMPI_ERR_UNREACH ;
127132 }
128133
129- OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_DEBUG , "reading region data from rank: %d pointer: 0x%" PRIx64
130- ", size: %lu" , node_rank , array_pointer , sizeof (rank_data ));
134+ OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_DEBUG , "reading region data for %d from rank: %d, index: %d, pointer: 0x%" PRIx64
135+ ", size: %lu" , peer -> rank , node_rank , array_index , array_pointer , sizeof (rank_data ));
131136
132137 ret = ompi_osc_get_data_blocking (module , array_endpoint , array_pointer , (mca_btl_base_registration_handle_t * ) array_peer_data -> btl_handle_data ,
133138 & rank_data , sizeof (rank_data ));
@@ -146,7 +151,7 @@ static int ompi_osc_rdma_peer_setup (ompi_osc_rdma_module_t *module, ompi_osc_rd
146151 peer -> state_handle = (mca_btl_base_registration_handle_t * ) node_peer_data -> btl_handle_data ;
147152 }
148153
149- peer -> state_endpoint = ompi_osc_rdma_peer_btl_endpoint (module , NODE_ID_TO_RANK (module , rank_data .node_id ));
154+ peer -> state_endpoint = ompi_osc_rdma_peer_btl_endpoint (module , NODE_ID_TO_RANK (module , node_peer_data , rank_data .node_id ));
150155 if (OPAL_UNLIKELY (NULL == peer -> state_endpoint )) {
151156 return OPAL_ERR_UNREACH ;
152157 }
0 commit comments