Skip to content

Add negative test for non-uniform work-group size - #2851

Open
shajder wants to merge 3 commits into
KhronosGroup:mainfrom
shajder:api_negative_non_uniform_invalid_work_size
Open

shajder wants to merge 3 commits into
KhronosGroup:mainfrom
shajder:api_negative_non_uniform_invalid_work_size

Conversation

@shajder

@shajder shajder commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Related to #2790.

Checks that clEnqueueNDRangeKernel returns CL_INVALID_WORK_GROUP_SIZE for a non-uniform work-group when the program is built from source without -cl-std, so it is compiled for OpenCL C 1.x, on a device that supports non-uniform work-groups.

[run-test: test_api negative_enqueue_non_uniform_work_group_size]

Comment on lines +72 to +86
error = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_WORK_GROUP_SIZE,
sizeof(maxWorkGroupSize),
&maxWorkGroupSize, NULL);
test_error(error, "Unable to get max work group size from kernel");

cl_uint maxThreadDim = 0;
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
sizeof(maxThreadDim), &maxThreadDim, NULL);
test_error(error, "Unable to get max work item dimensions from device");

std::vector<size_t> workGroupMaxSizes(maxThreadDim, 0);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZES,
sizeof(size_t) * workGroupMaxSizes.size(),
workGroupMaxSizes.data(), NULL);
test_error(error, "Unable to get max work group sizes from device");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can use get_max_allowed_1d_work_group_size_on_device(device, kernel, &maxWorkGroupSize) from harness/kernelHelpers.h here instead of querying CL_KERNEL_WORK_GROUP_SIZE, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, and CL_DEVICE_MAX_WORK_GROUP_SIZES manually.

Suggested change
error = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_WORK_GROUP_SIZE,
sizeof(maxWorkGroupSize),
&maxWorkGroupSize, NULL);
test_error(error, "Unable to get max work group size from kernel");
cl_uint maxThreadDim = 0;
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
sizeof(maxThreadDim), &maxThreadDim, NULL);
test_error(error, "Unable to get max work item dimensions from device");
std::vector<size_t> workGroupMaxSizes(maxThreadDim, 0);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZES,
sizeof(size_t) * workGroupMaxSizes.size(),
workGroupMaxSizes.data(), NULL);
test_error(error, "Unable to get max work group sizes from device");
error = get_max_allowed_1d_work_group_size_on_device(device, kernel,
&maxWorkGroupSize);
test_error(error, "get_max_allowed_1d_work_group_size_on_device failed");

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.

Corrected

Comment on lines +34 to +54
const Version version = get_device_cl_version(device);
cl_bool nonUniformSupport = CL_FALSE;
if (version >= Version(3, 0))
{
error = clGetDeviceInfo(
device, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT,
sizeof(nonUniformSupport), &nonUniformSupport, NULL);
test_error(error,
"Unable to query CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT");
}
else if (version >= Version(2, 0))
{
nonUniformSupport = CL_TRUE;
}

if (nonUniformSupport == CL_FALSE)
{
log_info("Device does not support non-uniform work-groups, skipping "
"test\n");
return TEST_SKIPPED_ITSELF;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we actually need to skip when nonUniformSupport == CL_FALSE? Even on OpenCL 1.2 devices (or OpenCL 3.0 devices without non-uniform work-group support), clEnqueueNDRangeKernel is still required to return CL_INVALID_WORK_GROUP_SIZE for this enqueue. Removing this check would simplify the test and also cover OpenCL 1.2 devices (which aren't covered by consistency_non_uniform_work_group or options_uniform_work_group_size).

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.

yep, good point - corrected

rjodinchr
rjodinchr previously approved these changes Oct 20, 2026
@rjodinchr

Copy link
Copy Markdown
Collaborator

Please rebase

@shajder
shajder force-pushed the api_negative_non_uniform_invalid_work_size branch from d490fa4 to a852383 Compare October 21, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants