From: Sobin Thomas <sobin.thomas@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: kamil.konieczny@intel.com, zbigniew.kempczynski@intel.com,
priyanka.dandamudi@intel.com,
Sobin Thomas <sobin.thomas@intel.com>
Subject: [PATCH i-g-t v9 2/3] lib/intel/intel_compute: Add kernel lookup and validation for compute IP versions
Date: Fri, 3 Oct 2025 05:26:20 +0000 [thread overview]
Message-ID: <20251003052640.56068-3-sobin.thomas@intel.com> (raw)
In-Reply-To: <20251003052640.56068-1-sobin.thomas@intel.com>
Introduce functions to locate compute square kernels based on IP version
and validate their availability for preemption scenarios.
- intel_compute_find_kernels() returns the matching kernel entry.
- validate_kernels() ensures required kernel variants are present
for compute and preemption kernels.
Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
lib/intel_compute.c | 90 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 69 insertions(+), 21 deletions(-)
diff --git a/lib/intel_compute.c b/lib/intel_compute.c
index ae656a4f6..ade0b44c1 100644
--- a/lib/intel_compute.c
+++ b/lib/intel_compute.c
@@ -1921,23 +1921,80 @@ static const struct {
},
};
+static const struct intel_compute_kernels
+ *intel_compute_find_kernels(const struct intel_compute_kernels *kernels,
+ unsigned int ip_ver)
+{
+ if (!kernels) {
+ igt_debug("%s: kernel_list is NULL\n", __func__);
+ return NULL;
+ }
+
+ while (kernels->kernel) {
+ if (ip_ver == kernels->ip_ver)
+ return kernels;
+ kernels++;
+ }
+
+ return NULL;
+}
+
+static bool validate_kernels(const struct intel_compute_kernels *kernels,
+ bool check_preemption, bool threadgroup_preemption,
+ unsigned int ip_ver)
+{
+ if (!kernels) {
+ igt_warn("No kernel entry found for IP version 0x%x\n", ip_ver);
+ return false;
+ }
+
+ if (!kernels->kernel) {
+ igt_warn("Missing compute square kernel for IP version 0x%x\n", ip_ver);
+ return false;
+ }
+
+ if (!check_preemption)
+ return true;
+
+ /* The following checks are only performed if preemption check is enabled. */
+ if (threadgroup_preemption && !kernels->long_kernel) {
+ igt_warn("Missing Long kernel for IP version 0x%x\n", ip_ver);
+ return false;
+ } else if (!threadgroup_preemption) {
+ if (!kernels->sip_kernel) {
+ igt_warn("Missing SIP kernel for IP version 0x%x\n", ip_ver);
+ return false;
+ }
+ if (!kernels->loop_kernel) {
+ igt_warn("Missing Loop kernel for IP version 0x%x\n", ip_ver);
+ return false;
+ }
+ }
+ return true;
+}
+
+static int find_compute_batch(unsigned int ip_ver)
+{
+ for (int batch_idx = 0; batch_idx < ARRAY_SIZE(intel_compute_batches); batch_idx++)
+ if (ip_ver == intel_compute_batches[batch_idx].ip_ver)
+ return batch_idx;
+ return -1;
+}
+
static bool __run_intel_compute_kernel(int fd,
struct drm_xe_engine_class_instance *eci,
struct user_execenv *user,
enum execenv_alloc_prefs alloc_prefs)
{
unsigned int ip_ver = intel_graphics_ver(intel_get_drm_devid(fd));
- unsigned int batch;
- const struct intel_compute_kernels *kernels = intel_compute_square_kernels;
+ int batch;
+ const struct intel_compute_kernels *kernel_entries = intel_compute_square_kernels, *kernels;
enum intel_driver driver = get_intel_driver(fd);
const unsigned char *kernel;
unsigned int kernel_size;
- for (batch = 0; batch < ARRAY_SIZE(intel_compute_batches); batch++) {
- if (ip_ver == intel_compute_batches[batch].ip_ver)
- break;
- }
- if (batch == ARRAY_SIZE(intel_compute_batches)) {
+ batch = find_compute_batch(ip_ver);
+ if (batch < 0) {
igt_debug("GPU version 0x%x not supported\n", ip_ver);
return false;
}
@@ -1954,12 +2011,8 @@ static bool __run_intel_compute_kernel(int fd,
kernel = user->kernel;
kernel_size = user->kernel_size;
} else {
- while (kernels->kernel) {
- if (ip_ver == kernels->ip_ver)
- break;
- kernels++;
- }
- if (!kernels->kernel)
+ kernels = intel_compute_find_kernels(kernel_entries, ip_ver);
+ if (!validate_kernels(kernels, false, false, ip_ver))
return false;
kernel = kernels->kernel;
kernel_size = kernels->size;
@@ -2270,18 +2323,13 @@ static bool __run_intel_compute_kernel_preempt(int fd,
return false;
}
- while (kernels->kernel) {
- if (ip_ver == kernels->ip_ver)
- break;
- kernels++;
- }
-
if (!is_preemptable(batch, required_preempt))
return false;
- if (!kernels->kernel || !kernels->sip_kernel || !kernels->long_kernel)
- return 0;
+ kernels = intel_compute_find_kernels(kernel_entries, ip_ver);
+ if (!validate_kernels(kernels, true, threadgroup_preemption, ip_ver))
+ return false;
intel_compute_preempt_batches[batch].compute_exec(fd, kernels->long_kernel,
kernels->long_kernel_size,
kernels->kernel, kernels->size,
--
2.51.0
next prev parent reply other threads:[~2025-10-03 5:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-03 5:26 [PATCH i-g-t v9 0/3] tests/intel/xe_compute_preempt: Compute preemption check Sobin Thomas
2025-10-03 5:26 ` [PATCH i-g-t v9 1/3] " Sobin Thomas
2025-10-10 8:57 ` Zbigniew Kempczyński
2025-10-10 9:09 ` Zbigniew Kempczyński
2025-10-03 5:26 ` Sobin Thomas [this message]
2025-10-10 9:23 ` [PATCH i-g-t v9 2/3] lib/intel/intel_compute: Add kernel lookup and validation for compute IP versions Zbigniew Kempczyński
2025-10-03 5:26 ` [PATCH i-g-t v9 3/3] lib/intel_compute: Adjust long kernel usage for WMTP Sobin Thomas
2025-10-10 9:24 ` Zbigniew Kempczyński
2025-10-03 7:11 ` ✓ Xe.CI.BAT: success for tests/intel/xe_compute_preempt: Compute preemption check Patchwork
2025-10-03 7:11 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-10-03 7:26 ` ✗ i915.CI.BAT: " Patchwork
2025-10-03 8:43 ` ✗ Xe.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=20251003052640.56068-3-sobin.thomas@intel.com \
--to=sobin.thomas@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@intel.com \
--cc=priyanka.dandamudi@intel.com \
--cc=zbigniew.kempczynski@intel.com \
/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