public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	"Francois Dugast" <francois.dugast@intel.com>
Subject: [PATCH i-g-t v4 1/5] lib/intel_compute: Add types for input and output buffers
Date: Tue,  3 Mar 2026 14:47:08 +0100	[thread overview]
Message-ID: <20260303134706.41948-8-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20260303134706.41948-7-zbigniew.kempczynski@intel.com>

Instead of selecting input and output buffers by direct indices mark
them in provided arrays as typed, allowing to search them instead
of hardcoded index.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
---
 lib/intel_compute.c | 115 ++++++++++++++++++++++++++++++--------------
 1 file changed, 80 insertions(+), 35 deletions(-)

diff --git a/lib/intel_compute.c b/lib/intel_compute.c
index eab6accfbc..dfd38b8d8c 100644
--- a/lib/intel_compute.c
+++ b/lib/intel_compute.c
@@ -77,12 +77,18 @@
 #define TGP_long_kernel_loop_count		10
 #define XE2_THREADGROUP_PREEMPT_XDIM		0x4000
 
+enum bo_dict_type {
+	BO_TYPE_INPUT = 1,
+	BO_TYPE_OUTPUT
+};
+
 struct bo_dict_entry {
 	uint64_t addr;
 	uint32_t size;
 	void *data;
 	const char *name;
 	uint32_t handle;
+	enum bo_dict_type bo_type;
 };
 
 struct bo_sync {
@@ -142,16 +148,34 @@ static void bo_check_square(float *input, float *output, int size)
 	}
 }
 
+static struct bo_dict_entry *bo_dict_find_by_type(struct bo_dict_entry *bo_dict,
+						  int entries,
+						  enum bo_dict_type bo_type)
+{
+	struct bo_dict_entry *entry = NULL;
+
+	for (int i = 0; i < entries; i++)
+		if (bo_dict[i].bo_type == bo_type)
+			entry = &bo_dict[i];
+	igt_assert_f(entry, "bo_type %d not found in bo_dict\n", bo_type);
+
+	return entry;
+}
+
 static float *get_input_data(const struct bo_execenv *execenv,
-			     const struct user_execenv *user,
-			     void *data)
+			     struct bo_dict_entry *bo_dict,
+			     int entries)
 {
+	const struct user_execenv *user = execenv->user;
 	float *input_data;
 
 	if (user && user->input_addr) {
 		input_data = from_user_pointer(user->input_addr);
 	} else {
-		input_data = (float *) data;
+		struct bo_dict_entry *entry;
+
+		entry = bo_dict_find_by_type(bo_dict, entries, BO_TYPE_INPUT);
+		input_data = (float *) entry->data;
 		bo_randomize(input_data, execenv->loop_count);
 	}
 
@@ -159,15 +183,20 @@ static float *get_input_data(const struct bo_execenv *execenv,
 }
 
 static float *get_output_data(const struct bo_execenv *execenv,
-			      const struct user_execenv *user,
-			      void *data)
+			      struct bo_dict_entry *bo_dict,
+			      int entries)
 {
+	const struct user_execenv *user = execenv->user;
 	float *output_data;
 
 	if (user && user->output_addr)
 		output_data = from_user_pointer(user->output_addr);
-	else
-		output_data = (float *) data;
+	else {
+		struct bo_dict_entry *entry;
+
+		entry = bo_dict_find_by_type(bo_dict, entries, BO_TYPE_OUTPUT);
+		output_data = (float *) entry->data;
+	}
 
 	return output_data;
 }
@@ -863,9 +892,11 @@ static void compute_exec(int fd, const unsigned char *kernel,
 		  .size = SIZE_INDIRECT_OBJECT,
 		  .name = "indirect data start" },
 		{ .addr = ADDR_INPUT,
-		  .name = "input" },
+		  .name = "input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT,
-		  .name = "output" },
+		  .name = "output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_BATCH,
 		  .size = SIZE_BATCH,
 		  .name = "batch" },
@@ -895,8 +926,8 @@ static void compute_exec(int fd, const unsigned char *kernel,
 	create_indirect_data(bo_dict[3].data, bind_input_addr, bind_output_addr,
 			     IS_DG1(devid) ? 0x200 : 0x40, execenv.loop_count);
 
-	input_data = get_input_data(&execenv, user, bo_dict[4].data);
-	output_data = get_output_data(&execenv, user, bo_dict[5].data);
+	input_data = get_input_data(&execenv, bo_dict, entries);
+	output_data = get_output_data(&execenv, bo_dict, entries);
 
 	if (IS_DG1(devid))
 		dg1_compute_exec_compute(bo_dict[6].data,
@@ -1144,9 +1175,11 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
 		  .size = SIZE_INDIRECT_OBJECT,
 		  .name = "indirect object base"},
 		{ .addr = ADDR_INPUT,
-		  .name = "addr input"},
+		  .name = "addr input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT,
-		  .name = "addr output" },
+		  .name = "addr output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_GENERAL_STATE_BASE,
 		  .size = SIZE_GENERAL_STATE,
 		  .name = "general state base" },
@@ -1184,8 +1217,8 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
 				  execenv.loop_count);
 	xehp_create_surface_state(bo_dict[7].data, bind_input_addr, bind_output_addr);
 
-	input_data = get_input_data(&execenv, user, bo_dict[4].data);
-	output_data = get_output_data(&execenv, user, bo_dict[5].data);
+	input_data = get_input_data(&execenv, bo_dict, entries);
+	output_data = get_output_data(&execenv, bo_dict, entries);
 
 	xehp_compute_exec_compute(fd,
 				  bo_dict[8].data,
@@ -1365,9 +1398,11 @@ static void xehpc_compute_exec(int fd, const unsigned char *kernel,
 		  .size = SIZE_INDIRECT_OBJECT,
 		  .name = "indirect object base"},
 		{ .addr = ADDR_INPUT,
-		  .name = "addr input"},
+		  .name = "addr input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT,
-		  .name = "addr output" },
+		  .name = "addr output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_GENERAL_STATE_BASE,
 		  .size = SIZE_GENERAL_STATE,
 		  .name = "general state base" },
@@ -1396,8 +1431,8 @@ static void xehpc_compute_exec(int fd, const unsigned char *kernel,
 	xehpc_create_indirect_data(bo_dict[1].data, bind_input_addr, bind_output_addr,
 				   execenv.loop_count);
 
-	input_data = get_input_data(&execenv, user, bo_dict[2].data);
-	output_data = get_output_data(&execenv, user, bo_dict[3].data);
+	input_data = get_input_data(&execenv, bo_dict, entries);
+	output_data = get_output_data(&execenv, bo_dict, entries);
 
 	xehpc_compute_exec_compute(fd,
 				   bo_dict[5].data,
@@ -1757,9 +1792,11 @@ static void xelpg_compute_exec(int fd, const unsigned char *kernel,
 		  .size = SIZE_INDIRECT_OBJECT,
 		  .name = "indirect object base"},
 		{ .addr = ADDR_INPUT,
-		  .name = "addr input"},
+		  .name = "addr input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT,
-		  .name = "addr output" },
+		  .name = "addr output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_GENERAL_STATE_BASE,
 		  .size = SIZE_GENERAL_STATE,
 		  .name = "general state base" },
@@ -1800,8 +1837,8 @@ static void xelpg_compute_exec(int fd, const unsigned char *kernel,
 				   execenv.loop_count);
 	xehp_create_surface_state(bo_dict[7].data, bind_input_addr, bind_output_addr);
 
-	input_data = get_input_data(&execenv, user, bo_dict[4].data);
-	output_data = get_output_data(&execenv, user, bo_dict[5].data);
+	input_data = get_input_data(&execenv, bo_dict, entries);
+	output_data = get_output_data(&execenv, bo_dict, entries);
 
 	xelpg_compute_exec_compute(bo_dict[8].data,
 				   ADDR_GENERAL_STATE_BASE,
@@ -1848,9 +1885,11 @@ static void xe2lpg_compute_exec(int fd, const unsigned char *kernel,
 		  .size = SIZE_INDIRECT_OBJECT,
 		  .name = "indirect object base"},
 		{ .addr = ADDR_INPUT,
-		  .name = "addr input"},
+		  .name = "addr input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT,
-		  .name = "addr output" },
+		  .name = "addr output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_GENERAL_STATE_BASE,
 		  .size = SIZE_GENERAL_STATE,
 		  .name = "general state base" },
@@ -1888,8 +1927,8 @@ static void xe2lpg_compute_exec(int fd, const unsigned char *kernel,
 				   execenv.loop_count);
 	xehp_create_surface_state(bo_dict[7].data, bind_input_addr, bind_output_addr);
 
-	input_data = get_input_data(&execenv, user, bo_dict[4].data);
-	output_data = get_output_data(&execenv, user, bo_dict[5].data);
+	input_data = get_input_data(&execenv, bo_dict, entries);
+	output_data = get_output_data(&execenv, bo_dict, entries);
 
 	xe2lpg_compute_exec_compute(fd,
 				    bo_dict[8].data,
@@ -2097,9 +2136,11 @@ static void xe3p_compute_exec(int fd, const unsigned char *kernel,
 		  .size =  0x1000,
 		  .name = "indirect object base"},
 		{ .addr = ADDR_INPUT,
-		  .name = "addr input"},
+		  .name = "addr input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT,
-		  .name = "addr output" },
+		  .name = "addr output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_BATCH,
 		  .size = SIZE_BATCH,
 		  .name = "batch" },
@@ -2131,8 +2172,8 @@ static void xe3p_compute_exec(int fd, const unsigned char *kernel,
 	idata.xe3p.indirect_addr_lo = indirect_addr;
 	idata.xe3p.indirect_addr_hi = indirect_addr >> 32;
 
-	input_data = get_input_data(&execenv, user, bo_dict[2].data);
-	output_data = get_output_data(&execenv, user, bo_dict[3].data);
+	input_data = get_input_data(&execenv, bo_dict, entries);
+	output_data = get_output_data(&execenv, bo_dict, entries);
 
 	xe3p_compute_exec_compute(fd, &idata,
 				  bo_dict[4].data,
@@ -2421,9 +2462,11 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
 		  .size = SIZE_INDIRECT_OBJECT,
 		  .name = "indirect object base"},
 		{ .addr = ADDR_INPUT, .size = MAX(sizeof(float) * SIZE_DATA, 0x10000),
-		  .name = "addr input"},
+		  .name = "addr input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT, .size = MAX(sizeof(float) * SIZE_DATA, 0x10000),
-		  .name = "addr output" },
+		  .name = "addr output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_GENERAL_STATE_BASE,
 		  .size = SIZE_GENERAL_STATE,
 		  .name = "general state base" },
@@ -2566,9 +2609,11 @@ static void xe3p_compute_preempt_exec(int fd, const unsigned char *long_kernel,
 		  .size =  0x1000,
 		  .name = "indirect object base"},
 		{ .addr = ADDR_INPUT, .size = MAX(sizeof(float) * SIZE_DATA, 0x10000),
-		  .name = "addr input"},
+		  .name = "addr input",
+		  .bo_type = BO_TYPE_INPUT },
 		{ .addr = ADDR_OUTPUT, .size = MAX(sizeof(float) * SIZE_DATA, 0x10000),
-		  .name = "addr output" },
+		  .name = "addr output",
+		  .bo_type = BO_TYPE_OUTPUT },
 		{ .addr = ADDR_BATCH,
 		  .size = SIZE_BATCH,
 		  .name = "batch" },
-- 
2.43.0


  reply	other threads:[~2026-03-03 13:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 13:47 [PATCH i-g-t v4 0/5] Extend compute userenv to support user passed buffers Zbigniew Kempczyński
2026-03-03 13:47 ` Zbigniew Kempczyński [this message]
2026-03-03 13:47 ` [PATCH i-g-t v4 2/5] lib/intel_compute: Extend userenv by adding input and output bos Zbigniew Kempczyński
2026-03-03 13:47 ` [PATCH i-g-t v4 3/5] lib/intel_compute: Use user offsets and loop size if provided Zbigniew Kempczyński
2026-03-03 15:07   ` Sharma, Nishit
2026-03-03 16:37     ` Kamil Konieczny
2026-03-03 18:30       ` Sharma, Nishit
2026-03-04  7:56         ` Zbigniew Kempczyński
2026-03-03 16:31   ` Kamil Konieczny
2026-03-03 13:47 ` [PATCH i-g-t v4 4/5] tests/xe_compute: Exercise user passed buffers Zbigniew Kempczyński
2026-03-03 13:47 ` [PATCH i-g-t v4 5/5] tests/xe_compute: Use appropriate feature in compute-square tests Zbigniew Kempczyński
2026-03-03 14:56 ` [PATCH i-g-t v4 0/5] Extend compute userenv to support user passed buffers Sharma, Nishit
2026-03-04  7:59   ` Zbigniew Kempczyński
2026-03-04  3:24 ` ✓ Xe.CI.BAT: success for Extend compute userenv to support user passed buffers (rev4) Patchwork
2026-03-04  3:45 ` ✓ i915.CI.BAT: " Patchwork
2026-03-05  0:46 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-05  5:58 ` ✗ i915.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260303134706.41948-8-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox