Skip to content

Commit

Permalink
const more mutable-dispatch test variables
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanC committed Sep 24, 2024
1 parent e4f9f80 commit c14327a
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 216 deletions.
2 changes: 1 addition & 1 deletion source/cl/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ endif()
if(${OCL_EXTENSION_cl_khr_command_buffer_mutable_dispatch})
# Intentionally misnamed. Windows guesses that executables with "patch"
# in the file name are installers and need admin privileges.
add_ca_cl_example(clMutableDispathcKHR
add_ca_cl_example(clMutableDispatchKHR
${CMAKE_CURRENT_SOURCE_DIR}/MutableDispatchKHR/source/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/common.h)
endif()
Expand Down
6 changes: 3 additions & 3 deletions source/cl/examples/MutableDispatchKHR/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ int main(const int argc, const char **argv) {
&input_B_buffer};
const cl_mutable_dispatch_arg_khr arg_2{2, sizeof(cl_mem),
&output_buffer};
cl_mutable_dispatch_arg_khr args[] = {arg_0, arg_1, arg_2};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_arg_khr args[] = {arg_0, arg_1, arg_2};
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle,
3 /* num_args */,
0 /* num_svm_arg */,
Expand All @@ -231,7 +231,7 @@ int main(const int argc, const char **argv) {

// Update the command buffer with the mutable configuration
const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};
error = clUpdateMutableCommandsKHR(command_buffer, num_configs,
Expand Down
4 changes: 2 additions & 2 deletions source/cl/source/extension/source/khr_command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,9 @@ cargo::expected<mux_descriptor_info_s, cl_int> createArgumentDescriptor(
const cl_device_id device = command_queue->device;

// Verify struct configures kernel arguments and return error if malformed
for (const auto config_ptr : mutable_dispatch_configs) {
for (const auto &config_ptr : mutable_dispatch_configs) {
OCL_CHECK(config_ptr == nullptr, return CL_INVALID_VALUE);
const cl_mutable_dispatch_config_khr config = *config_ptr;
const cl_mutable_dispatch_config_khr &config = *config_ptr;
OCL_CHECK(!config.command, return CL_INVALID_MUTABLE_COMMAND_KHR);
OCL_CHECK(config.command->command_buffer != this,
return CL_INVALID_MUTABLE_COMMAND_KHR);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,20 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidSimulataneousUse) {
// command object
TEST_F(CommandBufferUpdateNDKernel, NullHandle) {
ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer));
cl_mutable_dispatch_config_khr dispatch_config{nullptr /* command */,
0,
0,
0,
0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr};
const cl_mutable_dispatch_config_khr dispatch_config{nullptr /* command */,
0,
0,
0,
0,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -205,7 +205,7 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidHandle) {
EXPECT_SUCCESS(clFinalizeCommandBufferKHR(new_command_buffer));

const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &dst_buffer};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
new_command_handle /* command */,
1,
0,
Expand All @@ -219,7 +219,7 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidHandle) {
nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -295,11 +295,11 @@ TEST_F(CommandBufferUpdateNDKernel, ImmutablePropertyBit) {
ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer));

const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &dst_buffer};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};
const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -333,7 +333,7 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgList) {
nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -372,12 +372,12 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgIndex) {
ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer));
const cl_mutable_dispatch_arg_khr arg = {3 /* arg_index */, sizeof(cl_mem),
&src_buffer};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -432,12 +432,12 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgValue) {
EXPECT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer));
const cl_mutable_dispatch_arg_khr arg = {0, sizeof(cl_mem),
&image /* arg_value */};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand All @@ -460,12 +460,12 @@ TEST_F(CommandBufferUpdateNDKernel, InvalidArgSize) {

ASSERT_SUCCESS(clFinalizeCommandBufferKHR(command_buffer));
const cl_mutable_dispatch_arg_khr arg = {0, 2 /* arg_size */, &src_buffer};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -522,12 +522,12 @@ TEST_F(CommandBufferUpdateNDKernel, IterativeArgumentUpdate) {
// Update both the input and output buffer, reusing the same
// cl_mutable_dispatch_arg_khr struct
cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_mem), &updated_src_buffer};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -607,11 +607,11 @@ TEST_F(CommandBufferUpdateNDKernel, OverwriteArgumentUpdate) {
// Update both the input and output buffer, reusing the same
// cl_mutable_dispatch_arg_khr struct
cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &unused_dst_buffer};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};
const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -677,12 +677,12 @@ TEST_F(CommandBufferUpdateNDKernel, NoMutablePropertiesSet) {

// Update the output buffer
const cl_mutable_dispatch_arg_khr arg{1, sizeof(cl_mem), &updated_dst_buffer};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -799,12 +799,12 @@ TEST_F(CommandBufferSimultaneousUpdate, UpdatePending) {
const cl_mutable_dispatch_arg_khr args[2] = {
{0, sizeof(cl_mem), &updated_src_buffer},
{1, sizeof(cl_mem), &updated_dst_buffer}};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 2, 0, 0, 0, args,
nullptr, nullptr, nullptr, nullptr, nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -854,7 +854,7 @@ TEST_F(CommandBufferSimultaneousUpdate, ConsecutiveUpdate) {
nullptr, nullptr, nullptr, nullptr, nullptr};

const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down Expand Up @@ -926,14 +926,14 @@ TEST_F(CommandBufferSimultaneousUpdate, MultipleCommands) {
&updated_dst_buffer};
const cl_mutable_dispatch_arg_khr arg2 = {0, sizeof(cl_mem),
&updated_dst_buffer};
cl_mutable_dispatch_config_khr dispatch_configs[2] = {
const cl_mutable_dispatch_config_khr dispatch_configs[2] = {
{command_handle, 1, 0, 0, 0, &arg1, nullptr, nullptr, nullptr, nullptr,
nullptr},
{command_handle2, 1, 0, 0, 0, &arg2, nullptr, nullptr, nullptr, nullptr,
nullptr}};

const cl_uint num_configs = 2;
cl_command_buffer_update_type_khr config_types[2] = {
const cl_command_buffer_update_type_khr config_types[2] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR,
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[2] = {&dispatch_configs[0], &dispatch_configs[1]};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ TEST_F(MutableDispatchThreadSafetyTest, UpdateInParallel) {
// Create a mutable config.
const cl_mutable_dispatch_arg_khr arg{0, sizeof(cl_int),
&updated_input_value};
cl_mutable_dispatch_config_khr dispatch_config{
const cl_mutable_dispatch_config_khr dispatch_config{
command_handle, 1, 0, 0, 0, &arg,
nullptr, nullptr, nullptr, nullptr, nullptr};
// Update the nd range.
const cl_uint num_configs = 1;
cl_command_buffer_update_type_khr config_types[1] = {
const cl_command_buffer_update_type_khr config_types[1] = {
CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR};
const void *configs[1] = {&dispatch_config};

Expand Down
Loading

0 comments on commit c14327a

Please sign in to comment.