Skip to content

Commit 4e0d267

Browse files
committed
btl/uct: use uct_ep_am_short_iov for short messages
The uct_ep_am_short_iov method should allow for faster short messages than uct_ep_am_short (which can only take a single buffer). This commit moves btl/uct to the newer method which breaks compatibility with some version of UCT. Since we already no longer support those versions this change is safe. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
1 parent 3c717d4 commit 4e0d267

File tree

3 files changed

+46
-30
lines changed

3 files changed

+46
-30
lines changed

opal/mca/btl/uct/btl_uct_am.c

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ mca_btl_base_descriptor_t *mca_btl_uct_alloc(mca_btl_base_module_t *btl,
4141
frag->base.des_segment_count = 1;
4242
frag->base.des_flags = flags;
4343
frag->base.order = order;
44-
frag->uct_iov.length = size;
44+
frag->uct_iov[1].length = size;
45+
frag->uct_iov[2].length = 0;
46+
frag->uct_iov_count = 2;
4547
if (NULL != frag->base.super.registration) {
4648
/* zero-copy fragments will need callbacks */
4749
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
@@ -89,11 +91,11 @@ struct mca_btl_base_descriptor_t *mca_btl_uct_prepare_src(mca_btl_base_module_t
8991
return NULL;
9092
}
9193

92-
_mca_btl_uct_send_pack((void *) ((intptr_t) frag->uct_iov.buffer + reserve), NULL, 0,
94+
_mca_btl_uct_send_pack((void *) ((intptr_t) frag->uct_iov[1].buffer + reserve), NULL, 0,
9395
convertor, size);
9496
/* update the length of the fragment according to the convertor packed data */
9597
frag->segments[0].seg_len = reserve + *size;
96-
frag->uct_iov.length = frag->segments[0].seg_len;
98+
frag->uct_iov[1].length = frag->segments[0].seg_len;
9799
} else {
98100
opal_convertor_get_current_pointer(convertor, &data_ptr);
99101
assert(NULL != data_ptr);
@@ -103,20 +105,21 @@ struct mca_btl_base_descriptor_t *mca_btl_uct_prepare_src(mca_btl_base_module_t
103105
return NULL;
104106
}
105107

106-
frag->uct_iov.length = total_size;
108+
frag->uct_iov[1].length = reserve;
109+
110+
/* user data */
111+
frag->uct_iov[2].length = *size;
112+
frag->uct_iov[2].buffer = data_ptr;
113+
114+
frag->uct_iov_count = 3;
115+
107116
frag->base.order = order;
108117
frag->base.des_flags = flags;
109-
if (total_size > (size_t) uct_btl->am_tl->uct_iface_attr.cap.am.max_short) {
110-
frag->segments[0].seg_len = reserve;
111-
frag->segments[1].seg_len = *size;
112-
frag->segments[1].seg_addr.pval = data_ptr;
113-
frag->base.des_segment_count = 2;
114-
} else {
115-
frag->segments[0].seg_len = total_size;
116-
memcpy((void *) ((intptr_t) frag->segments[0].seg_addr.pval + reserve), data_ptr,
117-
*size);
118-
frag->base.des_segment_count = 1;
119-
}
118+
119+
frag->segments[0].seg_len = reserve;
120+
frag->segments[1].seg_len = *size;
121+
frag->segments[1].seg_addr.pval = data_ptr;
122+
frag->base.des_segment_count = 2;
120123
}
121124

122125
return &frag->base;
@@ -167,7 +170,7 @@ static void mca_btl_uct_append_pending_frag(mca_btl_uct_module_t *uct_btl,
167170
int mca_btl_uct_send_frag(mca_btl_uct_module_t *uct_btl, mca_btl_uct_base_frag_t *frag, bool append)
168171
{
169172
mca_btl_uct_device_context_t *context = frag->context;
170-
const ssize_t msg_size = frag->uct_iov.length + 8;
173+
const ssize_t msg_size = frag->uct_iov[0].length + frag->uct_iov[1].length + frag->uct_iov[2].length;
171174
ssize_t size;
172175
ucs_status_t ucs_status;
173176
uct_ep_h ep_handle = NULL;
@@ -184,8 +187,8 @@ int mca_btl_uct_send_frag(mca_btl_uct_module_t *uct_btl, mca_btl_uct_base_frag_t
184187
if (NULL != frag->base.super.registration
185188
&& (uct_btl->am_tl->uct_iface_attr.cap.flags & UCT_IFACE_FLAG_AM_ZCOPY)) {
186189
frag->comp.dev_context = context;
187-
ucs_status = uct_ep_am_zcopy(ep_handle, MCA_BTL_UCT_FRAG, &frag->header,
188-
sizeof(frag->header), &frag->uct_iov, 1, 0,
190+
ucs_status = uct_ep_am_zcopy(ep_handle, MCA_BTL_UCT_FRAG, frag->uct_iov[0].buffer,
191+
frag->uct_iov[0].length, &frag->uct_iov[1], 1, 0,
189192
&frag->comp.uct_comp);
190193

191194
if (OPAL_LIKELY(UCS_INPROGRESS == ucs_status)) {
@@ -195,12 +198,8 @@ int mca_btl_uct_send_frag(mca_btl_uct_module_t *uct_btl, mca_btl_uct_base_frag_t
195198
}
196199
} else {
197200
/* short message */
198-
if (1 == frag->base.des_segment_count
199-
&& (frag->uct_iov.length + 8)
200-
< uct_btl->am_tl->uct_iface_attr.cap.am.max_short) {
201-
ucs_status = uct_ep_am_short(ep_handle, MCA_BTL_UCT_FRAG, frag->header.value,
202-
frag->uct_iov.buffer, frag->uct_iov.length);
203-
201+
if (msg_size < uct_btl->am_tl->uct_iface_attr.cap.am.max_short) {
202+
ucs_status = uct_ep_am_short_iov(ep_handle, MCA_BTL_UCT_FRAG, frag->uct_iov, frag->uct_iov_count);
204203
if (OPAL_LIKELY(UCS_OK == ucs_status)) {
205204
uct_worker_progress(context->uct_worker);
206205
mca_btl_uct_context_unlock(context);
@@ -250,7 +249,7 @@ int mca_btl_uct_send(mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoi
250249

251250
BTL_VERBOSE(("btl/uct sending descriptor %p from %d -> %d. length = %" PRIu64,
252251
(void *) descriptor, OPAL_PROC_MY_NAME.vpid, endpoint->ep_proc->proc_name.vpid,
253-
frag->uct_iov.length));
252+
frag->uct_iov[0].length + frag->uct_iov[1].length + frag->uct_iov[2].length));
254253

255254
frag->header.data.tag = tag;
256255
frag->context = context;

opal/mca/btl/uct/btl_uct_frag.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,25 @@ static void mca_btl_uct_base_frag_constructor(mca_btl_uct_base_frag_t *frag)
2626
frag->base.des_segment_count = 1;
2727

2828
frag->segments[0].seg_addr.pval = frag->base.super.ptr;
29-
frag->uct_iov.buffer = frag->base.super.ptr;
30-
frag->uct_iov.stride = 0;
31-
frag->uct_iov.count = 1;
29+
/* header */
30+
frag->uct_iov[0].buffer = &frag->header;
31+
frag->uct_iov[0].length = sizeof(frag->header);
32+
frag->uct_iov[0].stride = 0;
33+
frag->uct_iov[0].count = 1;
34+
35+
/* fragment buffer (reserve with or without data) */
36+
frag->uct_iov[1].buffer = frag->base.super.ptr;
37+
frag->uct_iov[1].stride = 0;
38+
frag->uct_iov[1].count = 1;
39+
40+
/* reserved for user data */
41+
frag->uct_iov[2].buffer = NULL;
42+
frag->uct_iov[2].stride = 0;
43+
frag->uct_iov[2].length = 0;
44+
frag->uct_iov[2].count = 1;
45+
frag->uct_iov_count = 1;
3246
if (reg) {
33-
frag->uct_iov.memh = reg->uct_memh;
47+
frag->uct_iov[1].memh = reg->uct_memh;
3448
}
3549
}
3650

opal/mca/btl/uct/btl_uct_types.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ struct mca_btl_uct_base_frag_t {
295295
mca_btl_uct_am_header_t header;
296296

297297
/** pre-filled UCT io vector */
298-
uct_iov_t uct_iov;
298+
uct_iov_t uct_iov[3];
299+
300+
/** how many iov entries are filled */
301+
int uct_iov_count;
299302

300303
/** completion structure */
301304
mca_btl_uct_uct_completion_t comp;

0 commit comments

Comments
 (0)