@@ -327,16 +327,7 @@ ompi_mtl_ofi_isend_callback(struct fi_cq_tagged_entry *wc,
327327
328328#define MTL_OFI_MAP_COMM_TO_CONTEXT (comm_id , ctxt_id ) \
329329 do { \
330- if (ompi_mtl_ofi.thread_grouping && \
331- (!ompi_mtl_ofi.threshold_comm_context_id || \
332- ((uint32_t) ompi_mtl_ofi.threshold_comm_context_id > comm_id))) { \
333- ctxt_id = ompi_mtl_ofi.comm_to_context[comm_id]; \
334- } else if (ompi_mtl_ofi.thread_grouping) { \
335- /* Round-robin assignment of contexts if threshold is reached */ \
336- ctxt_id = comm_id % ompi_mtl_ofi .total_ctxts_used ; \
337- } else { \
338- ctxt_id = 0 ; \
339- } \
330+ ctxt_id = ompi_mtl_ofi.comm_to_context[comm_id]; \
340331 } while (0);
341332
342333__opal_attribute_always_inline__ static inline int
@@ -348,40 +339,40 @@ ompi_mtl_ofi_ssend_recv(ompi_mtl_ofi_request_t *ack_req,
348339 uint64_t * match_bits ,
349340 int tag )
350341{
351- ssize_t ret = OMPI_SUCCESS ;
352- int ctxt_id = 0 ;
342+ ssize_t ret = OMPI_SUCCESS ;
343+ int ctxt_id = 0 ;
353344
354- MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
355- set_thread_context (ctxt_id );
345+ MTL_OFI_MAP_COMM_TO_CONTEXT (comm -> c_contextid , ctxt_id );
346+ set_thread_context (ctxt_id );
356347
357- ack_req = malloc (sizeof (ompi_mtl_ofi_request_t ));
358- assert (ack_req );
348+ ack_req = malloc (sizeof (ompi_mtl_ofi_request_t ));
349+ assert (ack_req );
359350
360- ack_req -> parent = ofi_req ;
361- ack_req -> event_callback = ompi_mtl_ofi_send_ack_callback ;
362- ack_req -> error_callback = ompi_mtl_ofi_send_ack_error_callback ;
351+ ack_req -> parent = ofi_req ;
352+ ack_req -> event_callback = ompi_mtl_ofi_send_ack_callback ;
353+ ack_req -> error_callback = ompi_mtl_ofi_send_ack_error_callback ;
363354
364- ofi_req -> completion_count += 1 ;
355+ ofi_req -> completion_count += 1 ;
365356
366- MTL_OFI_RETRY_UNTIL_DONE (fi_trecv (ompi_mtl_ofi .ofi_ctxt [ctxt_id ].rx_ep ,
367- NULL ,
368- 0 ,
369- NULL ,
370- * src_addr ,
371- * match_bits | ompi_mtl_ofi .sync_send_ack ,
372- 0 , /* Exact match, no ignore bits */
373- (void * ) & ack_req -> ctx ), ret );
374- if (OPAL_UNLIKELY (0 > ret )) {
375- opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
376- "%s:%d: fi_trecv failed: %s(%zd)" ,
377- __FILE__ , __LINE__ , fi_strerror (- ret ), ret );
378- free (ack_req );
379- return ompi_mtl_ofi_get_error (ret );
380- }
357+ MTL_OFI_RETRY_UNTIL_DONE (fi_trecv (ompi_mtl_ofi .ofi_ctxt [ctxt_id ].rx_ep ,
358+ NULL ,
359+ 0 ,
360+ NULL ,
361+ * src_addr ,
362+ * match_bits | ompi_mtl_ofi .sync_send_ack ,
363+ 0 , /* Exact match, no ignore bits */
364+ (void * ) & ack_req -> ctx ), ret );
365+ if (OPAL_UNLIKELY (0 > ret )) {
366+ opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
367+ "%s:%d: fi_trecv failed: %s(%zd)" ,
368+ __FILE__ , __LINE__ , fi_strerror (- ret ), ret );
369+ free (ack_req );
370+ return ompi_mtl_ofi_get_error (ret );
371+ }
381372
382- /* The SYNC_SEND tag bit is set for the send operation only.*/
383- MTL_OFI_SET_SYNC_SEND (* match_bits );
384- return OMPI_SUCCESS ;
373+ /* The SYNC_SEND tag bit is set for the send operation only.*/
374+ MTL_OFI_SET_SYNC_SEND (* match_bits );
375+ return OMPI_SUCCESS ;
385376}
386377
387378__opal_attribute_always_inline__ static inline int
@@ -1242,13 +1233,15 @@ static int ompi_mtl_ofi_init_contexts(struct mca_mtl_base_module_t *mtl,
12421233 }
12431234
12441235 /*
1245- * We only create upto Max number of contexts allowed by provider .
1236+ * We only create upto Max number of contexts asked for by the user .
12461237 * If user enables thread grouping feature and creates more number of
1247- * communicators than we have contexts, then we set the threshold
1248- * context_id so we know to use context 0 for operations involving these
1249- * "extra" communicators .
1238+ * communicators than available contexts, then we set the threshold
1239+ * context_id so that new communicators created beyond the threshold
1240+ * will be assigned to contexts in a round-robin fashion .
12501241 */
1251- if (ompi_mtl_ofi .max_ctx_cnt <= ctxt_id ) {
1242+ if (ompi_mtl_ofi .num_ofi_contexts <= ompi_mtl_ofi .total_ctxts_used ) {
1243+ ompi_mtl_ofi .comm_to_context [comm -> c_contextid ] = comm -> c_contextid %
1244+ ompi_mtl_ofi .total_ctxts_used ;
12521245 if (!ompi_mtl_ofi .threshold_comm_context_id ) {
12531246 ompi_mtl_ofi .threshold_comm_context_id = comm -> c_contextid ;
12541247
0 commit comments