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

Commit b03ef3c

Browse files
committed
Fix a race condition when multiple threads do the "first send" to an endpoint simultaneously.
Fix a race condition when multiple threads try to create a bml endpoint simultaneously. forgot to update copyright in commits 627a89b 4899c89
1 parent 4310b3f commit b03ef3c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

ompi/mca/bml/r2/bml_r2.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2014 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -160,7 +160,6 @@ static mca_bml_base_endpoint_t *mca_bml_r2_allocate_endpoint (ompi_proc_t *proc)
160160
mca_bml_base_btl_array_reserve(&bml_endpoint->btl_rdma, mca_bml_r2.num_btl_modules);
161161
bml_endpoint->btl_max_send_size = -1;
162162
bml_endpoint->btl_proc = proc;
163-
proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML] = bml_endpoint;
164163

165164
bml_endpoint->btl_flags_or = 0;
166165
return bml_endpoint;
@@ -428,6 +427,12 @@ static int mca_bml_r2_add_proc (struct ompi_proc_t *proc)
428427
/* compute metrics for registered btls */
429428
mca_bml_r2_compute_endpoint_metrics (bml_endpoint);
430429

430+
/* do it last, for the lazy initialization check in bml_base_get* */
431+
#if OPAL_ENABLE_THREAD_MULTI
432+
opal_atomic_wmb();
433+
#endif /* OPAL_ENABLE_THREAD_MULTI */
434+
proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML] = bml_endpoint;
435+
431436
return OMPI_SUCCESS;
432437
}
433438

@@ -521,6 +526,7 @@ static int mca_bml_r2_add_procs( size_t nprocs,
521526

522527
if (NULL == bml_endpoint) {
523528
bml_endpoint = mca_bml_r2_allocate_endpoint (proc);
529+
proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML] = bml_endpoint;
524530
if (NULL == bml_endpoint) {
525531
free(btl_endpoints);
526532
free(new_procs);

ompi/mca/pml/ob1/pml_ob1_comm.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2006 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -73,10 +73,11 @@ static inline mca_pml_ob1_comm_proc_t *mca_pml_ob1_peer_lookup (struct ompi_comm
7373
if (OPAL_UNLIKELY(NULL == pml_comm->procs[rank])) {
7474
OPAL_THREAD_LOCK(&pml_comm->proc_lock);
7575
if (NULL == pml_comm->procs[rank]) {
76-
pml_comm->procs[rank] = OBJ_NEW(mca_pml_ob1_comm_proc_t);
77-
pml_comm->procs[rank]->ompi_proc = ompi_comm_peer_lookup (comm, rank);
78-
OBJ_RETAIN(pml_comm->procs[rank]->ompi_proc);
76+
mca_pml_ob1_comm_proc_t* proc = OBJ_NEW(mca_pml_ob1_comm_proc_t);
77+
proc->ompi_proc = ompi_comm_peer_lookup (comm, rank);
78+
OBJ_RETAIN(proc->ompi_proc);
7979
opal_atomic_wmb ();
80+
pml_comm->procs[rank] = proc;
8081
}
8182
OPAL_THREAD_UNLOCK(&pml_comm->proc_lock);
8283
}

0 commit comments

Comments
 (0)