From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
"Nishit Sharma" <nishit.sharma@intel.com>,
"Francois Dugast" <francois.dugast@intel.com>
Subject: [PATCH i-g-t v4 4/5] tests/xe_compute: Exercise user passed buffers
Date: Tue, 3 Mar 2026 14:47:11 +0100 [thread overview]
Message-ID: <20260303134706.41948-11-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20260303134706.41948-7-zbigniew.kempczynski@intel.com>
Verify input and output buffers added to execenv are properly handled
and data within are fully on user control.
Do compute-square on input buffer and verify output contain computed
square root for floats of input buffer.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Signed-off-by: Nishit Sharma <nishit.sharma@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
---
v2: Adding SVM part by Nishit
v3: Use input and output as bo or svm buffers (ZK)
---
tests/intel/xe_compute.c | 150 +++++++++++++++++++++++++++++++++++++++
1 file changed, 150 insertions(+)
diff --git a/tests/intel/xe_compute.c b/tests/intel/xe_compute.c
index 310093fc56..738ad8cd33 100644
--- a/tests/intel/xe_compute.c
+++ b/tests/intel/xe_compute.c
@@ -510,6 +510,144 @@ test_compute_square(int fd)
"GPU not supported\n");
}
+/**
+ * SUBTEST: compute-square-userenv
+ * Mega feature: Compute
+ * Sub-category: compute tests
+ * Functionality: OpenCL kernel
+ * Description:
+ * Run an openCL Kernel that returns output[i] = input[i] * input[i],
+ * taking buffers from userenv.
+ *
+ * SUBTEST: compute-square-userenv-isvm
+ * Mega feature: Compute
+ * Sub-category: compute tests
+ * Functionality: OpenCL kernel
+ * Description:
+ * Run an openCL Kernel that returns output[i] = input[i] * input[i],
+ * taking buffers from userenv where input is svm buffer.
+ *
+ * SUBTEST: compute-square-userenv-osvm
+ * Mega feature: Compute
+ * Sub-category: compute tests
+ * Functionality: OpenCL kernel
+ * Description:
+ * Run an openCL Kernel that returns output[i] = input[i] * input[i],
+ * taking buffers from userenv where output buffer is svm buffer.
+ *
+ * SUBTEST: compute-square-userenv-iosvm
+ * Mega feature: Compute
+ * Sub-category: compute tests
+ * Functionality: OpenCL kernel
+ * Description:
+ * Run an openCL Kernel that returns output[i] = input[i] * input[i],
+ * taking buffers from userenv where input and output buffers are svm buffer.
+ */
+
+#define INPUT_IN_SVM (1 << 0)
+#define OUTPUT_IN_SVM (1 << 1)
+#define INPUT_BO_ADDR 0x30000000
+#define OUTPUT_BO_ADDR 0x31000000
+#define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
+#define FIVE_SEC (5LL * NSEC_PER_SEC)
+
+#define bind_system_allocator(__sync, __num_sync) \
+ __xe_vm_bind_assert(fd, vm, 0, \
+ 0, 0, 0, 0x1ull << va_bits, \
+ DRM_XE_VM_BIND_OP_MAP, \
+ DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR, \
+ (__sync), (__num_sync), 0, 0)
+
+static void
+test_compute_square_userenv(int fd, uint32_t flags)
+{
+ uint32_t size = SZ_4K, vm;
+ struct user_execenv env = {
+ .array_size = size / sizeof(float),
+ };
+ uint32_t input_bo, output_bo;
+ int va_bits = xe_va_bits(fd);
+ float *input, *output;
+ int i;
+
+ vm = env.vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE |
+ DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0);
+
+ if ((flags & INPUT_IN_SVM) || (flags & OUTPUT_IN_SVM)) {
+ struct drm_xe_sync sync = {
+ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+ .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .timeline_value = USER_FENCE_VALUE,
+ };
+ struct bo_sync {
+ uint64_t sync;
+ } *bo_sync;
+
+ bo_sync = aligned_alloc(xe_get_default_alignment(fd), sizeof(*bo_sync));
+ igt_assert(bo_sync);
+ sync.addr = to_user_pointer(&bo_sync->sync);
+ bind_system_allocator(&sync, 1);
+ xe_wait_ufence(fd, &bo_sync->sync, USER_FENCE_VALUE, 0, FIVE_SEC);
+ free(bo_sync);
+ }
+
+ if (flags & INPUT_IN_SVM) {
+ input = aligned_alloc(xe_get_default_alignment(fd), size);
+ env.input_addr = to_user_pointer(input);
+
+ } else {
+ input_bo = xe_bo_create(fd, env.vm, size, vram_if_possible(fd, 0),
+ DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+ input = xe_bo_map(fd, input_bo, size);
+ env.input_bo = input_bo;
+ env.input_addr = INPUT_BO_ADDR;
+ }
+
+ if (flags & OUTPUT_IN_SVM) {
+ output = aligned_alloc(xe_get_default_alignment(fd), size);
+ env.output_addr = to_user_pointer(output);
+ } else {
+ output_bo = xe_bo_create(fd, env.vm, size, vram_if_possible(fd, 0),
+ DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+ output = xe_bo_map(fd, output_bo, size);
+ env.output_bo = output_bo;
+ env.output_addr = OUTPUT_BO_ADDR;
+ }
+
+ env.loop_count = env.array_size / 2;
+ env.skip_results_check = true;
+
+ for (i = 0; i < env.array_size; i++)
+ input[i] = (float)i + 2.0f;
+
+ run_intel_compute_kernel(fd, &env, EXECENV_PREF_SYSTEM);
+
+ for (i = 0; i < env.loop_count; i++) {
+ float expected_output = input[i] * input[i];
+
+ if (output[i] != expected_output || output[i] == 0.0f)
+ igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
+ i, input[i], output[i], expected_output);
+ igt_assert_eq_double(output[i], expected_output);
+ }
+
+ if (flags & INPUT_IN_SVM) {
+ free(input);
+ } else {
+ munmap(input, size);
+ gem_close(fd, input_bo);
+ }
+
+ if (flags & OUTPUT_IN_SVM) {
+ free(output);
+ } else {
+ munmap(output, size);
+ gem_close(fd, output_bo);
+ }
+
+ xe_vm_destroy(fd, env.vm);
+}
+
int igt_main()
{
int xe, ccs_mode[4];
@@ -525,6 +663,18 @@ int igt_main()
igt_subtest("compute-square")
test_compute_square(xe);
+ igt_subtest("compute-square-userenv")
+ test_compute_square_userenv(xe, 0);
+
+ igt_subtest("compute-square-userenv-isvm")
+ test_compute_square_userenv(xe, INPUT_IN_SVM);
+
+ igt_subtest("compute-square-userenv-osvm")
+ test_compute_square_userenv(xe, OUTPUT_IN_SVM);
+
+ igt_subtest("compute-square-userenv-iosvm")
+ test_compute_square_userenv(xe, INPUT_IN_SVM | OUTPUT_IN_SVM);
+
igt_fixture()
drm_close_driver(xe);
--
2.43.0
next prev parent 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 ` [PATCH i-g-t v4 1/5] lib/intel_compute: Add types for input and output buffers Zbigniew Kempczyński
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 ` Zbigniew Kempczyński [this message]
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-11-zbigniew.kempczynski@intel.com \
--to=zbigniew.kempczynski@intel.com \
--cc=francois.dugast@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=nishit.sharma@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