1+ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12/*
23 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
34 * University Research and Technology
910 * University of Stuttgart. All rights reserved.
1011 * Copyright (c) 2004-2005 The Regents of the University of California.
1112 * All rights reserved.
13+ * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
14+ * reserved.
1215 * $COPYRIGHT$
1316 *
1417 * Additional copyrights may follow
@@ -51,13 +54,10 @@ OBJ_CLASS_DECLARATION(mca_pml_ob1_comm_proc_t);
5154 */
5255struct mca_pml_comm_t {
5356 opal_object_t super ;
54- #if OPAL_ENABLE_MULTI_THREADS
5557 volatile uint32_t recv_sequence ; /**< recv request sequence number - receiver side */
56- #else
57- uint32_t recv_sequence ; /**< recv request sequence number - receiver side */
58- #endif
5958 opal_mutex_t matching_lock ; /**< matching lock */
6059 opal_list_t wild_receives ; /**< queue of unmatched wild (source process not specified) receives */
60+ opal_mutex_t proc_lock ;
6161 mca_pml_ob1_comm_proc_t * * procs ;
6262 size_t num_procs ;
6363 size_t last_probed ;
@@ -71,9 +71,14 @@ static inline mca_pml_ob1_comm_proc_t *mca_pml_ob1_peer_lookup (struct ompi_comm
7171 mca_pml_ob1_comm_t * pml_comm = (mca_pml_ob1_comm_t * )comm -> c_pml_comm ;
7272
7373 if (OPAL_UNLIKELY (NULL == pml_comm -> procs [rank ])) {
74- pml_comm -> procs [rank ] = OBJ_NEW (mca_pml_ob1_comm_proc_t );
75- pml_comm -> procs [rank ]-> ompi_proc = ompi_comm_peer_lookup (comm , rank );
76- OBJ_RETAIN (pml_comm -> procs [rank ]-> ompi_proc );
74+ OPAL_THREAD_LOCK (& pml_comm -> proc_lock );
75+ 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 );
79+ opal_atomic_wmb ();
80+ }
81+ OPAL_THREAD_UNLOCK (& pml_comm -> proc_lock );
7782 }
7883
7984 return pml_comm -> procs [rank ];
0 commit comments