@@ -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,41 +157,84 @@ 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 if (ucs_config_sscanf_bool (proto_info_config , & bool_value , NULL )) {
165171 return bool_value ;
166172 }
167173
168174 return fnmatch (proto_info_config , select_param_str , FNM_CASEFOLD ) == 0 ;
169175}
170176
171- void ucp_proto_select_elem_info (ucp_worker_h worker ,
172- ucp_worker_cfg_index_t ep_cfg_index ,
173- ucp_worker_cfg_index_t rkey_cfg_index ,
174- const ucp_proto_select_param_t * select_param ,
175- const ucp_proto_select_elem_t * select_elem ,
176- int show_all , ucs_string_buffer_t * strb )
177+ static inline int
178+ ucp_proto_select_elem_has_selections (const ucp_proto_select_elem_t * select_elem )
179+ {
180+ const ucp_proto_threshold_elem_t * thresh_elem = select_elem -> thresholds ;
181+
182+ do {
183+ if (thresh_elem -> proto_config .selections > 0 ) {
184+ return 1 ;
185+ }
186+ } while ((thresh_elem ++ )-> max_msg_length < SIZE_MAX );
187+
188+ return 0 ;
189+ }
190+
191+ static void
192+ ucp_proto_selections_dump (const ucp_proto_query_attr_t * proto_attr ,
193+ char * counter_str , size_t size , int show_used )
194+ {
195+ unsigned max_selections ;
196+
197+ if (!show_used ) {
198+ * counter_str = '\0' ;
199+ return ;
200+ }
201+
202+ max_selections = (strstr (proto_attr -> desc , "short" ) != NULL ) ?
203+ 1 : UCP_PROTO_SELECTIONS_COUNT_MAX ;
204+
205+ ucs_snprintf_safe (counter_str , size , "%u%s " , proto_attr -> selections ,
206+ (proto_attr -> selections >= max_selections ? "+" : "" ));
207+ }
208+
209+ void
210+ ucp_proto_select_elem_info (ucp_worker_h worker ,
211+ ucp_worker_cfg_index_t ep_cfg_index ,
212+ ucp_worker_cfg_index_t rkey_cfg_index ,
213+ const ucp_proto_select_param_t * select_param ,
214+ const ucp_proto_select_elem_t * select_elem ,
215+ int show_all , int show_used , ucs_string_buffer_t * strb )
177216{
178217 UCS_STRING_BUFFER_ONSTACK (ep_cfg_strb , UCP_PROTO_CONFIG_STR_MAX );
179218 UCS_STRING_BUFFER_ONSTACK (sel_param_strb , UCP_PROTO_CONFIG_STR_MAX );
180- static const char * info_row_fmt = "| %*s | %-*s | %-*s |\n" ;
219+ static const char * info_row_fmt = "| %s% *s | %-*s | %-*s |\n" ;
181220 ucp_proto_info_table_t table ;
182221 int hdr_col_width [2 ], col_width [3 ];
183222 ucp_proto_query_attr_t proto_attr ;
184223 ucp_proto_info_row_t * row_elem ;
185224 size_t range_start , range_end ;
186225 int proto_valid ;
187226
227+ if (show_used && !ucp_proto_select_elem_has_selections (select_elem )) {
228+ return ;
229+ }
230+
188231 ucp_proto_select_param_dump (worker , ep_cfg_index , rkey_cfg_index ,
189232 select_param , ucp_operation_descs , & ep_cfg_strb ,
190233 & sel_param_strb );
191234 if (!show_all &&
192235 !ucp_proto_debug_is_info_enabled (
193- worker -> context , ucs_string_buffer_cstr (& sel_param_strb ))) {
236+ worker -> context , ucs_string_buffer_cstr (& sel_param_strb ),
237+ show_used )) {
194238 return ;
195239 }
196240
@@ -221,7 +265,11 @@ void ucp_proto_select_elem_info(ucp_worker_h worker,
221265 ucs_memunits_range_str (range_start , range_end , row_elem -> range_str ,
222266 sizeof (row_elem -> range_str ));
223267
224- col_width [0 ] = ucs_max (col_width [0 ], strlen (row_elem -> range_str ));
268+ ucp_proto_selections_dump (& proto_attr , row_elem -> counter_str ,
269+ sizeof (row_elem -> counter_str ), show_used );
270+
271+ col_width [0 ] = ucs_max (col_width [0 ], strlen (row_elem -> counter_str ) +
272+ strlen (row_elem -> range_str ));
225273 col_width [1 ] = ucs_max (col_width [1 ], strlen (row_elem -> desc ));
226274 col_width [2 ] = ucs_max (col_width [2 ], strlen (row_elem -> config ));
227275 } while (range_end != SIZE_MAX );
@@ -243,7 +291,8 @@ void ucp_proto_select_elem_info(ucp_worker_h worker,
243291 /* Print contents */
244292 ucp_proto_table_row_separator (strb , col_width , 3 );
245293 ucs_array_for_each (row_elem , & table ) {
246- ucs_string_buffer_appendf (strb , info_row_fmt , col_width [0 ],
294+ ucs_string_buffer_appendf (strb , info_row_fmt , row_elem -> counter_str ,
295+ col_width [0 ] - strlen (row_elem -> counter_str ),
247296 row_elem -> range_str , col_width [1 ],
248297 row_elem -> desc , col_width [2 ],
249298 row_elem -> config );
@@ -264,7 +313,7 @@ void ucp_proto_select_info(ucp_worker_h worker,
264313
265314 kh_foreach (proto_select -> hash , key .u64 , select_elem ,
266315 ucp_proto_select_elem_info (worker , ep_cfg_index , rkey_cfg_index ,
267- & key .param , & select_elem , show_all ,
316+ & key .param , & select_elem , show_all , 0 ,
268317 strb );
269318 ucs_string_buffer_appendf (strb , "\n" ))
270319}
@@ -966,7 +1015,7 @@ ucp_proto_select_write_info(ucp_worker_h worker,
9661015 ucp_operation_names , & ep_cfg_strb ,
9671016 & sel_param_strb );
9681017 if (!ucp_proto_debug_is_info_enabled (
969- worker -> context , ucs_string_buffer_cstr (& sel_param_strb ))) {
1018+ worker -> context , ucs_string_buffer_cstr (& sel_param_strb ), 0 )) {
9701019 goto out ;
9711020 }
9721021
@@ -1031,17 +1080,19 @@ ucp_proto_select_write_info(ucp_worker_h worker,
10311080}
10321081
10331082void ucp_proto_select_elem_trace (ucp_worker_h worker ,
1034- ucp_worker_cfg_index_t ep_cfg_index ,
1035- ucp_worker_cfg_index_t rkey_cfg_index ,
10361083 const ucp_proto_select_param_t * select_param ,
1037- ucp_proto_select_elem_t * select_elem )
1084+ const ucp_proto_select_elem_t * select_elem ,
1085+ int show_used )
10381086{
1039- ucs_string_buffer_t strb = UCS_STRING_BUFFER_INITIALIZER ;
1087+ const ucp_proto_config_t * proto_config = & select_elem -> thresholds [0 ].proto_config ;
1088+ ucp_worker_cfg_index_t ep_cfg_index = proto_config -> ep_cfg_index ;
1089+ ucp_worker_cfg_index_t rkey_cfg_index = proto_config -> rkey_cfg_index ;
1090+ ucs_string_buffer_t strb = UCS_STRING_BUFFER_INITIALIZER ;
10401091 char * line ;
10411092
10421093 /* Print human-readable protocol selection table to the log */
10431094 ucp_proto_select_elem_info (worker , ep_cfg_index , rkey_cfg_index ,
1044- select_param , select_elem , 0 , & strb );
1095+ select_param , select_elem , 0 , show_used , & strb );
10451096 ucs_string_buffer_for_each_token (line , & strb , "\n" ) {
10461097 ucs_log_print_compact (line );
10471098 }
0 commit comments