Skip to content

Commit

Permalink
btl/vader: ensure that the send tag is always written last
Browse files Browse the repository at this point in the history
To ensure fast box entries are complete when processed by the
receiving process the tag must be written last. This includes a zero
header for the next fast box entry (in some cases). This commit fixes
two instances where the tag was written too early. In one case, on
32-bit systems it is possible for the tag part of the header to be
written before the size. The second instance is an ordering issue. The
zero header was being written after the fastbox header.

Fixes open-mpi#5375, open-mpi#5638

Signed-off-by: Nathan Hjelm <[email protected]>
(cherry picked from commit 850fbff)
Signed-off-by: Nathan Hjelm <[email protected]>
  • Loading branch information
hjelmn committed Sep 14, 2018
1 parent 2ad9f8a commit 3146445
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions opal/mca/btl/vader/btl_vader_fbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ void mca_btl_vader_poll_handle_frag (mca_btl_vader_hdr_t *hdr, mca_btl_base_endp
static inline void mca_btl_vader_fbox_set_header (mca_btl_vader_fbox_hdr_t *hdr, uint16_t tag,
uint16_t seq, uint32_t size)
{
mca_btl_vader_fbox_hdr_t tmp = {.data = {.tag = tag, .seq = seq, .size = size}};
opal_atomic_wmb ();
mca_btl_vader_fbox_hdr_t tmp = {.data = {.tag = 0, .seq = seq, .size = size}};
hdr->ival = tmp.ival;
opal_atomic_wmb ();
hdr->data.tag = tag;
}

/* attempt to reserve a contiguous segment from the remote ep */
Expand Down Expand Up @@ -138,9 +139,6 @@ static inline bool mca_btl_vader_fbox_sendi (mca_btl_base_endpoint_t *ep, unsign
memcpy (data + header_size, payload, payload_size);
}

/* write out part of the header now. the tag will be written when the data is available */
mca_btl_vader_fbox_set_header (MCA_BTL_VADER_FBOX_HDR(dst), tag, ep->fbox_out.seq++, data_size);

end += size;

if (OPAL_UNLIKELY(fbox_size == end)) {
Expand All @@ -152,6 +150,9 @@ static inline bool mca_btl_vader_fbox_sendi (mca_btl_base_endpoint_t *ep, unsign
MCA_BTL_VADER_FBOX_HDR(ep->fbox_out.buffer + end)->ival = 0;
}

/* write out part of the header now. the tag will be written when the data is available */
mca_btl_vader_fbox_set_header (MCA_BTL_VADER_FBOX_HDR(dst), tag, ep->fbox_out.seq++, data_size);

/* align the buffer */
ep->fbox_out.end = ((uint32_t) hbs << 31) | end;
opal_atomic_wmb ();
Expand Down

0 comments on commit 3146445

Please sign in to comment.