Skip to content

Commit

Permalink
Add properties parameter to all command-buffer commands (update) (#2072)
Browse files Browse the repository at this point in the history
This is an update to #2050, with updates from the main branch.

---------

Co-authored-by: Ewan Crawford <[email protected]>
  • Loading branch information
bashbaug and EwanC authored Sep 6, 2024
1 parent 0bdc5d0 commit b57f90e
Show file tree
Hide file tree
Showing 19 changed files with 351 additions and 338 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ struct MixedCommandsTest : public BasicCommandBufferTest
{
const cl_int pattern = pattern_base + i;
cl_int error = clCommandFillBufferKHR(
command_buffer, nullptr, in_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, nullptr, nullptr);
command_buffer, nullptr, nullptr, in_mem, &pattern,
sizeof(cl_int), 0, data_size(), 0, nullptr, nullptr, nullptr);
test_error(error, "clCommandFillBufferKHR failed");

error = clCommandNDRangeKernelKHR(
Expand All @@ -265,8 +265,8 @@ struct MixedCommandsTest : public BasicCommandBufferTest

const size_t result_offset = i * sizeof(cl_int);
error = clCommandCopyBufferKHR(
command_buffer, nullptr, out_mem, result_mem, 0, result_offset,
sizeof(cl_int), 0, nullptr, nullptr, nullptr);
command_buffer, nullptr, nullptr, out_mem, result_mem, 0,
result_offset, sizeof(cl_int), 0, nullptr, nullptr, nullptr);
test_error(error, "clCommandCopyBufferKHR failed");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,30 @@ template <class T>
int MakeAndRunTest(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
CHECK_COMMAND_BUFFER_EXTENSION_AVAILABLE(device);
if (!is_extension_available(device, "cl_khr_command_buffer"))
{
log_info("Device does not support 'cl_khr_command_buffer'. Skipping "
"the test.\n");
return TEST_SKIPPED_ITSELF;
}

Version device_version = get_device_cl_version(device);
if ((device_version >= Version(3, 0))
|| is_extension_available(device, "cl_khr_extended_versioning"))
{

cl_version extension_version =
get_extension_version(device, "cl_khr_command_buffer");

if (extension_version < CL_MAKE_VERSION(0, 9, 5))
{

log_info("cl_khr_command_buffer version 0.9.5 or later is required "
"to run "
"the test, skipping.\n ");
return TEST_SKIPPED_ITSELF;
}
}
try
{
auto test_fixture = T(device, context, queue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct MutableDispatchGlobalArguments : public MutableDispatchArgumentsTest

cl_int Run() override
{
cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand Down Expand Up @@ -270,7 +270,7 @@ struct MutableDispatchLocalArguments : public MutableDispatchArgumentsTest
threads[0] = number_of_ints;
local_threads[0] = 1;

cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand Down Expand Up @@ -403,7 +403,7 @@ struct MutableDispatchPODArguments : public MutableDispatchArgumentsTest
threads[0] = number_of_ints;
local_threads[0] = 1;

cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand Down Expand Up @@ -533,7 +533,8 @@ struct MutableDispatchNullArguments : public MutableDispatchArgumentsTest

cl_int Run() override
{
cl_ndrange_kernel_command_properties_khr props[] = {

cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand Down Expand Up @@ -721,7 +722,7 @@ struct MutableDispatchSVMArguments : public MutableDispatchArgumentsTest
sizeof(init_buffer), &init_buffer);
test_error(error, "clSetKernelExecInfo failed for init_buffer");

cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR
| CL_MUTABLE_DISPATCH_EXEC_INFO_KHR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest
// run command buffer with full mutable dispatch test
cl_int Run() override
{
cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR, available_caps, 0
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct MutableDispatchImage1DArguments : public BasicMutableCommandBufferTest
error = clSetKernelArg(kernel, 2, sizeof(cl_mem), &dst_image);
test_error(error, "Unable to set indexed kernel arguments");

cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand Down Expand Up @@ -331,7 +331,7 @@ struct MutableDispatchImage2DArguments : public BasicMutableCommandBufferTest

size_t globalDim[3] = { 4, 4, 1 }, localDim[3] = { 1, 1, 1 };

cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// CL_DEVICE_MUTABLE_DISPATCH_CAPABILITIES_KHR
// CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR
// CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR
// CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR
// CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR
// CL_MUTABLE_DISPATCH_KERNEL_KHR
// CL_MUTABLE_DISPATCH_DIMENSIONS_KHR
// CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR
Expand Down Expand Up @@ -117,9 +117,27 @@ struct PropertiesArray : public InfoMutableCommandBufferTest
: InfoMutableCommandBufferTest(device, context, queue)
{}

virtual bool Skip() override
{
Version device_version = get_device_cl_version(device);
if ((device_version >= Version(3, 0))
|| is_extension_available(device, "cl_khr_extended_versioning"))
{

cl_version extension_version = get_extension_version(
device, "cl_khr_command_buffer_mutable_dispatch");

if (extension_version < CL_MAKE_VERSION(0, 9, 3))
{
return true;
}
}
return InfoMutableCommandBufferTest::Skip();
}

cl_int Run() override
{
cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand All @@ -129,11 +147,11 @@ struct PropertiesArray : public InfoMutableCommandBufferTest
&global_work_size, nullptr, 0, nullptr, nullptr, &command);
test_error(error, "clCommandNDRangeKernelKHR failed");

cl_ndrange_kernel_command_properties_khr test_props[] = { 0, 0, 0 };
cl_command_properties_khr test_props[] = { 0, 0, 0 };
size_t size;

error = clGetMutableCommandInfoKHR(
command, CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR,
command, CL_MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR,
sizeof(test_props), test_props, &size);
test_error(error, "clGetMutableCommandInfoKHR failed");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,15 @@ struct SimultaneousMutableDispatchTest : public BasicMutableCommandBufferTest
cl_sync_point_khr sync_points[2];
const cl_int pattern = pattern_pri;
cl_int error = clCommandFillBufferKHR(
work_command_buffer, nullptr, in_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, &sync_points[0], nullptr);
work_command_buffer, nullptr, nullptr, in_mem, &pattern,
sizeof(cl_int), 0, data_size(), 0, nullptr, &sync_points[0],
nullptr);
test_error(error, "clCommandFillBufferKHR failed");

error = clCommandFillBufferKHR(work_command_buffer, nullptr, out_mem,
&overwritten_pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, &sync_points[1],
nullptr);
error = clCommandFillBufferKHR(work_command_buffer, nullptr, nullptr,
out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
test_error(error, "clCommandFillBufferKHR failed");

error = clCommandNDRangeKernelKHR(
Expand Down Expand Up @@ -268,8 +269,8 @@ struct SimultaneousMutableDispatchTest : public BasicMutableCommandBufferTest
cl_sync_point_khr sync_points[2];
// for both simultaneous passes this call will fill entire in_mem buffer
cl_int error = clCommandFillBufferKHR(
work_command_buffer, nullptr, in_mem, &pattern_pri, sizeof(cl_int),
0, data_size() * buffer_size_multiplier, 0, nullptr,
work_command_buffer, nullptr, nullptr, in_mem, &pattern_pri,
sizeof(cl_int), 0, data_size() * buffer_size_multiplier, 0, nullptr,
&sync_points[0], nullptr);
test_error(error, "clCommandFillBufferKHR failed");

Expand Down Expand Up @@ -517,11 +518,11 @@ struct CrossQueueSimultaneousMutableDispatchTest
// record command buffer
cl_int pattern = 0;
cl_int error = clCommandFillBufferKHR(
command_buffer, nullptr, out_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, nullptr, nullptr);
command_buffer, nullptr, nullptr, out_mem, &pattern, sizeof(cl_int),
0, data_size(), 0, nullptr, nullptr, nullptr);
test_error(error, "clCommandFillBufferKHR failed");

cl_ndrange_kernel_command_properties_khr props[] = {
cl_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
struct Configuration
{
const cl_command_buffer_properties_khr *command_buffer_properties;
const cl_ndrange_kernel_command_properties_khr *ndrange_properties;
const cl_command_properties_khr *ndrange_properties;
};

// Define the command buffer properties for each configuration
Expand All @@ -44,7 +44,7 @@ const cl_command_buffer_properties_khr command_buffer_properties[] = {
};

// Define the ndrange properties
const cl_ndrange_kernel_command_properties_khr ndrange_properties[] = {
const cl_command_properties_khr ndrange_properties[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR, CL_MUTABLE_DISPATCH_ASSERTS_KHR,
CL_MUTABLE_DISPATCH_ASSERT_NO_ADDITIONAL_WORK_GROUPS_KHR, 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ struct OutOfOrderTest : public BasicCommandBufferTest
{
cl_sync_point_khr sync_points[2];
const cl_int pattern = pattern_pri;
cl_int error =
clCommandFillBufferKHR(out_of_order_command_buffer, nullptr, in_mem,
&pattern, sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[0], nullptr);
cl_int error = clCommandFillBufferKHR(
out_of_order_command_buffer, nullptr, nullptr, in_mem, &pattern,
sizeof(cl_int), 0, data_size(), 0, nullptr, &sync_points[0],
nullptr);
test_error(error, "clCommandFillBufferKHR failed");

error = clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
out_mem, &overwritten_pattern,
nullptr, out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
test_error(error, "clCommandFillBufferKHR failed");
Expand Down Expand Up @@ -214,7 +214,7 @@ struct OutOfOrderTest : public BasicCommandBufferTest
cl_sync_point_khr sync_points[2];
// for both simultaneous passes this call will fill entire in_mem buffer
cl_int error = clCommandFillBufferKHR(
out_of_order_command_buffer, nullptr, in_mem, &pattern_pri,
out_of_order_command_buffer, nullptr, nullptr, in_mem, &pattern_pri,
sizeof(cl_int), 0, data_size() * buffer_size_multiplier, 0, nullptr,
&sync_points[0], nullptr);
test_error(error, "clCommandFillBufferKHR failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ struct BarrierWithWaitListKHR : public BasicCommandBufferTest

cl_int Run() override
{
cl_int error =
clCommandFillBufferKHR(out_of_order_command_buffer, nullptr, in_mem,
&pattern, sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[0], nullptr);
cl_int error = clCommandFillBufferKHR(
out_of_order_command_buffer, nullptr, nullptr, in_mem, &pattern,
sizeof(cl_int), 0, data_size(), 0, nullptr, &sync_points[0],
nullptr);
test_error(error, "clCommandFillBufferKHR failed");

const cl_int overwritten_pattern = 0xACDC;
error = clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
out_mem, &overwritten_pattern,
nullptr, out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
test_error(error, "clCommandFillBufferKHR failed");

error = clCommandBarrierWithWaitListKHR(out_of_order_command_buffer,
nullptr, 2, sync_points,
nullptr, nullptr);
nullptr, nullptr, 2,
sync_points, nullptr, nullptr);
test_error(error, "clCommandBarrierWithWaitListKHR failed");

error = clCommandNDRangeKernelKHR(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,4 @@ class clCommandBufferWrapper {

operator cl_command_buffer_khr() const { return object; }
};

#define CHECK_COMMAND_BUFFER_EXTENSION_AVAILABLE(device) \
{ \
if (!is_extension_available(device, "cl_khr_command_buffer")) \
{ \
log_info( \
"Device does not support 'cl_khr_command_buffer'. Skipping " \
"the test.\n"); \
return TEST_SKIPPED_ITSELF; \
} \
}


#endif // CL_KHR_COMMAND_BUFFER_TEST_BASE_H
Loading

0 comments on commit b57f90e

Please sign in to comment.