@@ -94,7 +94,7 @@ static opal_event_base_t* fd_event_base = NULL;
9494static void fd_event_cb (int fd , short flags , void * pdetector );
9595
9696static bool comm_detector_use_thread = false;
97- static opal_atomic_int32_t fd_thread_active = 0 ;
97+ static opal_atomic_int32_t fd_thread_active = OPAL_ATOMIC_VAR_INIT ( 0 ) ;
9898static opal_thread_t fd_thread ;
9999static void * fd_progress (opal_object_t * obj );
100100
@@ -168,8 +168,8 @@ int ompi_comm_failure_detector_init(void) {
168168 fd_thread .t_arg = NULL ;
169169 ret = opal_thread_start (& fd_thread );
170170 if ( OPAL_SUCCESS != ret ) goto cleanup ;
171- while ( 0 == fd_thread_active ); /* wait for the fd thread initialization */
172- if ( 0 > fd_thread_active ) goto cleanup ;
171+ while ( 0 == opal_atomic_load ( & fd_thread_active ) ); /* wait for the fd thread initialization */
172+ if ( 0 > opal_atomic_load ( & fd_thread_active ) ) goto cleanup ;
173173 }
174174
175175 return OMPI_SUCCESS ;
@@ -218,18 +218,18 @@ int ompi_comm_failure_detector_finalize(void) {
218218#endif
219219 while ( observing == detector -> hb_observing ) {
220220 /* If observed process changed, recheck if local*/
221- if ( !(0 < fd_thread_active ) )
221+ if ( !(0 < opal_atomic_load ( & fd_thread_active ) ) )
222222 {
223223 opal_progress ();
224224 }
225225 }
226226 }
227227
228- if ( 0 < fd_thread_active ) {
228+ if ( 0 < opal_atomic_load ( & fd_thread_active ) ) {
229229 void * tret ;
230230 /* this is not a race condition. Accesses are serialized, we use the
231231 * atomic for the mfence part of it. */
232- OPAL_THREAD_ADD_FETCH32 (& fd_thread_active , - fd_thread_active );
232+ OPAL_THREAD_ADD_FETCH32 (& fd_thread_active , - opal_atomic_load ( & fd_thread_active ) );
233233 opal_event_base_loopbreak (fd_event_base );
234234 opal_thread_join (& fd_thread , & tret );
235235 }
@@ -587,9 +587,9 @@ void* fd_progress(opal_object_t* obj) {
587587 return OPAL_THREAD_CANCELLED ;
588588 }
589589 OPAL_THREAD_ADD_FETCH32 (& fd_thread_active , 1 );
590- while ( 1 == fd_thread_active ); /* wait for init stage 2: start_detector */
590+ while ( 1 == opal_atomic_load ( & fd_thread_active ) ); /* wait for init stage 2: start_detector */
591591 ret = MCA_PML_CALL (irecv (NULL , 0 , MPI_BYTE , 0 , MCA_COLL_BASE_TAG_FT_END , & ompi_mpi_comm_self .comm , & req ));
592- while ( fd_thread_active ) {
592+ while ( opal_atomic_load ( & fd_thread_active ) ) {
593593 opal_event_loop (fd_event_base , OPAL_EVLOOP_ONCE );
594594#if 0
595595 /* This test disabled because rdma emulation over TCP would not work without
0 commit comments