Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clSetCommandQueueProperty test #1182

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
85 changes: 84 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) 2024 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,86 @@ 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);
if (err == CL_INVALID_OPERATION)
{
// Implementations are allowed to return an error for
// non-OpenCL 1.0 devices. In which case, skip the test.
return TEST_SKIPPED_ITSELF;
}

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;
}
Loading