@@ -98,6 +98,7 @@ ompi_mtl_ofi_component_register(void)
98
98
{
99
99
int ret ;
100
100
mca_base_var_enum_t * new_enum = NULL ;
101
+ char * desc ;
101
102
102
103
param_priority = 25 ; /* for now give a lower priority than the psm mtl */
103
104
mca_base_component_var_register (& mca_mtl_ofi_component .super .mtl_version ,
@@ -125,6 +126,18 @@ ompi_mtl_ofi_component_register(void)
125
126
MCA_BASE_VAR_SCOPE_READONLY ,
126
127
& prov_exclude );
127
128
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
+
128
141
ret = mca_base_var_enum_create ("control_prog_type" , control_prog_type , & new_enum );
129
142
if (OPAL_SUCCESS != ret ) {
130
143
return ret ;
@@ -465,6 +478,19 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
465
478
* - dynamic memory-spanning memory region
466
479
*/
467
480
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
+
468
494
ret = fi_cq_open (ompi_mtl_ofi .domain , & cq_attr , & ompi_mtl_ofi .cq , NULL );
469
495
if (ret ) {
470
496
opal_output_verbose (1 , ompi_mtl_base_framework .framework_output ,
@@ -473,6 +499,17 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
473
499
goto error ;
474
500
}
475
501
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
+
476
513
/**
477
514
* The remote fi_addr will be stored in the ofi_endpoint struct.
478
515
*/
@@ -595,6 +632,10 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
595
632
if (ompi_mtl_ofi .fabric ) {
596
633
(void ) fi_close ((fid_t )ompi_mtl_ofi .fabric );
597
634
}
635
+ if (ompi_mtl_ofi .progress_entries ) {
636
+ free (ompi_mtl_ofi .progress_entries );
637
+ }
638
+
598
639
return NULL ;
599
640
}
600
641
@@ -626,6 +667,8 @@ ompi_mtl_ofi_finalize(struct mca_mtl_base_module_t *mtl)
626
667
goto finalize_err ;
627
668
}
628
669
670
+ free (ompi_mtl_ofi .progress_entries );
671
+
629
672
return OMPI_SUCCESS ;
630
673
631
674
finalize_err :
0 commit comments