diff --git a/test_conformance/api/main.cpp b/test_conformance/api/main.cpp index cdbf1f799a..e6bfc8b17d 100644 --- a/test_conformance/api/main.cpp +++ b/test_conformance/api/main.cpp @@ -146,6 +146,8 @@ test_definition test_list[] = { ADD_TEST_VERSION(consistency_3d_image_writes, Version(3, 0)), ADD_TEST(min_image_formats), + ADD_TEST(set_command_queue_property), + ADD_TEST(negative_get_platform_info), ADD_TEST(negative_get_platform_ids), diff --git a/test_conformance/api/procs.h b/test_conformance/api/procs.h index 22426be1b8..2c6eddde98 100644 --- a/test_conformance/api/procs.h +++ b/test_conformance/api/procs.h @@ -58,6 +58,11 @@ extern int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context extern int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); extern int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_set_command_queue_property(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); + extern int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); extern int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); extern int test_min_max_work_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); diff --git a/test_conformance/api/test_queue_properties_queries.cpp b/test_conformance/api/test_queue_properties_queries.cpp index 843fa8454a..85a2a1469d 100644 --- a/test_conformance/api/test_queue_properties_queries.cpp +++ b/test_conformance/api/test_queue_properties_queries.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020-2021 The Khronos Group Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -267,3 +267,79 @@ int test_queue_properties_queries(cl_device_id deviceID, cl_context context, } return error; } + +int test_set_command_queue_property(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) +{ + int err; + + // Required minimum command queue properties + std::vector queue_property_options = { + 0, CL_QUEUE_PROFILING_ENABLE + }; + + // Add other supported properties combinations + cl_command_queue_properties supported_queue_props; + clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, + sizeof(supported_queue_props), &supported_queue_props, + NULL); + if (supported_queue_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) + { + queue_property_options.push_back( + CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE); + queue_property_options.push_back( + CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE); + } + + // Initialise each queue with a different set of properties. + for (cl_command_queue_properties initial_properties : + queue_property_options) + { + clCommandQueueWrapper test_queue = + clCreateCommandQueue(context, deviceID, initial_properties, &err); + test_error(err, "clCreateCommandQueue failed"); + + cl_command_queue_properties old_properties, set_properties, + current_properties = initial_properties; + + // Test clSetCommandQueueProperty with each set of properties, ignoring + // 0 as a property. + for (int i = 1; i < queue_property_options.size(); i++) + { + set_properties = queue_property_options[i]; + err = clSetCommandQueueProperty(test_queue, set_properties, + CL_FALSE, &old_properties); + test_error(err, "clSetCommandQueueProperty failed"); + test_assert_error(old_properties == current_properties, + "The old properties for this command queue were " + "not as expected"); + + err = clGetCommandQueueInfo(test_queue, CL_QUEUE_PROPERTIES, + sizeof(cl_queue_properties), + ¤t_properties, NULL); + test_error(err, "clGetCommandQueueInfo failed"); + test_assert_error(current_properties + == (old_properties & ~set_properties), + "The current properties for this command queue " + "were not as expected"); + + err = clSetCommandQueueProperty(test_queue, set_properties, CL_TRUE, + &old_properties); + test_error(err, "clSetCommandQueueProperty failed"); + test_assert_error(old_properties == current_properties, + "The old properties for this command queue were " + "not as expected"); + + err = clGetCommandQueueInfo(test_queue, CL_QUEUE_PROPERTIES, + sizeof(cl_queue_properties), + ¤t_properties, NULL); + test_error(err, "clGetCommandQueueInfo failed"); + test_assert_error(current_properties + == (set_properties | old_properties), + "The current properties for this command queue " + "were not as expected"); + } + } + + return TEST_PASS; +}