Skip to content

Commit 267b119

Browse files
authored
Merge pull request #10568 from hppritcha/ofi_btl_use_inject
ofi: add inject path to ofi btl
2 parents b511836 + 6eca301 commit 267b119

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

opal/mca/btl/ofi/btl_ofi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ struct mca_btl_ofi_component_t {
162162

163163
size_t namelen;
164164

165+
/** Maximum inject size */
166+
size_t max_inject_size;
167+
bool disable_inject;
168+
165169
/** All BTL OFI modules (1 per tl) */
166170
mca_btl_ofi_module_t *modules[MCA_BTL_OFI_MAX_MODULES];
167171
};

opal/mca/btl/ofi/btl_ofi_component.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ static int mca_btl_ofi_component_register(void)
189189
MCA_BASE_VAR_SCOPE_READONLY,
190190
&mca_btl_ofi_component.rd_num);
191191

192+
mca_btl_ofi_component.disable_inject = false;
193+
(void) mca_base_component_var_register(&mca_btl_ofi_component.super.btl_version, "disable_inject",
194+
"disable use of fi_inject for short messages.",
195+
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, OPAL_INFO_LVL_5,
196+
MCA_BASE_VAR_SCOPE_READONLY,
197+
&mca_btl_ofi_component.disable_inject);
198+
192199
/* for now we want this component to lose to the MTL. */
193200
module->super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH - 50;
194201

@@ -477,6 +484,11 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
477484
goto fail;
478485
}
479486

487+
/**
488+
* Save the maximum sizes.
489+
*/
490+
mca_btl_ofi_component.max_inject_size = ofi_info->tx_attr->inject_size;
491+
480492
/* AV */
481493
av_attr.type = FI_AV_MAP;
482494
rc = fi_av_open(domain, &av_attr, &av, NULL);

opal/mca/btl/ofi/btl_ofi_frag.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ int mca_btl_ofi_send(mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoi
8989
mca_btl_base_descriptor_t *descriptor, mca_btl_base_tag_t tag)
9090
{
9191
int rc = 0;
92+
size_t msg_sz;
9293
mca_btl_ofi_context_t *context;
9394
mca_btl_ofi_module_t *ofi_btl = (mca_btl_ofi_module_t *) btl;
9495
mca_btl_ofi_endpoint_t *ofi_ep = (mca_btl_ofi_endpoint_t *) endpoint;
@@ -100,9 +101,35 @@ int mca_btl_ofi_send(mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoi
100101
/* This tag is the active message tag for the remote side */
101102
frag->hdr.tag = tag;
102103

103-
/* create completion context */
104104
context = get_ofi_context(ofi_btl);
105-
comp = mca_btl_ofi_frag_completion_alloc(btl, context, frag, MCA_BTL_OFI_TYPE_SEND);
105+
msg_sz = sizeof(mca_btl_ofi_header_t) + frag->hdr.len;
106+
107+
/*
108+
* If supported by the provider and not disabled by
109+
* the btl_ofi_disable_inject MCA parameter,
110+
* try to use the inject path for short messages.
111+
* fi_inject can return -FI_EAGAIN if the provider is
112+
* unable to buffer the message, so one needs to fall
113+
* back to the fi_send path when that error code is
114+
* returned.
115+
*/
116+
if (msg_sz <= mca_btl_ofi_component.max_inject_size &&
117+
false == mca_btl_ofi_component.disable_inject) {
118+
rc = fi_inject(context->tx_ctx, &frag->hdr, msg_sz, ofi_ep->peer_addr);
119+
if (FI_SUCCESS == rc) {
120+
mca_btl_ofi_frag_complete(frag, OPAL_SUCCESS);
121+
return OPAL_SUCCESS;
122+
}
123+
/*
124+
* -FI_EAGAIN is okay but any other error is a problem
125+
*/
126+
if (-FI_EAGAIN != rc) {
127+
return OPAL_ERROR;
128+
}
129+
}
130+
131+
/* create completion context */
132+
comp = mca_btl_ofi_frag_completion_alloc(btl, context, frag, MCA_BTL_OFI_TYPE_SEND);
106133

107134
/* send the frag. Note that we start sending from BTL header + payload
108135
* because we need the other side to have this header information. */

0 commit comments

Comments
 (0)