[PATCH i-g-t] lib/intel_compute: Do not assume engine class

Nirmoy Das nirmoy.das at intel.com
Mon Mar 18 10:07:47 UTC 2024


On 3/18/2024 10:55 AM, Zbigniew Kempczyński wrote:
> On Thu, Mar 14, 2024 at 10:37:48PM +0100, Nirmoy Das wrote:
>> Let the test decide what engine class to use instead of
>> a lib function deciding it for tests.
>>
>> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
>> Cc: Janga Rahul Kumar <janga.rahul.kumar at intel.com>
>> Signed-off-by: Nirmoy Das <nirmoy.das at intel.com>
>> ---
>>   lib/intel_compute.c      | 20 +++-----------------
>>   tests/intel/xe_compute.c | 21 ++++++++++++++++++++-
>>   2 files changed, 23 insertions(+), 18 deletions(-)
>>
>> diff --git a/lib/intel_compute.c b/lib/intel_compute.c
>> index 9d3b97efe..c96e60027 100644
>> --- a/lib/intel_compute.c
>> +++ b/lib/intel_compute.c
>> @@ -81,24 +81,10 @@ static void bo_execenv_create(int fd, struct bo_execenv *execenv,
>>   	execenv->driver = get_intel_driver(fd);
>>   
>>   	if (execenv->driver == INTEL_DRIVER_XE) {
>> +		igt_fail_on(eci == NULL);
>>   		execenv->vm = xe_vm_create(fd, 0, 0);
>> -
>> -		if (eci) {
>> -			execenv->exec_queue = xe_exec_queue_create(fd, execenv->vm,
>> -								   eci, 0);
>> -		} else {
>> -			uint16_t engine_class;
>> -			uint32_t devid = intel_get_drm_devid(fd);
>> -			const struct intel_device_info *info = intel_get_device_info(devid);
>> -
>> -			if (info->graphics_ver >= 12 && info->graphics_rel < 60)
>> -				engine_class = DRM_XE_ENGINE_CLASS_RENDER;
>> -			else
>> -				engine_class = DRM_XE_ENGINE_CLASS_COMPUTE;
>> -
>> -			execenv->exec_queue = xe_exec_queue_create_class(fd, execenv->vm,
>> -									 engine_class);
>> -		}
>> +		execenv->exec_queue = xe_exec_queue_create(fd, execenv->vm, eci,
>> +							   0);
>>   	}
>>   }
>>   
> I don't like this. You're moving logic which is common for compute
> users outside, giving possibility to pass invalid queue.

>   I vote
> to not merge this.

Yes, I waited for that :) Let's ignore the patch. I am fine with having 
a default eci if user doesn't pass anything.,

>
> --
> Zbigniew
>
>> diff --git a/tests/intel/xe_compute.c b/tests/intel/xe_compute.c
>> index 42f42ca0c..cb98b00d5 100644
>> --- a/tests/intel/xe_compute.c
>> +++ b/tests/intel/xe_compute.c
>> @@ -163,9 +163,28 @@ test_compute_kernel_with_ccs_mode(int num_gt)
>>   static void
>>   test_compute_square(int fd)
>>   {
>> -	igt_require_f(run_intel_compute_kernel(fd), "GPU not supported\n");
>> +	struct drm_xe_engine_class_instance *hwe;
>> +	const struct intel_device_info *info;
>> +	uint16_t engine_class;
>> +	uint32_t devid = intel_get_drm_devid(fd);
>> +
>> +	info = intel_get_device_info(devid);
>> +
>> +	if (info->graphics_ver >= 12 && info->graphics_rel < 60)
>> +		engine_class = DRM_XE_ENGINE_CLASS_RENDER;
>> +	else
>> +		engine_class = DRM_XE_ENGINE_CLASS_COMPUTE;
>> +
>> +	xe_for_each_engine(fd, hwe) {
>> +		if (hwe->engine_class != engine_class)
>> +			continue;
>> +
>> +		igt_require_f(xe_run_intel_compute_kernel_on_engine(fd, hwe),
>> +			      "GPU not supported\n");
>> +	}
>>   }
>>   
>> +
>>   igt_main
>>   {
>>   	int xe, num_gt;
>> -- 
>> 2.42.0
>>


More information about the igt-dev mailing list