@@ -325,10 +325,18 @@ ompi_mtl_ofi_isend_callback(struct fi_cq_tagged_entry *wc,
325325 return OMPI_SUCCESS ;
326326}
327327
328- #define MTL_OFI_MAP_COMM_TO_CONTEXT (comm_id , ctxt_id ) \
329- do { \
330- ctxt_id = ompi_mtl_ofi.comm_to_context[comm_id]; \
331- } while (0);
328+ /* Return OFI context ID associated with the specific communicator */
329+ __opal_attribute_always_inline__ static inline int
330+ ompi_mtl_ofi_map_comm_to_ctxt (uint32_t comm_id )
331+ {
332+ /* For non-thread-grouping use case, only one context is used which is
333+ * associated to MPI_COMM_WORLD, so use that. */
334+ if (0 == ompi_mtl_ofi .thread_grouping ) {
335+ comm_id = 0 ;
336+ }
337+
338+ return ompi_mtl_ofi .comm_to_context [comm_id ];
339+ }
332340
333341__opal_attribute_always_inline__ static inline int
334342ompi_mtl_ofi_ssend_recv (ompi_mtl_ofi_request_t * ack_req ,
@@ -342,7 +350,7 @@ ompi_mtl_ofi_ssend_recv(ompi_mtl_ofi_request_t *ack_req,
342350 ssize_t ret = OMPI_SUCCESS ;
343351 int ctxt_id = 0 ;
344352
345- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
353+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (comm -> c_contextid );
346354 set_thread_context (ctxt_id );
347355
348356 ack_req = malloc (sizeof (ompi_mtl_ofi_request_t ));
@@ -397,7 +405,7 @@ ompi_mtl_ofi_send_generic(struct mca_mtl_base_module_t *mtl,
397405 fi_addr_t src_addr = 0 ;
398406 fi_addr_t sep_peer_fiaddr = 0 ;
399407
400- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
408+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (comm -> c_contextid );
401409 set_thread_context (ctxt_id );
402410
403411 /**
@@ -532,7 +540,7 @@ ompi_mtl_ofi_isend_generic(struct mca_mtl_base_module_t *mtl,
532540 ompi_mtl_ofi_request_t * ack_req = NULL ; /* For synchronous send */
533541 fi_addr_t sep_peer_fiaddr = 0 ;
534542
535- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
543+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (comm -> c_contextid );
536544 set_thread_context (ctxt_id );
537545
538546 ofi_req -> event_callback = ompi_mtl_ofi_isend_callback ;
@@ -617,7 +625,7 @@ ompi_mtl_ofi_recv_callback(struct fi_cq_tagged_entry *wc,
617625 ompi_status_public_t * status = NULL ;
618626 struct fi_msg_tagged tagged_msg ;
619627
620- MTL_OFI_MAP_COMM_TO_CONTEXT (ofi_req -> comm -> c_contextid , ctxt_id );
628+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (ofi_req -> comm -> c_contextid );
621629
622630 assert (ofi_req -> super .ompi_req );
623631 status = & ofi_req -> super .ompi_req -> req_status ;
@@ -758,7 +766,7 @@ ompi_mtl_ofi_irecv_generic(struct mca_mtl_base_module_t *mtl,
758766 size_t length ;
759767 bool free_after ;
760768
761- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
769+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (comm -> c_contextid );
762770 set_thread_context (ctxt_id );
763771
764772 if (ofi_cq_data ) {
@@ -884,7 +892,7 @@ ompi_mtl_ofi_imrecv(struct mca_mtl_base_module_t *mtl,
884892 uint64_t msgflags = FI_CLAIM | FI_COMPLETION ;
885893 struct ompi_communicator_t * comm = (* message )-> comm ;
886894
887- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
895+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (comm -> c_contextid );
888896 set_thread_context (ctxt_id );
889897
890898 ompi_ret = ompi_mtl_datatype_recv_buf (convertor ,
@@ -977,7 +985,7 @@ ompi_mtl_ofi_iprobe_generic(struct mca_mtl_base_module_t *mtl,
977985 uint64_t msgflags = FI_PEEK | FI_COMPLETION ;
978986 int ctxt_id = 0 ;
979987
980- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
988+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (comm -> c_contextid );
981989 set_thread_context (ctxt_id );
982990
983991 if (ofi_cq_data ) {
@@ -1066,7 +1074,7 @@ ompi_mtl_ofi_improbe_generic(struct mca_mtl_base_module_t *mtl,
10661074 uint64_t msgflags = FI_PEEK | FI_CLAIM | FI_COMPLETION ;
10671075 int ctxt_id = 0 ;
10681076
1069- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
1077+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (comm -> c_contextid );
10701078 set_thread_context (ctxt_id );
10711079
10721080 ofi_req = malloc (sizeof * ofi_req );
@@ -1168,7 +1176,7 @@ ompi_mtl_ofi_cancel(struct mca_mtl_base_module_t *mtl,
11681176 int ret , ctxt_id = 0 ;
11691177 ompi_mtl_ofi_request_t * ofi_req = (ompi_mtl_ofi_request_t * ) mtl_request ;
11701178
1171- MTL_OFI_MAP_COMM_TO_CONTEXT (ofi_req -> comm -> c_contextid , ctxt_id );
1179+ ctxt_id = ompi_mtl_ofi_map_comm_to_ctxt (ofi_req -> comm -> c_contextid );
11721180
11731181 switch (ofi_req -> type ) {
11741182 case OMPI_MTL_OFI_SEND :
0 commit comments