Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit f3e67eb

Browse files
authored
Merge pull request #1127 from hjelmn/v2.x_osc_rdma_fixes
v2.x osc/rdma fixes
2 parents da483d9 + b436f43 commit f3e67eb

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

ompi/mca/osc/rdma/osc_rdma_accumulate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,11 @@ static void ompi_osc_rdma_cas_get_complete (struct mca_btl_base_module_t *btl, s
564564
if (OMPI_SUCCESS == status) {
565565
/* copy data to the user buffer (for gacc) */
566566
memcpy (request->result_addr, (void *) source, request->len);
567-
memcpy ((void *) source, request->origin_addr, request->len);
568567

569568
if (0 == memcmp ((void *) source, request->compare_addr, request->len)) {
570569
/* the target and compare buffers match so write the source to the target */
570+
memcpy ((void *) source, request->origin_addr, request->len);
571+
571572
ret = module->selected_btl->btl_put (module->selected_btl, peer->data_endpoint, local_address,
572573
request->target_address, local_handle,
573574
(mca_btl_base_registration_handle_t *) request->ctx,

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,8 @@ static int ompi_osc_rdma_share_data (ompi_osc_rdma_module_t *module)
845845
module->region_size);
846846

847847
my_data->base = (uint64_t) (intptr_t) module->rank_array;
848+
/* store my rank in the length field */
849+
my_data->len = (osc_rdma_size_t) my_rank;
848850

849851
if (module->selected_btl->btl_register_mem) {
850852
memcpy (my_data->btl_handle_data, module->state_handle, module->selected_btl->btl_registration_handle_size);
@@ -861,9 +863,11 @@ static int ompi_osc_rdma_share_data (ompi_osc_rdma_module_t *module)
861863
}
862864
}
863865

866+
int base_rank = ompi_comm_rank (module->local_leaders) * ((comm_size + module->node_count - 1) / module->node_count);
867+
864868
/* fill in the local part of the rank -> node map */
865869
for (int i = 0 ; i < RANK_ARRAY_COUNT(module) ; ++i) {
866-
int save_rank = my_rank + i;
870+
int save_rank = base_rank + i;
867871
if (save_rank >= comm_size) {
868872
break;
869873
}

ompi/mca/osc/rdma/osc_rdma_passive_target.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* University of Stuttgart. All rights reserved.
99
* Copyright (c) 2004-2005 The Regents of the University of California.
1010
* All rights reserved.
11-
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
11+
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
1212
* reserved.
1313
* Copyright (c) 2010 IBM Corporation. All rights reserved.
1414
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
@@ -197,6 +197,8 @@ int ompi_osc_rdma_lock_atomic (int lock_type, int target, int assert, ompi_win_t
197197
return OMPI_ERR_RMA_SYNC;
198198
}
199199

200+
/* clear the global sync object (in case MPI_Win_fence was called) */
201+
module->all_sync.type = OMPI_OSC_RDMA_SYNC_TYPE_NONE;
200202

201203
/* create lock item */
202204
lock = ompi_osc_rdma_sync_allocate (module);

ompi/mca/osc/rdma/osc_rdma_peer.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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.
@@ -22,7 +22,7 @@
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

Comments
 (0)