Extend compute userenv to support user passed buffers
v3 cover Extend compute userenv to support user passed buffers
Add support for user passed buffers in compute userenv. This allows users to pass their own input and output buffers to compute tests, which can be useful for testing specific scenarios.
Zbigniew Kempczyński (4):
lib/intel_compute: Add types for input and output buffers lib/intel_compute: Extend userenv by adding input and output bos lib/intel_compute: Use user offsets and loop size if provided tests/xe_compute: Exercise user passed buffers tests/xe_compute: Use appropriate feature in compute-square tests
lib/intel_compute.c | 191 ++++++++++++++++++++++++++++----------- lib/intel_compute.h | 4 + tests/intel/xe_compute.c | 154 ++++++++++++++++++++++++++++++- 3 files changed, 294 insertions(+), 55 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/5 lib/intel_compute: Add types for input and output buffers
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.
--- lib/intel_compute.c | 115 ++++++++++++++++++++++++++++++-------------- 1 file changed, 80 insertions(+), 35 deletions(-)
lib/intel_compute.c +80 -35
@@ -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" },
Signature · 1 line
2.43.0
PATCH v3 2/5 lib/intel_compute: Extend userenv by adding input and output bos
In reply to Zbigniew KempczyńskiInput and output addresses if were passed by userenv were related to SVM addresses so buffers were created in the library and only bound to offsets user wanted.
Extend this allowing user to pass addresses as well buffer objects what allows user to set its own input and output data.
--- lib/intel_compute.c | 70 ++++++++++++++++++++++++++++++++++----------- lib/intel_compute.h | 4 +++ 2 files changed, 58 insertions(+), 16 deletions(-)
lib/intel_compute.c +54 -16
@@ -89,6 +89,7 @@ struct bo_dict_entry {const char *name;uint32_t handle;enum bo_dict_type bo_type; +bool is_owner; };struct bo_sync {
@@ -169,14 +170,17 @@ static float *get_input_data(const struct bo_execenv *execenv,const struct user_execenv *user = execenv->user;float *input_data; -if (user && user->input_addr) { +if (user && user->input_addr && !user->input_bo) { input_data =from_user_pointer (user->input_addr); }else {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); + +/* Don't randomize on user passed bo */ +if ((!user) || (user && !user->input_bo)) +bo_randomize (input_data, execenv->loop_count); }return input_data;
@@ -189,7 +193,7 @@ static float *get_output_data(const struct bo_execenv *execenv,const struct user_execenv *user = execenv->user;float *output_data; -if (user && user->output_addr) +if (user && user->output_addr && !user->output_bo) output_data =from_user_pointer (user->output_addr);else {struct bo_dict_entry *entry;
@@ -297,6 +301,7 @@ static void bo_execenv_bind(struct bo_execenv *execenv,uint32_t placement, flags =0 ; bo_sync->sync =0 ; + bo_dict[i].is_owner = true;switch (alloc_prefs) {case EXECENV_PREF_SYSTEM :
@@ -312,14 +317,38 @@ static void bo_execenv_bind(struct bo_execenv *execenv,break ; } - bo_dict[i].handle =xe_bo_create (fd, execenv->vm, bo_dict[i].size, - placement, flags); - bo_dict[i].data =xe_bo_map (fd, bo_dict[i].handle, bo_dict[i].size); -xe_vm_bind_async (fd, vm,0 , bo_dict[i].handle,0 , bo_dict[i].addr, - bo_dict[i].size, &sync,1 ); -xe_wait_ufence (fd, &bo_sync->sync,USER_FENCE_VALUE , exec_queue, -INT64_MAX ); -memset (bo_dict[i].data,0 , bo_dict[i].size); +/* +* For input/output buffers skip their creation if +* were passed from the user +*/ +if (execenv->user && bo_dict[i].bo_type ==BO_TYPE_INPUT && + execenv->user->input_addr) { + bo_dict[i].handle = execenv->user->input_bo; + bo_dict[i].addr = execenv->user->input_addr; + bo_dict[i].size = execenv->array_size *sizeof (float ); + bo_dict[i].is_owner = false; + }else if (execenv->user && bo_dict[i].bo_type ==BO_TYPE_OUTPUT && + execenv->user->output_addr) { + bo_dict[i].handle = execenv->user->output_bo; + bo_dict[i].addr = execenv->user->output_addr; + bo_dict[i].size = execenv->array_size *sizeof (float ); + bo_dict[i].is_owner = false; + }else { + bo_dict[i].handle =xe_bo_create (fd, execenv->vm, bo_dict[i].size, + placement, flags); + } + +if (bo_dict[i].handle) { +xe_vm_bind_async (fd, vm,0 , bo_dict[i].handle,0 , bo_dict[i].addr, + bo_dict[i].size, &sync,1 ); +xe_wait_ufence (fd, &bo_sync->sync,USER_FENCE_VALUE , exec_queue, +INT64_MAX ); + } + +if (bo_dict[i].is_owner) { + bo_dict[i].data =xe_bo_map (fd, bo_dict[i].handle, bo_dict[i].size); +memset (bo_dict[i].data,0 , bo_dict[i].size); + } igt_debug("[i: %2d name: %20s] data: %p, addr: %16llx, size: %llx\n", i, bo_dict[i].name, bo_dict[i].data,
@@ -385,11 +414,20 @@ static void bo_execenv_unbind(struct bo_execenv *execenv,for (int i =0 ; i < entries; i++) { bo_sync->sync =0 ; -xe_vm_unbind_async (fd, vm,0 ,0 , bo_dict[i].addr, bo_dict[i].size, &sync,1 ); -xe_wait_ufence (fd, &bo_sync->sync,USER_FENCE_VALUE , exec_queue, -INT64_MAX ); -munmap (bo_dict[i].data, bo_dict[i].size); -gem_close (fd, bo_dict[i].handle); +if (bo_dict[i].is_owner) { +xe_vm_unbind_async (fd, vm,0 ,0 , bo_dict[i].addr, bo_dict[i].size, &sync,1 ); +xe_wait_ufence (fd, &bo_sync->sync,USER_FENCE_VALUE , exec_queue, +INT64_MAX ); +munmap (bo_dict[i].data, bo_dict[i].size); + } +/* Keep user buffers intact */ +if (execenv->user) +if ((execenv->user->input_bo && bo_dict[i].bo_type ==BO_TYPE_INPUT ) || + (execenv->user->output_bo && bo_dict[i].bo_type ==BO_TYPE_OUTPUT )) +continue ; + +if (bo_dict[i].handle) +gem_close (fd, bo_dict[i].handle); }munmap (bo_sync, bo_size);
lib/intel_compute.h +4 -0
@@ -59,6 +59,10 @@ struct user_execenv {bool skip_results_check;/** @array_size: size of input and output arrays */ uint32_t array_size; +/** @input_bo: override default bo input handle if provided */ +uint32_t input_bo; +/** @output_bo: override default bo output handle if provided */ +uint32_t output_bo;/** @input_addr: override default address of the input array if provided */ uint64_t input_addr;/** @output_addr: override default address of the output array if provided */
Signature · 1 line
2.43.0
PATCH v3 3/5 lib/intel_compute: Use user offsets and loop size if provided
In reply to Zbigniew KempczyńskiIf user passes its own input/output or number of iterations start to use it instead of hardcoded ones. This pattern was already used in other pipelines and only Xe3p missed this.
--- lib/intel_compute.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/intel_compute.c +4 -2
@@ -2189,6 +2189,8 @@ static void xe3p_compute_exec(int fd, const unsigned char *kernel,struct inline_data idata = {};struct bo_execenv execenv;float *input_data, *output_data; +uint64_t bind_input_addr = (user && user->input_addr) ? user->input_addr :ADDR_INPUT ; +uint64_t bind_output_addr = (user && user->output_addr) ? user->output_addr :ADDR_OUTPUT ;uint64_t indirect_addr =ADDR_GENERAL_STATE_BASE +OFFSET_INDIRECT_DATA_START ;int entries =ARRAY_SIZE (bo_dict);int64_t timeout_one_ns =1 ;
@@ -2205,7 +2207,7 @@ static void xe3p_compute_exec(int fd, const unsigned char *kernel,memcpy (bo_dict[0 ].data, kernel, size);memset (bo_dict[1 ].data,0 ,4096 ); -xe3p_create_indirect_data (bo_dict[1 ].data,ADDR_INPUT ,ADDR_OUTPUT , +xe3p_create_indirect_data (bo_dict[1 ].data, bind_input_addr, bind_output_addr, execenv.loop_count); idata.xe3p.indirect_addr_lo = indirect_addr; idata.xe3p.indirect_addr_hi = indirect_addr >>32 ;
@@ -2233,7 +2235,7 @@ static void xe3p_compute_exec(int fd, const unsigned char *kernel, }if (!user || (user && !user->skip_results_check)) -bo_check_square (input_data, output_data, execenv.array_size); +bo_check_square (input_data, output_data, execenv.loop_count);bo_execenv_unbind (&execenv, bo_dict, entries);bo_execenv_destroy (&execenv);
Signature · 1 line
2.43.0
PATCH v3 4/5 tests/xe_compute: Exercise user passed buffers
In reply to Zbigniew KempczyńskiVerify 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.
---
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(+)
tests/intel/xe_compute.c +150 -0
@@ -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);
Signature · 1 line
2.43.0
PATCH v3 5/5 tests/xe_compute: Use appropriate feature in compute-square tests
In reply to Zbigniew KempczyńskiTest is doing compute-square calculation so pick 'Compute' instead of 'WMTP' is better choice.
--- tests/intel/xe_compute.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/intel/xe_compute.c +2 -2
@@ -495,8 +495,8 @@ test_eu_busy(uint64_t duration_sec)/** * SUBTEST: compute-square -* Mega feature: WMTP -* Sub-category: wmtp tests +* Mega feature: Compute +* Sub-category: compute tests * Functionality: OpenCL kernel * GPU requirement: TGL, PVC, LNL, PTL * Description:
Signature · 1 line
2.43.0