[PATCH 2/3] tests/intel/xe_compute: Added loop_duration_2s subtest

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Thu Aug 21 10:30:54 UTC 2025


On Tue, Aug 19, 2025 at 07:43:37AM +0000, nishit.sharma at intel.com wrote:
> From: Nishit Sharma <nishit.sharma at intel.com>
> 
> Added loop_duration_2s subtest which fills kernel and loop_kernel_duration
> members of structure user_execenv and passed as member in
> xe_run_intel_compute_kernel_on_engine() to schedule Job on CCS engine.
> This also verifies GPU is executing loop_kernel shader when sleep for
> loop_kernel_duration is called. loop_kernel shader is available on
> xe2lpg and xe3lpg pipeline. Verified GPU is working during sleep using
> gputop. Test will skip for xehpc, xehp, xelpg pipeline as they don't have
> loop_kernel shader. This checks whether the test executed successfully
> in elapsed_duration  >= loop_kernel_duration + 0.2 seconds or failed in
> duration - 0.2 < elapsed_duration. elapsed_duration is time taken on
> scheduling and execution of workload in single iteration on single
> single instance of CCS.
> 
> Signed-off-by: Nishit Sharma <nishit.sharma at intel.com>
> ---
>  tests/intel/xe_compute.c | 59 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/tests/intel/xe_compute.c b/tests/intel/xe_compute.c
> index 5e9140902..998a58cf4 100644
> --- a/tests/intel/xe_compute.c
> +++ b/tests/intel/xe_compute.c
> @@ -19,6 +19,8 @@
>  #include "xe/xe_ioctl.h"
>  #include "xe/xe_query.h"
>  
> +#define LOOP_DURATION_2s	(1000000ull *2)
> +
>  static int gt_sysfs_open(int gt)
>  {
>  	int fd, gt_fd;
> @@ -186,6 +188,59 @@ test_compute_kernel_with_ccs_mode(void)
>  	igt_require(num_gt_with_ccs_mode > 0);
>  }
>  
> +static double elapsed(const struct timeval *start,
> +		      const struct timeval *end)
> +{
> +	return (end->tv_sec - start->tv_sec) + 1e-6*(end->tv_usec - start->tv_usec);
> +}
> +
> +/**
> + * SUBTEST: loop-duration-2s
> + * Functionality: OpenCL kernel
> + * Description:
> + *	Run an openCL loop Kernel that for duration,
> + *	set in loop_kernel_duration ..
> + */
> +static void
> +test_compute_kernel_loop(uint64_t loop_duration)
> +{
> +	int fd;
> +	unsigned int ip_ver;
> +	const struct intel_compute_kernels *kernels;
> +	struct user_execenv execenv = { 0 };
> +	struct drm_xe_engine_class_instance *hwe;
> +	struct timeval start, end;
> +
> +	fd = drm_open_driver(DRIVER_XE);

This should come from the fixture and test should be in part
before drm_close_driver();

> +	ip_ver = intel_graphics_ver(intel_get_drm_devid(fd));
> +	kernels = intel_compute_square_kernels;
> +
> +	while (kernels->kernel) {
> +		if (ip_ver == kernels->ip_ver)
> +			break;
> +		kernels++;
> +	}
> +
> +	/* loop_kernel_duration used as sleep to make EU busy for loop_duration */
> +	execenv.loop_kernel_duration = loop_duration;
> +	execenv.kernel = kernels->loop_kernel;
> +	execenv.kernel_size = kernels->loop_kernel_size;
> +
> +	xe_for_each_engine(fd, hwe) {
> +		if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COMPUTE)
> +			continue;
> +
> +		igt_info("Running loop_kernel on ccs engine %d\n", hwe->engine_instance);
> +		gettimeofday(&start, NULL);
> +		igt_assert_f(xe_run_intel_compute_kernel_on_engine(fd, hwe, &execenv, EXECENV_PREF_SYSTEM),
> +				"Unable to run compute kernel successfully\n");
> +		gettimeofday(&end, NULL);
> +		igt_assert((double)(loop_duration/LOOP_DURATION_2s - 0.2) < elapsed(&start, &end) &&
> +				    (double)(loop_duration/LOOP_DURATION_2s + 0.2));

It would be good to define DURATION_MARGIN == 0.2 and use here.

> +	}
> +	drm_close_driver(fd);

This obviously can be removed when you use fd from opening fixture.

With these nits addressed:

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew

> +}
> +
>  /**
>   * SUBTEST: compute-square
>   * Mega feature: WMTP
> @@ -223,4 +278,8 @@ igt_main
>  
>  	igt_subtest("ccs-mode-compute-kernel")
>  		test_compute_kernel_with_ccs_mode();
> +
> +	/* To test compute function stops after loop_kernel_duration */
> +	igt_subtest("loop-duration-2s")
> +		test_compute_kernel_loop(LOOP_DURATION_2s);
>  }
> -- 
> 2.43.0
> 


More information about the igt-dev mailing list