@@ -64,6 +64,7 @@ struct ucp_proto_perf_node {
6464
6565/* Protocol information table */
6666typedef struct {
67+ char counter_str [32 ];
6768 char range_str [32 ];
6869 char desc [UCP_PROTO_DESC_STR_MAX ];
6970 char config [UCP_PROTO_CONFIG_STR_MAX ];
@@ -156,11 +157,16 @@ static void ucp_proto_table_row_separator(ucs_string_buffer_t *strb,
156157}
157158
158159static int ucp_proto_debug_is_info_enabled (ucp_context_h context ,
159- const char * select_param_str )
160+ const char * select_param_str ,
161+ int show_used )
160162{
161163 const char * proto_info_config = context -> config .ext .proto_info ;
162164 int bool_value ;
163165
166+ if (show_used ) {
167+ return context -> config .trace_used_proto_selections ;
168+ }
169+
164170 /* Handle "auto" - enable when log level is DEBUG or higher */
165171 if (!strcasecmp (proto_info_config , "auto" )) {
166172 return ucs_log_is_enabled (UCS_LOG_LEVEL_DEBUG );
@@ -175,29 +181,74 @@ static int ucp_proto_debug_is_info_enabled(ucp_context_h context,
175181 return fnmatch (proto_info_config , select_param_str , FNM_CASEFOLD ) == 0 ;
176182}
177183
178- void ucp_proto_select_elem_info (ucp_worker_h worker ,
179- ucp_worker_cfg_index_t ep_cfg_index ,
180- ucp_worker_cfg_index_t rkey_cfg_index ,
181- const ucp_proto_select_param_t * select_param ,
182- const ucp_proto_select_elem_t * select_elem ,
183- int show_all , ucs_string_buffer_t * strb )
184+ static inline int
185+ ucp_proto_select_elem_has_selections (const ucp_proto_select_elem_t * select_elem )
186+ {
187+ const ucp_proto_threshold_elem_t * thresh_elem = select_elem -> thresholds ;
188+
189+ do {
190+ if (thresh_elem -> proto_config .selections > 0 ) {
191+ return 1 ;
192+ }
193+ } while ((thresh_elem ++ )-> max_msg_length < SIZE_MAX );
194+
195+ return 0 ;
196+ }
197+
198+ static void
199+ ucp_proto_selections_dump (ucp_worker_h worker ,
200+ const ucp_proto_query_attr_t * proto_attr ,
201+ const ucp_proto_select_param_t * select_param ,
202+ char * counter_str , size_t size , int show_used )
203+ {
204+ ucp_operation_id_t op_id ;
205+
206+ if (!show_used ) {
207+ * counter_str = '\0' ;
208+ return ;
209+ }
210+
211+ /* Short active messages protocol selections are not counted */
212+ op_id = ucp_proto_select_op_id (select_param );
213+ if ((op_id == UCP_OP_ID_AM_SEND || op_id == UCP_OP_ID_AM_SEND_REPLY ) &&
214+ strstr (proto_attr -> desc , "short" ) != NULL ) {
215+ ucs_assert (proto_attr -> selections == 0 );
216+ * counter_str = '\0' ;
217+ return ;
218+ }
219+
220+ ucs_snprintf_safe (counter_str , size , "%u " , proto_attr -> selections );
221+ }
222+
223+ void
224+ ucp_proto_select_elem_info (ucp_worker_h worker ,
225+ ucp_worker_cfg_index_t ep_cfg_index ,
226+ ucp_worker_cfg_index_t rkey_cfg_index ,
227+ const ucp_proto_select_param_t * select_param ,
228+ const ucp_proto_select_elem_t * select_elem ,
229+ int show_all , int show_used , ucs_string_buffer_t * strb )
184230{
185231 UCS_STRING_BUFFER_ONSTACK (ep_cfg_strb , UCP_PROTO_CONFIG_STR_MAX );
186232 UCS_STRING_BUFFER_ONSTACK (sel_param_strb , UCP_PROTO_CONFIG_STR_MAX );
187- static const char * info_row_fmt = "| %*s | %-*s | %-*s |\n" ;
233+ static const char * info_row_fmt = "| %s% *s | %-*s | %-*s |\n" ;
188234 ucp_proto_info_table_t table ;
189235 int hdr_col_width [2 ], col_width [3 ];
190236 ucp_proto_query_attr_t proto_attr ;
191237 ucp_proto_info_row_t * row_elem ;
192238 size_t range_start , range_end ;
193239 int proto_valid ;
194240
241+ if (show_used && !ucp_proto_select_elem_has_selections (select_elem )) {
242+ return ;
243+ }
244+
195245 ucp_proto_select_param_dump (worker , ep_cfg_index , rkey_cfg_index ,
196246 select_param , ucp_operation_descs , & ep_cfg_strb ,
197247 & sel_param_strb );
198248 if (!show_all &&
199249 !ucp_proto_debug_is_info_enabled (
200- worker -> context , ucs_string_buffer_cstr (& sel_param_strb ))) {
250+ worker -> context , ucs_string_buffer_cstr (& sel_param_strb ),
251+ show_used )) {
201252 return ;
202253 }
203254
@@ -228,7 +279,12 @@ void ucp_proto_select_elem_info(ucp_worker_h worker,
228279 ucs_memunits_range_str (range_start , range_end , row_elem -> range_str ,
229280 sizeof (row_elem -> range_str ));
230281
231- col_width [0 ] = ucs_max (col_width [0 ], strlen (row_elem -> range_str ));
282+ ucp_proto_selections_dump (worker , & proto_attr , select_param ,
283+ row_elem -> counter_str ,
284+ sizeof (row_elem -> counter_str ), show_used );
285+
286+ col_width [0 ] = ucs_max (col_width [0 ], strlen (row_elem -> counter_str ) +
287+ strlen (row_elem -> range_str ));
232288 col_width [1 ] = ucs_max (col_width [1 ], strlen (row_elem -> desc ));
233289 col_width [2 ] = ucs_max (col_width [2 ], strlen (row_elem -> config ));
234290 } while (range_end != SIZE_MAX );
@@ -250,7 +306,8 @@ void ucp_proto_select_elem_info(ucp_worker_h worker,
250306 /* Print contents */
251307 ucp_proto_table_row_separator (strb , col_width , 3 );
252308 ucs_array_for_each (row_elem , & table ) {
253- ucs_string_buffer_appendf (strb , info_row_fmt , col_width [0 ],
309+ ucs_string_buffer_appendf (strb , info_row_fmt , row_elem -> counter_str ,
310+ col_width [0 ] - strlen (row_elem -> counter_str ),
254311 row_elem -> range_str , col_width [1 ],
255312 row_elem -> desc , col_width [2 ],
256313 row_elem -> config );
@@ -271,7 +328,7 @@ void ucp_proto_select_info(ucp_worker_h worker,
271328
272329 kh_foreach (proto_select -> hash , key .u64 , select_elem ,
273330 ucp_proto_select_elem_info (worker , ep_cfg_index , rkey_cfg_index ,
274- & key .param , & select_elem , show_all ,
331+ & key .param , & select_elem , show_all , 0 ,
275332 strb );
276333 ucs_string_buffer_appendf (strb , "\n" ))
277334}
@@ -973,7 +1030,7 @@ ucp_proto_select_write_info(ucp_worker_h worker,
9731030 ucp_operation_names , & ep_cfg_strb ,
9741031 & sel_param_strb );
9751032 if (!ucp_proto_debug_is_info_enabled (
976- worker -> context , ucs_string_buffer_cstr (& sel_param_strb ))) {
1033+ worker -> context , ucs_string_buffer_cstr (& sel_param_strb ), 0 )) {
9771034 goto out ;
9781035 }
9791036
@@ -1038,17 +1095,19 @@ ucp_proto_select_write_info(ucp_worker_h worker,
10381095}
10391096
10401097void ucp_proto_select_elem_trace (ucp_worker_h worker ,
1041- ucp_worker_cfg_index_t ep_cfg_index ,
1042- ucp_worker_cfg_index_t rkey_cfg_index ,
10431098 const ucp_proto_select_param_t * select_param ,
1044- ucp_proto_select_elem_t * select_elem )
1099+ const ucp_proto_select_elem_t * select_elem ,
1100+ int show_used )
10451101{
1046- ucs_string_buffer_t strb = UCS_STRING_BUFFER_INITIALIZER ;
1102+ const ucp_proto_config_t * proto_config = & select_elem -> thresholds [0 ].proto_config ;
1103+ ucp_worker_cfg_index_t ep_cfg_index = proto_config -> ep_cfg_index ;
1104+ ucp_worker_cfg_index_t rkey_cfg_index = proto_config -> rkey_cfg_index ;
1105+ ucs_string_buffer_t strb = UCS_STRING_BUFFER_INITIALIZER ;
10471106 char * line ;
10481107
10491108 /* Print human-readable protocol selection table to the log */
10501109 ucp_proto_select_elem_info (worker , ep_cfg_index , rkey_cfg_index ,
1051- select_param , select_elem , 0 , & strb );
1110+ select_param , select_elem , 0 , show_used , & strb );
10521111 ucs_string_buffer_for_each_token (line , & strb , "\n" ) {
10531112 ucs_log_print_compact (line );
10541113 }
0 commit comments