From: Francois Dugast <francois.dugast@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Francois Dugast <francois.dugast@intel.com>
Subject: [PATCH i-g-t 1/5] lib/intel_compute: Rename variables for input and output data
Date: Wed, 5 Feb 2025 11:17:02 +0100 [thread overview]
Message-ID: <20250205101748.1117809-2-francois.dugast@intel.com> (raw)
In-Reply-To: <20250205101748.1117809-1-francois.dugast@intel.com>
Use more explicit names to make development and debugging easier.
Signed-off-by: Francois Dugast <francois.dugast@intel.com>
---
lib/intel_compute.c | 143 ++++++++++++++++++++++++--------------------
1 file changed, 77 insertions(+), 66 deletions(-)
diff --git a/lib/intel_compute.c b/lib/intel_compute.c
index 233835c6c..86eb48afc 100644
--- a/lib/intel_compute.c
+++ b/lib/intel_compute.c
@@ -694,7 +694,7 @@ static void compute_exec(int fd, const unsigned char *kernel,
.name = "batch" },
};
struct bo_execenv execenv;
- float *dinput;
+ float *input_data, *output_data;
uint16_t devid = intel_get_drm_devid(fd);
bo_execenv_create(fd, &execenv, eci);
@@ -710,10 +710,12 @@ static void compute_exec(int fd, const unsigned char *kernel,
create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT,
IS_DG1(devid) ? 0x200 : 0x40);
- dinput = (float *)bo_dict[4].data;
+ input_data = (float *) bo_dict[4].data;
+ output_data = (float *) bo_dict[5].data;
srand(time(NULL));
+
for (int i = 0; i < SIZE_DATA; i++)
- ((float *)dinput)[i] = rand() / (float)RAND_MAX;
+ input_data[i] = rand() / (float)RAND_MAX;
if (IS_DG1(devid))
dg1_compute_exec_compute(bo_dict[6].data,
@@ -731,13 +733,14 @@ static void compute_exec(int fd, const unsigned char *kernel,
bo_execenv_exec(&execenv, ADDR_BATCH);
for (int i = 0; i < SIZE_DATA; i++) {
- float f1, f2;
-
- f1 = ((float *) bo_dict[5].data)[i];
- f2 = ((float *) bo_dict[4].data)[i];
- if (f1 != f2 * f2)
- igt_debug("[%4d] f1: %f != %f\n", i, f1, f2 * f2);
- igt_assert(f1 == f2 * f2);
+ float input = input_data[i];
+ float output = output_data[i];
+ float expected_output = input * input;
+
+ if (output != expected_output)
+ igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
+ i, input, output, expected_output);
+ igt_assert_eq(output, expected_output);
}
bo_execenv_unbind(&execenv, bo_dict, BO_DICT_ENTRIES);
@@ -974,7 +977,7 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
.name = "batch" },
};
struct bo_execenv execenv;
- float *dinput;
+ float *input_data, *output_data;
bo_execenv_create(fd, &execenv, eci);
@@ -989,10 +992,12 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT);
xehp_create_surface_state(bo_dict[7].data, ADDR_INPUT, ADDR_OUTPUT);
- dinput = (float *)bo_dict[4].data;
+ input_data = (float *) bo_dict[4].data;
+ output_data = (float *) bo_dict[5].data;
srand(time(NULL));
+
for (int i = 0; i < SIZE_DATA; i++)
- ((float *)dinput)[i] = rand() / (float)RAND_MAX;
+ input_data[i] = rand() / (float)RAND_MAX;
xehp_compute_exec_compute(bo_dict[8].data,
ADDR_GENERAL_STATE_BASE,
@@ -1005,13 +1010,14 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
bo_execenv_exec(&execenv, ADDR_BATCH);
for (int i = 0; i < SIZE_DATA; i++) {
- float f1, f2;
-
- f1 = ((float *) bo_dict[5].data)[i];
- f2 = ((float *) bo_dict[4].data)[i];
- if (f1 != f2 * f2)
- igt_debug("[%4d] f1: %f != %f\n", i, f1, f2 * f2);
- igt_assert(f1 == f2 * f2);
+ float input = input_data[i];
+ float output = output_data[i];
+ float expected_output = input * input;
+
+ if (output != expected_output)
+ igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
+ i, input, output, expected_output);
+ igt_assert_eq(output, expected_output);
}
bo_execenv_unbind(&execenv, bo_dict, XEHP_BO_DICT_ENTRIES);
@@ -1181,7 +1187,7 @@ static void xehpc_compute_exec(int fd, const unsigned char *kernel,
.name = "batch" },
};
struct bo_execenv execenv;
- float *dinput;
+ float *input_data, *output_data;
bo_execenv_create(fd, &execenv, eci);
@@ -1193,10 +1199,12 @@ static void xehpc_compute_exec(int fd, const unsigned char *kernel,
memcpy(bo_dict[0].data, kernel, size);
xehpc_create_indirect_data(bo_dict[1].data, ADDR_INPUT, ADDR_OUTPUT);
- dinput = (float *)bo_dict[2].data;
+ input_data = (float *) bo_dict[2].data;
+ output_data = (float *) bo_dict[3].data;
srand(time(NULL));
+
for (int i = 0; i < SIZE_DATA; i++)
- ((float *)dinput)[i] = rand() / (float)RAND_MAX;
+ input_data[i] = rand() / (float)RAND_MAX;
xehpc_compute_exec_compute(bo_dict[5].data,
ADDR_GENERAL_STATE_BASE,
@@ -1209,13 +1217,14 @@ static void xehpc_compute_exec(int fd, const unsigned char *kernel,
bo_execenv_exec(&execenv, ADDR_BATCH);
for (int i = 0; i < SIZE_DATA; i++) {
- float f1, f2;
-
- f1 = ((float *) bo_dict[3].data)[i];
- f2 = ((float *) bo_dict[2].data)[i];
- if (f1 != f2 * f2)
- igt_debug("[%4d] f1: %f != %f\n", i, f1, f2 * f2);
- igt_assert(f1 == f2 * f2);
+ float input = input_data[i];
+ float output = output_data[i];
+ float expected_output = input * input;
+
+ if (output != expected_output)
+ igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
+ i, input, output, expected_output);
+ igt_assert_eq(output, expected_output);
}
bo_execenv_unbind(&execenv, bo_dict, XEHPC_BO_DICT_ENTRIES);
@@ -1538,7 +1547,7 @@ static void xelpg_compute_exec(int fd, const unsigned char *kernel,
};
struct bo_execenv execenv;
- float *dinput;
+ float *input_data, *output_data;
bo_execenv_create(fd, &execenv, eci);
@@ -1554,11 +1563,12 @@ static void xelpg_compute_exec(int fd, const unsigned char *kernel,
xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT);
xehp_create_surface_state(bo_dict[7].data, ADDR_INPUT, ADDR_OUTPUT);
- dinput = (float *)bo_dict[4].data;
+ input_data = (float *) bo_dict[4].data;
+ output_data = (float *) bo_dict[5].data;
srand(time(NULL));
for (int i = 0; i < SIZE_DATA; i++)
- ((float *)dinput)[i] = rand() / (float)RAND_MAX;
+ input_data[i] = rand() / (float)RAND_MAX;
xelpg_compute_exec_compute(bo_dict[8].data,
ADDR_GENERAL_STATE_BASE,
@@ -1571,15 +1581,14 @@ static void xelpg_compute_exec(int fd, const unsigned char *kernel,
bo_execenv_exec(&execenv, ADDR_BATCH);
for (int i = 0; i < SIZE_DATA; i++) {
- float f1, f2;
-
- f1 = ((float *) bo_dict[5].data)[i];
- f2 = ((float *) bo_dict[4].data)[i];
-
- if (f1 != f2 * f2)
- igt_debug("[%4d] f1: %f != %f %f\n", i, f1, f2 * f2, f2);
-
- igt_assert(f1 == f2 * f2);
+ float input = input_data[i];
+ float output = output_data[i];
+ float expected_output = input * input;
+
+ if (output != expected_output)
+ igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
+ i, input, output, expected_output);
+ igt_assert_eq(output, expected_output);
}
bo_execenv_unbind(&execenv, bo_dict, XELPG_BO_DICT_ENTRIES);
@@ -1628,7 +1637,7 @@ static void xe2lpg_compute_exec(int fd, const unsigned char *kernel,
};
struct bo_execenv execenv;
- float *dinput;
+ float *input_data, *output_data;
bo_execenv_create(fd, &execenv, eci);
@@ -1643,11 +1652,12 @@ static void xe2lpg_compute_exec(int fd, const unsigned char *kernel,
xehp_create_indirect_data(bo_dict[3].data, ADDR_INPUT, ADDR_OUTPUT);
xehp_create_surface_state(bo_dict[7].data, ADDR_INPUT, ADDR_OUTPUT);
- dinput = (float *)bo_dict[4].data;
+ input_data = (float *) bo_dict[4].data;
+ output_data = (float *) bo_dict[5].data;
srand(time(NULL));
for (int i = 0; i < SIZE_DATA; i++)
- ((float *)dinput)[i] = rand() / (float)RAND_MAX;
+ input_data[i] = rand() / (float)RAND_MAX;
xe2lpg_compute_exec_compute(bo_dict[8].data,
ADDR_GENERAL_STATE_BASE,
@@ -1661,14 +1671,14 @@ static void xe2lpg_compute_exec(int fd, const unsigned char *kernel,
bo_execenv_exec(&execenv, ADDR_BATCH);
for (int i = 0; i < SIZE_DATA; i++) {
- float f1, f2;
-
- f1 = ((float *) bo_dict[5].data)[i];
- f2 = ((float *) bo_dict[4].data)[i];
-
- if (f1 != f2 * f2)
- igt_debug("[%4d] f1: %f != %f\n", i, f1, f2 * f2);
- igt_assert(f1 == f2 * f2);
+ float input = input_data[i];
+ float output = output_data[i];
+ float expected_output = input * input;
+
+ if (output != expected_output)
+ igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
+ i, input, output, expected_output);
+ igt_assert_eq(output, expected_output);
}
bo_execenv_unbind(&execenv, bo_dict, XE2_BO_DICT_ENTRIES);
@@ -1861,7 +1871,7 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
struct bo_dict_entry bo_dict_short[XE2_BO_PREEMPT_DICT_ENTRIES];
struct bo_execenv execenv_short, execenv_long;
- float *dinput;
+ float *input_data, *output_data;
unsigned int long_kernel_loop_count;
struct drm_xe_sync sync_long = {
.type = DRM_XE_SYNC_TYPE_USER_FENCE,
@@ -1944,16 +1954,17 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
xehp_create_indirect_data(bo_dict_short[3].data, ADDR_INPUT, ADDR_OUTPUT);
xehp_create_surface_state(bo_dict_short[7].data, ADDR_INPUT, ADDR_OUTPUT);
- dinput = (float *)bo_dict_long[4].data;
+ input_data = (float *) bo_dict_long[4].data;
+ output_data = (float *) bo_dict_short[5].data;
srand(time(NULL));
for (int i = 0; i < SIZE_DATA; i++)
- ((float *)dinput)[i] = rand() / (float)RAND_MAX;
+ input_data[i] = rand() / (float)RAND_MAX;
- dinput = (float *)bo_dict_short[4].data;
+ input_data = (float *) bo_dict_short[4].data;
for (int i = 0; i < SIZE_DATA; i++)
- ((float *)dinput)[i] = rand() / (float)RAND_MAX;
+ input_data[i] = rand() / (float)RAND_MAX;
xe2lpg_compute_exec_compute(bo_dict_long[8].data, ADDR_GENERAL_STATE_BASE,
ADDR_SURFACE_STATE_BASE, ADDR_DYNAMIC_STATE_BASE,
@@ -1983,14 +1994,14 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
gem_close(fd, bo_short);
for (int i = 0; i < SIZE_DATA; i++) {
- float f1, f2;
-
- f1 = ((float *) bo_dict_short[5].data)[i];
- f2 = ((float *) bo_dict_short[4].data)[i];
-
- if (f1 != f2 * f2)
- igt_debug("[%4d] f1: %f != %f\n", i, f1, f2 * f2);
- igt_assert(f1 == f2 * f2);
+ float input = input_data[i];
+ float output = output_data[i];
+ float expected_output = input * input;
+
+ if (output != expected_output)
+ igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
+ i, input, output, expected_output);
+ igt_assert_eq(output, expected_output);
}
for (int i = 0; i < SIZE_DATA; i++) {
--
2.43.0
next prev parent reply other threads:[~2025-02-05 10:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 10:17 [PATCH i-g-t 0/5] Prepare lib/intel_compute for SVM/system allocator Francois Dugast
2025-02-05 10:17 ` Francois Dugast [this message]
2025-02-05 10:17 ` [PATCH i-g-t 2/5] lib/intel_compute: Allow the user to provide a vm Francois Dugast
2025-02-05 10:17 ` [PATCH i-g-t 3/5] lib/intel_compute: Allow the user to provide a custom compute kernel Francois Dugast
2025-02-13 7:00 ` Zbigniew Kempczyński
2025-02-21 13:37 ` Francois Dugast
2025-02-24 7:17 ` Zbigniew Kempczyński
2025-02-05 10:17 ` [PATCH i-g-t 4/5] lib/intel_compute: Give option to skip results check Francois Dugast
2025-02-05 10:17 ` [PATCH i-g-t 5/5] lib/intel_compute: Allow the user to provide input and output buffers Francois Dugast
2025-02-05 13:04 ` ✗ GitLab.Pipeline: warning for Prepare lib/intel_compute for SVM/system allocator Patchwork
2025-02-05 13:31 ` ✓ i915.CI.BAT: success " Patchwork
2025-02-05 13:32 ` ✓ Xe.CI.BAT: " Patchwork
2025-02-05 16:34 ` ✗ Xe.CI.Full: failure " Patchwork
2025-02-05 17:29 ` ✓ i915.CI.Full: success " 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=20250205101748.1117809-2-francois.dugast@intel.com \
--to=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