Skip to content

Commit

Permalink
Add properties parameter to all command-buffer commands
Browse files Browse the repository at this point in the history
Make changes to reflect OpenCL-Docs change KhronosGroup/OpenCL-Docs#1215
and requires header change KhronosGroup/OpenCL-Headers#260
to use preprocessor path with extra parameters
  • Loading branch information
EwanC committed Aug 15, 2024
1 parent b8981f5 commit 8eb259b
Show file tree
Hide file tree
Showing 17 changed files with 752 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,13 @@ struct MixedCommandsTest : public BasicCommandBufferTest
{
const cl_int pattern = pattern_base + i;
cl_int error = clCommandFillBufferKHR(
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
command_buffer, nullptr, nullptr, in_mem, &pattern,
sizeof(cl_int), 0, data_size(), 0, nullptr, nullptr, nullptr);
#else
command_buffer, nullptr, in_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, nullptr, nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

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

const size_t result_offset = i * sizeof(cl_int);
error = clCommandCopyBufferKHR(
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
command_buffer, nullptr, nullptr, out_mem, result_mem, 0,
result_offset, sizeof(cl_int), 0, nullptr, nullptr, nullptr);
#else
command_buffer, nullptr, out_mem, result_mem, 0, result_offset,
sizeof(cl_int), 0, nullptr, nullptr, nullptr);
#endif
test_error(error, "clCommandCopyBufferKHR failed");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,14 @@ struct MutableDispatchGlobalArguments : public MutableDispatchArgumentsTest

cl_int Run() override
{
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

cl_int error = clCommandNDRangeKernelKHR(
Expand Down Expand Up @@ -271,9 +276,14 @@ struct MutableDispatchLocalArguments : public MutableDispatchArgumentsTest
threads[0] = number_of_ints;
local_threads[0] = 1;

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

cl_int error = clCommandNDRangeKernelKHR(
Expand Down Expand Up @@ -404,9 +414,14 @@ struct MutableDispatchPODArguments : public MutableDispatchArgumentsTest
threads[0] = number_of_ints;
local_threads[0] = 1;

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

cl_int error = clCommandNDRangeKernelKHR(
Expand Down Expand Up @@ -534,9 +549,15 @@ struct MutableDispatchNullArguments : public MutableDispatchArgumentsTest

cl_int Run() override
{

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

cl_int error = clCommandNDRangeKernelKHR(
Expand Down Expand Up @@ -723,7 +744,11 @@ struct MutableDispatchSVMArguments : public MutableDispatchArgumentsTest
sizeof(init_buffer), &init_buffer);
test_error(error, "clSetKernelExecInfo failed for init_buffer");

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
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,8 +295,15 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest
// run command buffer with full mutable dispatch test
cl_int Run() override
{

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR, available_caps, 0
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
available_caps,
0
};

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

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

size_t globalDim[3] = { 4, 1, 1 }, localDim[3] = { 1, 1, 1 };
Expand Down Expand Up @@ -330,9 +335,14 @@ struct MutableDispatchImage2DArguments : public BasicMutableCommandBufferTest

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

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

error = clCommandNDRangeKernelKHR(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,26 @@ struct PropertiesArray : public InfoMutableCommandBufferTest

cl_int Run() override
{
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

cl_int error = clCommandNDRangeKernelKHR(
command_buffer, nullptr, props, kernel, 1, nullptr,
&global_work_size, nullptr, 0, nullptr, nullptr, &command);
test_error(error, "clCommandNDRangeKernelKHR failed");

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr test_props[] = { 0, 0, 0 };
#else
cl_ndrange_kernel_command_properties_khr test_props[] = { 0, 0, 0 };
#endif
size_t size;

error = clGetMutableCommandInfoKHR(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,27 @@ struct SimultaneousMutableDispatchTest : public BasicMutableCommandBufferTest
cl_sync_point_khr sync_points[2];
const cl_int pattern = pattern_pri;
cl_int error = clCommandFillBufferKHR(
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
work_command_buffer, nullptr, nullptr, in_mem, &pattern,
sizeof(cl_int), 0, data_size(), 0, nullptr, &sync_points[0],
nullptr);
#else
work_command_buffer, nullptr, in_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, &sync_points[0], nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
error = clCommandFillBufferKHR(work_command_buffer, nullptr, nullptr,
out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
#else
error = clCommandFillBufferKHR(work_command_buffer, nullptr, out_mem,
&overwritten_pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, &sync_points[1],
nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

error = clCommandNDRangeKernelKHR(
Expand Down Expand Up @@ -269,9 +282,15 @@ 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(
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
work_command_buffer, nullptr, nullptr, in_mem, &pattern_pri,
sizeof(cl_int), 0, data_size() * buffer_size_multiplier, 0, nullptr,
&sync_points[0], nullptr);
#else
work_command_buffer, nullptr, in_mem, &pattern_pri, sizeof(cl_int),
0, data_size() * buffer_size_multiplier, 0, nullptr,
&sync_points[0], nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

// to avoid overwriting the entire result buffer instead of filling
Expand Down Expand Up @@ -519,13 +538,24 @@ struct CrossQueueSimultaneousMutableDispatchTest
// record command buffer
cl_int pattern = 0;
cl_int error = clCommandFillBufferKHR(
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
command_buffer, nullptr, nullptr, out_mem, &pattern, sizeof(cl_int),
0, data_size(), 0, nullptr, nullptr, nullptr);
#else
command_buffer, nullptr, out_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, nullptr, nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");


#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
cl_command_properties_khr props[] = {
#else
cl_ndrange_kernel_command_properties_khr props[] = {
#endif
CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR,
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR, 0
CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
0
};

error = clCommandNDRangeKernelKHR(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
struct Configuration
{
const cl_command_buffer_properties_khr *command_buffer_properties;

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
const cl_command_properties_khr *ndrange_properties;
#else
const cl_ndrange_kernel_command_properties_khr *ndrange_properties;
#endif
};

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

// Define the ndrange properties
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
const cl_command_properties_khr ndrange_properties[] = {
#else
const cl_ndrange_kernel_command_properties_khr ndrange_properties[] = {
#endif
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 @@ -162,15 +162,29 @@ struct OutOfOrderTest : public BasicCommandBufferTest
cl_sync_point_khr sync_points[2];
const cl_int pattern = pattern_pri;
cl_int error =
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
nullptr, in_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, &sync_points[0],
nullptr);
#else
clCommandFillBufferKHR(out_of_order_command_buffer, nullptr, in_mem,
&pattern, sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[0], nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
error = clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
nullptr, out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
#else
error = clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

error = clCommandNDRangeKernelKHR(
Expand Down Expand Up @@ -214,9 +228,15 @@ 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(
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
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);
#else
out_of_order_command_buffer, nullptr, in_mem, &pattern_pri,
sizeof(cl_int), 0, data_size() * buffer_size_multiplier, 0, nullptr,
&sync_points[0], nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

// to avoid overwriting the entire result buffer instead of filling only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,41 @@ struct BarrierWithWaitListKHR : public BasicCommandBufferTest
cl_int Run() override
{
cl_int error =
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
nullptr, in_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, &sync_points[0],
nullptr);
#else
clCommandFillBufferKHR(out_of_order_command_buffer, nullptr, in_mem,
&pattern, sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[0], nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

const cl_int overwritten_pattern = 0xACDC;
#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
error = clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
nullptr, out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
#else
error = clCommandFillBufferKHR(out_of_order_command_buffer, nullptr,
out_mem, &overwritten_pattern,
sizeof(cl_int), 0, data_size(), 0,
nullptr, &sync_points[1], nullptr);
#endif
test_error(error, "clCommandFillBufferKHR failed");

#if CL_KHR_COMMAND_BUFFER_EXTENSION_VERSION > CL_MAKE_VERSION(0, 9, 4)
error = clCommandBarrierWithWaitListKHR(out_of_order_command_buffer,
nullptr, nullptr, 2,
sync_points, nullptr, nullptr);
#else
error = clCommandBarrierWithWaitListKHR(out_of_order_command_buffer,
nullptr, 2, sync_points,
nullptr, nullptr);
#endif
test_error(error, "clCommandBarrierWithWaitListKHR failed");

error = clCommandNDRangeKernelKHR(
Expand Down
Loading

0 comments on commit 8eb259b

Please sign in to comment.