@@ -98,6 +98,7 @@ ompi_mtl_ofi_component_register(void)
9898{
9999 int ret ;
100100 mca_base_var_enum_t * new_enum = NULL ;
101+ char * desc ;
101102
102103 param_priority = 25 ; /* for now give a lower priority than the psm mtl */
103104 mca_base_component_var_register (& mca_mtl_ofi_component .super .mtl_version ,
@@ -125,6 +126,18 @@ ompi_mtl_ofi_component_register(void)
125126 MCA_BASE_VAR_SCOPE_READONLY ,
126127 & prov_exclude );
127128
129+ ompi_mtl_ofi .ofi_progress_event_count = 100 ;
130+ asprintf (& desc , "Max number of events to read each call to OFI progress (default: %d events will be read per OFI progress call)" , ompi_mtl_ofi .ofi_progress_event_count );
131+ mca_base_component_var_register (& mca_mtl_ofi_component .super .mtl_version ,
132+ "progress_event_cnt" ,
133+ desc ,
134+ MCA_BASE_VAR_TYPE_INT , NULL , 0 , 0 ,
135+ OPAL_INFO_LVL_6 ,
136+ MCA_BASE_VAR_SCOPE_READONLY ,
137+ & ompi_mtl_ofi .ofi_progress_event_count );
138+
139+ free (desc );
140+
128141 ret = mca_base_var_enum_create ("control_prog_type" , control_prog_type , & new_enum );
129142 if (OPAL_SUCCESS != ret ) {
130143 return ret ;
@@ -465,6 +478,19 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
465478 * - dynamic memory-spanning memory region
466479 */
467480 cq_attr .format = FI_CQ_FORMAT_TAGGED ;
481+
482+ /**
483+ * If a user has set an ofi_progress_event_count > the default, then
484+ * the CQ size hint is set to the user's desired value such that
485+ * the CQ created will have enough slots to store up to
486+ * ofi_progress_event_count events. If a user has not set the
487+ * ofi_progress_event_count, then the provider is trusted to set a
488+ * default high CQ size and the CQ size hint is left unspecified.
489+ */
490+ if (ompi_mtl_ofi .ofi_progress_event_count > 100 ) {
491+ cq_attr .size = ompi_mtl_ofi .ofi_progress_event_count ;
492+ }
493+
468494 ret = fi_cq_open (ompi_mtl_ofi .domain , & cq_attr , & ompi_mtl_ofi .cq , NULL );
469495 if (ret ) {
470496 opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
@@ -473,6 +499,17 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
473499 goto error ;
474500 }
475501
502+ /**
503+ * Allocate memory for storing the CQ events read in OFI progress.
504+ */
505+ ompi_mtl_ofi .progress_entries = calloc (ompi_mtl_ofi .ofi_progress_event_count , sizeof (struct fi_cq_tagged_entry ));
506+ if (OPAL_UNLIKELY (!ompi_mtl_ofi .progress_entries )) {
507+ opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
508+ "%s:%d: alloc of CQ event storage failed: %s\n" ,
509+ __FILE__ , __LINE__ , strerror (errno ));
510+ goto error ;
511+ }
512+
476513 /**
477514 * The remote fi_addr will be stored in the ofi_endpoint struct.
478515 */
@@ -595,6 +632,10 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
595632 if (ompi_mtl_ofi .fabric ) {
596633 (void ) fi_close ((fid_t )ompi_mtl_ofi .fabric );
597634 }
635+ if (ompi_mtl_ofi .progress_entries ) {
636+ free (ompi_mtl_ofi .progress_entries );
637+ }
638+
598639 return NULL ;
599640}
600641
@@ -626,6 +667,8 @@ ompi_mtl_ofi_finalize(struct mca_mtl_base_module_t *mtl)
626667 goto finalize_err ;
627668 }
628669
670+ free (ompi_mtl_ofi .progress_entries );
671+
629672 return OMPI_SUCCESS ;
630673
631674finalize_err :
0 commit comments