diff --git a/ompi/mca/btl/sm/btl_sm.h b/ompi/mca/btl/sm/btl_sm.h index 1058b8a7f6..fabdbd4348 100644 --- a/ompi/mca/btl/sm/btl_sm.h +++ b/ompi/mca/btl/sm/btl_sm.h @@ -334,12 +334,13 @@ static inline int sm_fifo_write(void *value, sm_fifo_t *fifo) volatile void **q = (volatile void **) RELATIVE2VIRTUAL(fifo->queue); /* if there is no free slot to write, report exhausted resource */ + opal_atomic_rmb(); if ( SM_FIFO_FREE != q[fifo->head] ) return OMPI_ERR_OUT_OF_RESOURCE; /* otherwise, write to the slot and advance the head index */ - opal_atomic_rmb(); q[fifo->head] = value; + opal_atomic_wmb(); fifo->head = (fifo->head + 1) & fifo->mask; opal_atomic_wmb(); return OMPI_SUCCESS;