diff --git a/ompi/mca/bml/r2/bml_r2.c b/ompi/mca/bml/r2/bml_r2.c index e29928f673..cc0181874f 100644 --- a/ompi/mca/bml/r2/bml_r2.c +++ b/ompi/mca/bml/r2/bml_r2.c @@ -160,7 +160,6 @@ static mca_bml_base_endpoint_t *mca_bml_r2_allocate_endpoint (ompi_proc_t *proc) mca_bml_base_btl_array_reserve(&bml_endpoint->btl_rdma, mca_bml_r2.num_btl_modules); bml_endpoint->btl_max_send_size = -1; bml_endpoint->btl_proc = proc; - proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML] = bml_endpoint; bml_endpoint->btl_flags_or = 0; return bml_endpoint; @@ -430,6 +429,12 @@ static int mca_bml_r2_add_proc (struct ompi_proc_t *proc) /* compute metrics for registered btls */ mca_bml_r2_compute_endpoint_metrics (bml_endpoint); + /* do it last, for the lazy initialization check in bml_base_get* */ +#if OPAL_ENABLE_THREAD_MULTI + opal_atomic_wmb(); +#endif /* OPAL_ENABLE_THREAD_MULTI */ + proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML] = bml_endpoint; + return OMPI_SUCCESS; } @@ -523,6 +528,7 @@ static int mca_bml_r2_add_procs( size_t nprocs, if (NULL == bml_endpoint) { bml_endpoint = mca_bml_r2_allocate_endpoint (proc); + proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML] = bml_endpoint; if (NULL == bml_endpoint) { free(btl_endpoints); free(new_procs);