mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Command buffer test adjustments (#2141)
Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com> Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e360d2de5b
commit
96e3d7e669
@@ -70,6 +70,9 @@ bool BasicCommandBufferTest::Skip()
|
||||
!= 0;
|
||||
out_of_order_support =
|
||||
capabilities & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR;
|
||||
device_side_enqueue_support =
|
||||
(capabilities & CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR)
|
||||
!= 0;
|
||||
|
||||
// Skip if queue properties don't contain those required
|
||||
return required_properties != (required_properties & queue_properties);
|
||||
@@ -177,6 +180,71 @@ cl_int BasicCommandBufferTest::SetUp(int elements)
|
||||
|
||||
namespace {
|
||||
|
||||
// Test that the CL_COMMAND_BUFFER_FLAGS_KHR bitfield is parsed correctly when
|
||||
// multiple flags are set.
|
||||
struct MultiFlagCreationTest : public BasicCommandBufferTest
|
||||
{
|
||||
using BasicCommandBufferTest::BasicCommandBufferTest;
|
||||
|
||||
cl_int Run() override
|
||||
{
|
||||
cl_command_buffer_properties_khr flags = 0;
|
||||
size_t num_flags_set = 0;
|
||||
bool multi_flags_supported = true;
|
||||
cl_int error = CL_SUCCESS;
|
||||
|
||||
// First try to find multiple flags that are supported by the driver and
|
||||
// device.
|
||||
if (simultaneous_use_support)
|
||||
{
|
||||
flags |= CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR;
|
||||
num_flags_set++;
|
||||
}
|
||||
|
||||
if (device_side_enqueue_support)
|
||||
{
|
||||
flags |= CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR;
|
||||
num_flags_set++;
|
||||
}
|
||||
|
||||
if (is_extension_available(
|
||||
device, CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_NAME))
|
||||
{
|
||||
flags |= CL_COMMAND_BUFFER_MUTABLE_KHR;
|
||||
num_flags_set++;
|
||||
}
|
||||
|
||||
// If we can't find multiple supported flags, still set a bitfield but
|
||||
// expect CL_INVALID_PROPERTY to be returned on creation.
|
||||
if (num_flags_set < 2)
|
||||
{
|
||||
flags = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR
|
||||
| CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR;
|
||||
|
||||
multi_flags_supported = false;
|
||||
}
|
||||
|
||||
cl_command_buffer_properties_khr props[] = {
|
||||
CL_COMMAND_BUFFER_FLAGS_KHR, flags, 0
|
||||
};
|
||||
|
||||
command_buffer = clCreateCommandBufferKHR(1, &queue, props, &error);
|
||||
if (multi_flags_supported)
|
||||
{
|
||||
test_error(error, "clCreateCommandBufferKHR failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
test_failure_error_ret(
|
||||
error, CL_INVALID_PROPERTY,
|
||||
"clCreateCommandBufferKHR should return CL_INVALID_PROPERTY",
|
||||
TEST_FAIL);
|
||||
}
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
// Test enqueuing a command-buffer containing a single NDRange command once
|
||||
struct BasicEnqueueTest : public BasicCommandBufferTest
|
||||
{
|
||||
@@ -421,6 +489,13 @@ struct InterleavedEnqueueTest : public BasicCommandBufferTest
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int test_multi_flag_creation(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return MakeAndRunTest<MultiFlagCreationTest>(device, context, queue,
|
||||
num_elements);
|
||||
}
|
||||
|
||||
int test_single_ndrange(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,7 @@ protected:
|
||||
// Device support query results
|
||||
bool simultaneous_use_support;
|
||||
bool out_of_order_support;
|
||||
bool device_side_enqueue_support;
|
||||
|
||||
// user request for simultaneous use
|
||||
bool simultaneous_use_requested;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "harness/testHarness.h"
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST(multi_flag_creation),
|
||||
ADD_TEST(single_ndrange),
|
||||
ADD_TEST(interleaved_enqueue),
|
||||
ADD_TEST(mixed_commands),
|
||||
|
||||
@@ -102,9 +102,8 @@ struct CreateCommandBufferRepeatedProperties : public BasicCommandBufferTest
|
||||
cl_int error = CL_SUCCESS;
|
||||
|
||||
cl_command_buffer_properties_khr repeated_properties[5] = {
|
||||
CL_COMMAND_BUFFER_FLAGS_KHR, CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR,
|
||||
CL_COMMAND_BUFFER_FLAGS_KHR, CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR,
|
||||
0
|
||||
CL_COMMAND_BUFFER_FLAGS_KHR, rep_prop, CL_COMMAND_BUFFER_FLAGS_KHR,
|
||||
rep_prop, 0
|
||||
};
|
||||
|
||||
command_buffer =
|
||||
@@ -127,6 +126,33 @@ struct CreateCommandBufferRepeatedProperties : public BasicCommandBufferTest
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
bool Skip() override
|
||||
{
|
||||
bool skip = true;
|
||||
|
||||
if (simultaneous_use_support)
|
||||
{
|
||||
rep_prop = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR;
|
||||
skip = false;
|
||||
}
|
||||
else if (device_side_enqueue_support)
|
||||
{
|
||||
rep_prop = CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR;
|
||||
skip = false;
|
||||
}
|
||||
else if (is_extension_available(
|
||||
device,
|
||||
CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_NAME))
|
||||
{
|
||||
rep_prop = CL_COMMAND_BUFFER_MUTABLE_KHR;
|
||||
skip = false;
|
||||
}
|
||||
|
||||
return skip;
|
||||
}
|
||||
|
||||
cl_command_buffer_properties_khr rep_prop = 0;
|
||||
};
|
||||
|
||||
// CL_INVALID_PROPERTY if values specified in properties are valid but are not
|
||||
@@ -140,8 +166,7 @@ struct CreateCommandBufferNotSupportedProperties : public BasicCommandBufferTest
|
||||
cl_int error = CL_SUCCESS;
|
||||
|
||||
cl_command_buffer_properties_khr properties[3] = {
|
||||
CL_COMMAND_BUFFER_FLAGS_KHR, CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR,
|
||||
0
|
||||
CL_COMMAND_BUFFER_FLAGS_KHR, unsupported_prop, 0
|
||||
};
|
||||
|
||||
command_buffer =
|
||||
@@ -156,21 +181,23 @@ struct CreateCommandBufferNotSupportedProperties : public BasicCommandBufferTest
|
||||
|
||||
bool Skip() override
|
||||
{
|
||||
cl_device_command_buffer_capabilities_khr capabilities;
|
||||
cl_int error =
|
||||
clGetDeviceInfo(device, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR,
|
||||
sizeof(capabilities), &capabilities, NULL);
|
||||
test_error(error,
|
||||
"Unable to query CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR");
|
||||
bool skip = true;
|
||||
|
||||
bool device_supports_simultaneous_use =
|
||||
(capabilities & CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR)
|
||||
!= 0;
|
||||
if (!simultaneous_use_support)
|
||||
{
|
||||
unsupported_prop = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR;
|
||||
skip = false;
|
||||
}
|
||||
else if (!device_side_enqueue_support)
|
||||
{
|
||||
unsupported_prop = CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR;
|
||||
skip = false;
|
||||
}
|
||||
|
||||
// If device supports command queue property
|
||||
// CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR test should be skipped
|
||||
return device_supports_simultaneous_use;
|
||||
return skip;
|
||||
}
|
||||
|
||||
cl_command_buffer_properties_khr unsupported_prop = 0;
|
||||
};
|
||||
|
||||
// CL_INCOMPATIBLE_COMMAND_QUEUE_KHR if the properties of any command-queue in
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <CL/cl.h>
|
||||
|
||||
// Basic command-buffer tests
|
||||
extern int test_multi_flag_creation(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements);
|
||||
extern int test_single_ndrange(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements);
|
||||
extern int test_interleaved_enqueue(cl_device_id device, cl_context context,
|
||||
|
||||
Reference in New Issue
Block a user