Skip to content

Commit 850fbff

Browse files
committed
btl/vader: ensure that the send tag is always written last
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 #5375, #5638 Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 9a514c6 commit 850fbff

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

opal/mca/btl/vader/btl_vader_fbox.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ void mca_btl_vader_poll_handle_frag (mca_btl_vader_hdr_t *hdr, mca_btl_base_endp
5050
static inline void mca_btl_vader_fbox_set_header (mca_btl_vader_fbox_hdr_t *hdr, uint16_t tag,
5151
uint16_t seq, uint32_t size)
5252
{
53-
mca_btl_vader_fbox_hdr_t tmp = {.data = {.tag = tag, .seq = seq, .size = size}};
54-
opal_atomic_wmb ();
53+
mca_btl_vader_fbox_hdr_t tmp = {.data = {.tag = 0, .seq = seq, .size = size}};
5554
hdr->ival = tmp.ival;
55+
opal_atomic_wmb ();
56+
hdr->data.tag = tag;
5657
}
5758

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

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

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

153+
/* write out part of the header now. the tag will be written when the data is available */
154+
mca_btl_vader_fbox_set_header (MCA_BTL_VADER_FBOX_HDR(dst), tag, ep->fbox_out.seq++, data_size);
155+
155156
/* align the buffer */
156157
ep->fbox_out.end = ((uint32_t) hbs << 31) | end;
157158
opal_atomic_wmb ();

0 commit comments

Comments
 (0)