Skip to content

mutable dispatch related fixes - #2143

Closed
franz wants to merge 3 commits into
KhronosGroup:mainfrom
franz:mutable_dispatch_fixes
Closed

mutable dispatch related fixes#2143
franz wants to merge 3 commits into
KhronosGroup:mainfrom
franz:mutable_dispatch_fixes

Conversation

@franz

@franz franz commented Nov 6, 2024

Copy link
Copy Markdown
Contributor

No description provided.

@franz
franz force-pushed the mutable_dispatch_fixes branch from c26f9eb to 2cdd0eb Compare November 6, 2024 19:00
franz and others added 3 commits November 27, 2024 16:54
…heck

the test checks 'cl_khr_extended_versioning' then immediately calls:
get_extension_version(device, "cl_khr_command_buffer_mutable_dispatch");
.. however, get_extension_version throws an exception when called
with unsupported extension.
the test uses CL_MUTABLE_DISPATCH_ARGUMENTS_KHR,
but does not check for support.
test MutableDispatchGlobalSize was failing (with an implementation that
doesn't support non-uniform WGs), because the update_global_size = 3
was not a multiple of the local work-size.

Fixed by increasing the global work-size to 256K and update size to 16K.
This should work with all devices that have max_work_group_size <= 16K.

Updates also MutableDispatchWorkGroups which had an out-of-bounds access,
because it hardcoded the value of global work-size.
@franz
franz force-pushed the mutable_dispatch_fixes branch from 2cdd0eb to a2fc5d8 Compare November 27, 2024 14:54
@franz
franz requested a review from EwanC November 27, 2024 15:53

@EwanC EwanC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it's taken me a while to re-review this.

My main thought from looking at this again is whether we need to be using as many as 256K and 16K work items for the test, which is quite a big increase on what we had before. I'm not sure if on embedded devices or simulators that would slow the test time down and not really give us that much extra testing coverage of the extension. Could we use work item sizes that are an order of magnitude less but still resolve the issues you've seen?

@bashbaug bashbaug left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz, are these changes still required? Other than the global work size modifications, I think all of the other fixes have already been made in other PRs (not ideal, obviously, but it is what it is).

Comment on lines +156 to +158
const size_t update_global_size = 16 * 1024;
const size_t sizeToAllocate = global_work_size * sizeof(cl_int);
const size_t num_elements = global_work_size;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sizeToAllocate issue was already fixed by #2437

Unless update_global_size needs to be modified, I believe these changes are no longer required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the update_global_size change was the main motivation of the PR. In the original code, the updated global size (3) is not a divisor of the initial global size (4*16). Is this expected to work even when the implementation doesn't support non-uniform workgroups ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this test is changing the global work size, not the local work size, and that the local work size recorded into the command buffer is initially nullptr:

error = clCommandNDRangeKernelKHR(
command_buffer, nullptr, nullptr, kernel, 1, nullptr,
&global_work_size, nullptr, 0, nullptr, nullptr, &command);

It is not modified by the mutable command update, so it remains nullptr:

cl_mutable_dispatch_config_khr dispatch_config{
command,
0 /* num_args */,
0 /* num_svm_arg */,
0 /* num_exec_infos */,
0 /* work_dim - 0 means no change to dimensions */,
nullptr /* arg_list */,
nullptr /* arg_svm_list - nullptr means no change*/,
nullptr /* exec_info_list */,
nullptr /* global_work_offset */,
&update_global_size /* global_work_size */,
nullptr /* local_work_size */

Therefore, I don't think there is any requirement to support non-uniform work-groups to run this test. Do you agree?

@franz franz Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that part of mutable dispatch was unclear to me. But i agree with your explanation.

Therefore there is no need to keep the update_global_size related changes of this PR, the issue is in our implementation.

If all the other changes are already fixed, we can close this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, if you do find that any of these fixes are still needed, feel free to re-open this PR (or open another new PR if it'd be easier). Thanks!

Comment on lines +142 to +143
if ((mutable_capabilities & CL_MUTABLE_DISPATCH_ARGUMENTS_KHR) == 0)
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these changes are all covered elsewhere now.

We removed this Skip function in #2498, since it was already covered in a base class.

This check for CL_DEVICE_MUTABLE_DISPATCH_CAPABILITIES has already existed in the Skip check in the base class, see:

bool mutable_support =
!clGetDeviceInfo(
device, CL_DEVICE_MUTABLE_DISPATCH_CAPABILITIES_KHR,
sizeof(mutable_capabilities), &mutable_capabilities, nullptr)
&& mutable_capabilities != 0;

@franz franz closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants