Skip to content

Commit

Permalink
Add clSetCommandQueueProperty test
Browse files Browse the repository at this point in the history
Add test to check that clSetCommandQueueProperty
successfully changes command queue properties.

Fixes #904

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
  • Loading branch information
ellnor01 authored and ahesham-arm committed Jul 11, 2024
1 parent 6d60301 commit f45786b
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test_conformance/api/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
5 changes: 5 additions & 0 deletions test_conformance/api/procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
78 changes: 77 additions & 1 deletion test_conformance/api/test_queue_properties_queries.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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<cl_command_queue_properties> 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 (size_t 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),
&current_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),
&current_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;
}

0 comments on commit f45786b

Please sign in to comment.