@@ -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