[igt-dev] [Intel-gfx] [PATCH i-g-t 3/3] intel_gpu_top: Show non-normalized client usage in numeric mode

Kamil Konieczny kamil.konieczny at linux.intel.com
Fri Apr 14 15:28:14 UTC 2023


On 2023-03-28 at 13:54:29 +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> When numeric display is selected in the interactive mode it is more
> descriptive to show client's non-normalized (by number of engines per
> class) usage. Rendering of the visual representation (bar) is kept the
> same.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> ---
>  tools/intel_gpu_top.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 36da016c3df0..b6827b3de9bd 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -1275,14 +1275,14 @@ static void n_spaces(const unsigned int n)
>  }
>  
>  static void
> -print_percentage_bar(double percent, int max_len, bool numeric)
> +print_percentage_bar(double percent, double max, int max_len, bool numeric)
>  {
>  	int bar_len, i, len = max_len - 2;
>  	const int w = 8;
>  
>  	assert(max_len > 0);
>  
> -	bar_len = ceil(w * percent * len / 100.0);
> +	bar_len = ceil(w * percent * len / max);
>  	if (bar_len > w * len)
>  		bar_len = w * len;
>  
> @@ -2010,7 +2010,8 @@ print_engine(struct engines *engines, unsigned int i, double t,
>  			      engine->display_name, engine_items[0].buf);
>  
>  		val = pmu_calc(&engine->busy.val, 1e9, t, 100);
> -		print_percentage_bar(val, con_w > len ? con_w - len : 0, false);
> +		print_percentage_bar(val, 100.0, con_w > len ? con_w - len : 0,
> +				     false);
>  
>  		printf("%s\n", buf);
>  
> @@ -2292,23 +2293,24 @@ print_client(struct client *c, struct engines *engines, double t, int lines,
>  		       clients->max_name_len, c->print_name);
>  
>  		for (i = 0; c->samples > 1 && i < clients->num_classes; i++) {
> -			double pct;
> +			double pct, max;
>  
>  			if (!clients->class[i].num_engines)
>  				continue; /* Assert in the ideal world. */
>  
> -			pct = (double)c->val[i] / period_us / 1e3 * 100 /
> -			      clients->class[i].num_engines;
> +			pct = (double)c->val[i] / period_us / 1e3 * 100;
>  
>  			/*
>  			 * Guard against possible time-drift between sampling
>  			 * client data and time we obtained our time-delta from
>  			 * PMU.
>  			 */
> -			if (pct > 100.0)
> -				pct = 100.0;
> +			max = 100.0 * clients->class[i].num_engines;
> +			if (pct > max)
> +				pct = max;
>  
> -			print_percentage_bar(pct, *class_w, numeric_clients);
> +			print_percentage_bar(pct, max, *class_w,
> +					     numeric_clients);
>  		}
>  
>  		putchar('\n');
> -- 
> 2.37.2
> 


More information about the igt-dev mailing list