[PATCH v3 i-g-t 6/6] benchmarks/gem_wsim: Option to list physical engines

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed Jul 31 15:02:47 UTC 2024


Hi Marcin,
On 2024-07-29 at 19:52:19 +0200, Marcin Bernatowicz wrote:
> Added command line option (-l) to list physical engines.
> 
> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz at linux.intel.com>

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

> ---
>  benchmarks/gem_wsim.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> index 0c022f9ce..c4fd00a6a 100644
> --- a/benchmarks/gem_wsim.c
> +++ b/benchmarks/gem_wsim.c
> @@ -2989,6 +2989,7 @@ static void print_help(void)
>  "  -f <scale>        Scale factor for batch durations.\n"
>  "  -F <scale>        Scale factor for delays.\n"
>  "  -L                List GPUs.\n"
> +"  -l                List physical engines.\n"
>  "  -D <gpu>          One of the GPUs from -L.\n"
>  	);
>  }
> @@ -3048,10 +3049,42 @@ add_workload_arg(struct w_arg *w_args, unsigned int nr_args, char *w_arg,
>  	return w_args;
>  }
>  
> +static void list_engines(void)
> +{
> +	struct intel_engines *engines = query_engines();
> +	int engine_class_count[NUM_ENGINE_CLASSES] = {};
> +	unsigned int i;
> +
> +	for (i = 0; i < engines->nr_engines; ++i) {
> +		igt_assert_lt(engines->engines[i].engine_class, NUM_ENGINE_CLASSES);
> +		engine_class_count[engines->engines[i].engine_class]++;
> +	}
> +
> +	for (i = 0; i < engines->nr_engines; ++i) {
> +		if (engine_class_count[engines->engines[i].engine_class] > 1)
> +			printf("%s%u",
> +			       intel_engine_class_string(engines->engines[i].engine_class),
> +			       engines->engines[i].engine_instance + 1);
> +		else
> +			printf("%s",
> +			       intel_engine_class_string(engines->engines[i].engine_class));
> +
> +		if (is_xe && engines->engines[i].gt_id)
> +			printf("-%u", engines->engines[i].gt_id);
> +
> +		if (verbose > 3)
> +			printf(" [%d:%d:%d]", engines->engines[i].engine_class,
> +			       engines->engines[i].engine_instance,
> +			       engines->engines[i].gt_id);
> +		printf("\n");
> +	}
> +}
> +
>  int main(int argc, char **argv)
>  {
>  	struct igt_device_card card = { };
>  	bool list_devices_arg = false;
> +	bool list_engines_arg = false;
>  	unsigned int repeat = 1;
>  	unsigned int clients = 1;
>  	unsigned int flags = 0;
> @@ -3074,11 +3107,14 @@ int main(int argc, char **argv)
>  	master_prng = time(NULL);
>  
>  	while ((c = getopt(argc, argv,
> -			   "LhqvsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
> +			   "LlhqvsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
>  		switch (c) {
>  		case 'L':
>  			list_devices_arg = true;
>  			break;
> +		case 'l':
> +			list_engines_arg = true;
> +			break;
>  		case 'D':
>  			device_arg = strdup(optarg);
>  			break;
> @@ -3199,6 +3235,11 @@ int main(int argc, char **argv)
>  	if (is_xe)
>  		xe_device_get(fd);
>  
> +	if (list_engines_arg) {
> +		list_engines();
> +		goto out;
> +	}
> +
>  	if (!nr_w_args) {
>  		wsim_err("No workload descriptor(s)!\n");
>  		goto err;
> -- 
> 2.31.1
> 


More information about the igt-dev mailing list