[PATCH i-g-t,v2 1/6] lib/intel_compute: Make loop count a parameter

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Feb 25 09:22:54 UTC 2025


On Mon, Feb 24, 2025 at 03:46:09PM +0100, Francois Dugast wrote:
> The loop count was previously hardcoded as 0x400 in *create_indirect_data()
> functions. Turn it into a parameterized value that gets used during the
> batch buffer generation so that the function user can specify the count.
> 
> Signed-off-by: Francois Dugast <francois.dugast at intel.com>

LGTM,

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

--
Zbigniew

> ---
>  lib/intel_compute.c | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/intel_compute.c b/lib/intel_compute.c
> index f46de1074..b698bf77d 100644
> --- a/lib/intel_compute.c
> +++ b/lib/intel_compute.c
> @@ -293,7 +293,8 @@ static void bo_execenv_exec(struct bo_execenv *execenv, uint64_t start_addr)
>  static void create_indirect_data(uint32_t *addr_bo_buffer_batch,
>  				 uint64_t addr_input,
>  				 uint64_t addr_output,
> -				 uint32_t end_value)
> +				 uint32_t end_value,
> +				 unsigned int loop_count)
>  {
>  	uint32_t val = 0;
>  	int b = 0, curr = 0;
> @@ -313,7 +314,7 @@ static void create_indirect_data(uint32_t *addr_bo_buffer_batch,
>  	addr_bo_buffer_batch[b++] = addr_output & 0xffffffff;
>  	addr_bo_buffer_batch[b++] = addr_output >> 32;
>  
> -	addr_bo_buffer_batch[b++] = 0x00000400;
> +	addr_bo_buffer_batch[b++] = loop_count;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
> @@ -708,7 +709,7 @@ static void compute_exec(int fd, const unsigned char *kernel,
>  	create_dynamic_state(bo_dict[1].data, OFFSET_KERNEL);
>  	create_surface_state(bo_dict[2].data, ADDR_INPUT, ADDR_OUTPUT);
>  	create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT,
> -			     IS_DG1(devid) ? 0x200 : 0x40);
> +			     IS_DG1(devid) ? 0x200 : 0x40, SIZE_DATA);
>  
>  	dinput = (float *)bo_dict[4].data;
>  	srand(time(NULL));
> @@ -746,7 +747,8 @@ static void compute_exec(int fd, const unsigned char *kernel,
>  
>  static void xehp_create_indirect_data(uint32_t *addr_bo_buffer_batch,
>  				      uint64_t addr_input,
> -				      uint64_t addr_output)
> +				      uint64_t addr_output,
> +				      unsigned int loop_count)
>  {
>  	int b = 0;
>  
> @@ -754,7 +756,7 @@ static void xehp_create_indirect_data(uint32_t *addr_bo_buffer_batch,
>  	addr_bo_buffer_batch[b++] = addr_input >> 32;
>  	addr_bo_buffer_batch[b++] = addr_output & 0xffffffff;
>  	addr_bo_buffer_batch[b++] = addr_output >> 32;
> -	addr_bo_buffer_batch[b++] = 0x00000400;
> +	addr_bo_buffer_batch[b++] = loop_count;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
>  	addr_bo_buffer_batch[b++] = 0x00000000;
> @@ -986,7 +988,7 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
>  	memcpy(bo_dict[0].data, kernel, size);
>  	create_dynamic_state(bo_dict[1].data, OFFSET_KERNEL);
>  	xehp_create_surface_state(bo_dict[2].data, ADDR_INPUT, ADDR_OUTPUT);
> -	xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT);
> +	xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT, SIZE_DATA);
>  	xehp_create_surface_state(bo_dict[7].data, ADDR_INPUT, ADDR_OUTPUT);
>  
>  	dinput = (float *)bo_dict[4].data;
> @@ -1020,7 +1022,8 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
>  
>  static void xehpc_create_indirect_data(uint32_t *addr_bo_buffer_batch,
>  				       uint64_t addr_input,
> -				       uint64_t addr_output)
> +				       uint64_t addr_output,
> +				       unsigned int loop_count)
>  {
>  	int b = 0;
>  
> @@ -1036,7 +1039,7 @@ static void xehpc_create_indirect_data(uint32_t *addr_bo_buffer_batch,
>  	addr_bo_buffer_batch[b++] = addr_input >> 32;
>  	addr_bo_buffer_batch[b++] = addr_output & 0xffffffff;
>  	addr_bo_buffer_batch[b++] = addr_output >> 32;
> -	addr_bo_buffer_batch[b++] = 0x00000400;
> +	addr_bo_buffer_batch[b++] = loop_count;
>  	addr_bo_buffer_batch[b++] = 0x00000400;
>  	addr_bo_buffer_batch[b++] = 0x00000001;
>  	addr_bo_buffer_batch[b++] = 0x00000001;
> @@ -1191,7 +1194,7 @@ static void xehpc_compute_exec(int fd, const unsigned char *kernel,
>  	bo_execenv_bind(&execenv, bo_dict, XEHPC_BO_DICT_ENTRIES);
>  
>  	memcpy(bo_dict[0].data, kernel, size);
> -	xehpc_create_indirect_data(bo_dict[1].data, ADDR_INPUT, ADDR_OUTPUT);
> +	xehpc_create_indirect_data(bo_dict[1].data, ADDR_INPUT, ADDR_OUTPUT, SIZE_DATA);
>  
>  	dinput = (float *)bo_dict[2].data;
>  	srand(time(NULL));
> @@ -1551,7 +1554,7 @@ static void xelpg_compute_exec(int fd, const unsigned char *kernel,
>  
>  	create_dynamic_state(bo_dict[1].data, OFFSET_KERNEL);
>  	xehp_create_surface_state(bo_dict[2].data, ADDR_INPUT, ADDR_OUTPUT);
> -	xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT);
> +	xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT, SIZE_DATA);
>  	xehp_create_surface_state(bo_dict[7].data, ADDR_INPUT, ADDR_OUTPUT);
>  
>  	dinput = (float *)bo_dict[4].data;
> @@ -1640,7 +1643,7 @@ static void xe2lpg_compute_exec(int fd, const unsigned char *kernel,
>  	memcpy(bo_dict[0].data, kernel, size);
>  	create_dynamic_state(bo_dict[1].data, OFFSET_KERNEL);
>  	xehp_create_surface_state(bo_dict[2].data, ADDR_INPUT, ADDR_OUTPUT);
> -	xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT);
> +	xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT, SIZE_DATA);
>  	xehp_create_surface_state(bo_dict[7].data, ADDR_INPUT, ADDR_OUTPUT);
>  
>  	dinput = (float *)bo_dict[4].data;
> @@ -1946,7 +1949,7 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
>  
>  	create_dynamic_state(bo_dict_short[1].data, OFFSET_KERNEL);
>  	xehp_create_surface_state(bo_dict_short[2].data, ADDR_INPUT, ADDR_OUTPUT);
> -	xehp_create_indirect_data(bo_dict_short[3].data, ADDR_INPUT, ADDR_OUTPUT);
> +	xehp_create_indirect_data(bo_dict_short[3].data, ADDR_INPUT, ADDR_OUTPUT, SIZE_DATA);
>  	xehp_create_surface_state(bo_dict_short[7].data, ADDR_INPUT, ADDR_OUTPUT);
>  
>  	dinput = (float *)bo_dict_long[4].data;
> -- 
> 2.43.0
> 


More information about the igt-dev mailing list