From d86f04ae4a8ea82a4f8992b3a76a6f8b22c2b339 Mon Sep 17 00:00:00 2001 From: Michal Babej <michal.babej@intel.com> Date: Thu, 10 Oct 2024 15:17:18 +0300 Subject: [PATCH] fix tests & poclu to not use out-of-order queues unconditionally --- poclu/misc.c | 24 +++++++++++++------ poclu/poclu.h | 12 ++++++---- tests/runtime/test_buffer_migration.c | 3 ++- .../test_cl_pocl_content_size_migration.c | 2 +- tests/runtime/test_command_buffer.c | 9 +++++-- tests/runtime/test_command_buffer_images.c | 9 +++++-- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/poclu/misc.c b/poclu/misc.c index db5426061..35979db83 100644 --- a/poclu/misc.c +++ b/poclu/misc.c @@ -111,10 +111,13 @@ poclu_get_any_device2 (cl_context *context, cl_device_id *device, } cl_int -poclu_get_multiple_devices (cl_platform_id *platform, cl_context *context, - cl_char include_custom_dev, cl_uint *num_devices, - cl_device_id **devices, cl_command_queue **queues, - int ooo_queues) +poclu_get_multiple_devices (cl_platform_id *platform, + cl_context *context, + cl_char include_custom_dev, + cl_uint *num_devices, + cl_device_id **devices, + cl_command_queue **queues, + cl_command_queue_properties optional_props) { cl_int err; cl_uint num_dev_all = 0; @@ -185,11 +188,13 @@ poclu_get_multiple_devices (cl_platform_id *platform, cl_context *context, if (err != CL_SUCCESS) goto ERROR; - cl_command_queue_properties props = CL_QUEUE_PROFILING_ENABLE; - if (ooo_queues) - props |= CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; for (i = 0; i < *num_devices; ++i) { + cl_command_queue_properties dev_props = 0; + CHECK_CL_ERROR (clGetDeviceInfo (devs[i], + CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, + sizeof (dev_props), &dev_props, NULL)); + cl_command_queue_properties props = dev_props & optional_props; ques[i] = clCreateCommandQueue (*context, devs[i], props, &err); if (err != CL_SUCCESS) goto ERROR; @@ -201,6 +206,11 @@ poclu_get_multiple_devices (cl_platform_id *platform, cl_context *context, ERROR: free (devs); + for (i = 0; i < *num_devices; ++i) + { + if (ques[i]) + clReleaseCommandQueue (ques[i]); + } free (ques); return err; } diff --git a/poclu/poclu.h b/poclu/poclu.h index 904092a47..0c16d4186 100644 --- a/poclu/poclu.h +++ b/poclu/poclu.h @@ -220,10 +220,14 @@ POCLU_API cl_int POCLU_CALL poclu_get_any_device (cl_context *context, * @return CL_SUCCESS on success, or a descriptive OpenCL error code upon * failure. */ -POCLU_API cl_int POCLU_CALL poclu_get_multiple_devices ( - cl_platform_id *platform, cl_context *context, cl_char include_custom_dev, - cl_uint *num_devices, cl_device_id **devices, cl_command_queue **queues, - int ooo_queues); +POCLU_API cl_int POCLU_CALL +poclu_get_multiple_devices (cl_platform_id *platform, + cl_context *context, + cl_char include_custom_dev, + cl_uint *num_devices, + cl_device_id **devices, + cl_command_queue **queues, + cl_command_queue_properties optional_props); /** * Convert a float to a cl_half (uint16_t). diff --git a/tests/runtime/test_buffer_migration.c b/tests/runtime/test_buffer_migration.c index b7f41c9b1..21299ef8a 100644 --- a/tests/runtime/test_buffer_migration.c +++ b/tests/runtime/test_buffer_migration.c @@ -55,7 +55,8 @@ main (int argc, char **argv) cl_event ev1, ev2; err = poclu_get_multiple_devices (&platform, &context, 0, &num_devices, - &devices, &queues, 1); + &devices, &queues, + CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE); CHECK_OPENCL_ERROR_IN ("poclu_get_multiple_devices"); printf ("NUM DEVICES: %u \n", num_devices); diff --git a/tests/runtime/test_cl_pocl_content_size_migration.c b/tests/runtime/test_cl_pocl_content_size_migration.c index 940b46fa2..c8907ae05 100644 --- a/tests/runtime/test_cl_pocl_content_size_migration.c +++ b/tests/runtime/test_cl_pocl_content_size_migration.c @@ -63,7 +63,7 @@ main (void) uint64_t content_size; poclu_get_multiple_devices (&platform, &context, CL_FALSE, &num_devices, - &devices, &queues, CL_FALSE); + &devices, &queues, 0); if (num_devices < 2) { printf ("Not enough devices (2 required), skipping"); diff --git a/tests/runtime/test_command_buffer.c b/tests/runtime/test_command_buffer.c index 29280bb5c..61009724d 100644 --- a/tests/runtime/test_command_buffer.c +++ b/tests/runtime/test_command_buffer.c @@ -118,8 +118,13 @@ main (int _argc, char **_argv) CHECK_CL_ERROR ( clSetKernelArg (kernel, 2, sizeof (buffer_res), &buffer_res)); - cl_command_queue command_queue = clCreateCommandQueue ( - context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &error); + cl_command_queue_properties props = 0; + CHECK_CL_ERROR (clGetDeviceInfo (device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, + sizeof (props), &props, NULL)); + if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) + props = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + cl_command_queue command_queue + = clCreateCommandQueue (context, device, props, &error); CHECK_CL_ERROR (error); cl_command_buffer_khr command_buffer diff --git a/tests/runtime/test_command_buffer_images.c b/tests/runtime/test_command_buffer_images.c index 6656d089a..a647292ed 100644 --- a/tests/runtime/test_command_buffer_images.c +++ b/tests/runtime/test_command_buffer_images.c @@ -116,8 +116,13 @@ main (int _argc, char **_argv) &img_desc, NULL, &error); CHECK_CL_ERROR (error); - cl_command_queue command_queue = clCreateCommandQueue ( - context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &error); + cl_command_queue_properties props = 0; + CHECK_CL_ERROR (clGetDeviceInfo (device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, + sizeof (props), &props, NULL)); + if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) + props = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + cl_command_queue command_queue + = clCreateCommandQueue (context, device, props, &error); CHECK_CL_ERROR (error); /**** Command buffer creation ****/ -- GitLab