@@ -372,6 +372,7 @@ static inline int mca_btl_base_am_rdma_advance(mca_btl_base_module_t *btl,
372372 mca_btl_base_rdma_context_t * context ,
373373 bool send_descriptor )
374374{
375+ int ret ;
375376 const size_t remaining = context -> total_size - context -> sent ;
376377
377378 if (0 == remaining ) {
@@ -409,7 +410,19 @@ static inline int mca_btl_base_am_rdma_advance(mca_btl_base_module_t *btl,
409410 }
410411
411412 if (send_descriptor ) {
412- return btl -> btl_send (btl , endpoint , descriptor , mca_btl_base_rdma_tag (hdr -> type ));
413+ /* btl_send return OPAL_SUCCESS when that the descriptor has been queued for send, and
414+ * descriptor's callback will be called upon completion.
415+ *
416+ * btl_send return 1 when the descriptor has been sent. In this case, the descriptor's
417+ * callback is called only if MCA_BTL_DES_SEND_ALWAYS_CALLBACK is set on the descriptor's flags.
418+ *
419+ * When creating the initiator request, we specified MCA_BTL_DES_SEND_ALWAYS_CALLBACK,
420+ * therefore btl_send's returning 1 is the same as it returning OPAL_SUCCESS.
421+ */
422+ ret = btl -> btl_send (btl , endpoint , descriptor , mca_btl_base_rdma_tag (hdr -> type ));
423+ if (ret == 1 )
424+ ret = OPAL_SUCCESS ;
425+ return ret ;
413426 }
414427
415428 /* queue for later to avoid btl_send in callback */
@@ -614,7 +627,19 @@ static int mca_btl_base_am_rdma_respond(mca_btl_base_module_t *btl,
614627
615628 send_descriptor -> des_cbfunc = NULL ;
616629
630+ /* btl_send return OPAL_SUCCESS when that the descriptor has been queued for send, and
631+ * descriptor's callback will be called upon completion.
632+ *
633+ * btl_send return 1 when the descriptor has been sent. In this case, descriptor's
634+ * callback is called only if MCA_BTL_DES_SEND_ALWAYS_CALLBACK is set on the descriptor.
635+ *
636+ * There is no callback for the response descriptor, therefore for us btl_send
637+ * return 1 is the the same as it returning OPAL_SUCCESS.
638+ */
617639 int ret = btl -> btl_send (btl , endpoint , send_descriptor , mca_btl_base_rdma_resp_tag ());
640+ if (ret == 1 )
641+ ret = OPAL_SUCCESS ;
642+
618643 if (OPAL_UNLIKELY (OPAL_SUCCESS != ret )) {
619644 * descriptor = send_descriptor ;
620645 }
@@ -779,6 +804,18 @@ static int mca_btl_base_am_rdma_progress(void)
779804
780805 OPAL_THREAD_SCOPED_LOCK (& default_module .mutex , ACTION1 );
781806
807+ /* Note in ACTION2, we treated btl_send's return value of opal_success
808+ * and 1 the same. This is because:
809+ *
810+ * btl_send return OPAL_SUCCESS when that the descriptor has been queued for send, and
811+ * descriptor's callback will be called upon completion.
812+ *
813+ * btl_send return 1 when the descriptor has been sent and descriptor's callback has been
814+ * called if MCA_BTL_DES_SEND_ALWAYS_CALLBACK is set on the descriptor's flags.
815+ *
816+ * When creating the initiator descriptor, we specified MCA_BTL_DES_SEND_ALWAYS_CALLBACK,
817+ * therefore for us, btl_send's returning 1 is the same as it returning OPAL_SUCCESS.
818+ */
782819#define ACTION2 \
783820 mca_btl_base_am_rdma_queued_descriptor_t *descriptor, *next; \
784821 OPAL_LIST_FOREACH_SAFE (descriptor, next, \
@@ -791,7 +828,7 @@ static int mca_btl_base_am_rdma_progress(void)
791828 descriptor->endpoint, \
792829 descriptor->descriptor, \
793830 mca_btl_base_rdma_tag(context->type)); \
794- if (OPAL_SUCCESS == ret) { \
831+ if (OPAL_SUCCESS == ret || 1 == ret ) { \
795832 opal_list_remove_item(&default_module.queued_initiator_descriptors, \
796833 &descriptor->super); \
797834 } \
0 commit comments