Skip to content

Add device-side execution test for cl_khr_command_buffer#2657

Open
shajder wants to merge 2 commits intoKhronosGroup:mainfrom
shajder:command_buffer_device_execution
Open

Add device-side execution test for cl_khr_command_buffer#2657
shajder wants to merge 2 commits intoKhronosGroup:mainfrom
shajder:command_buffer_device_execution

Conversation

@shajder
Copy link
Copy Markdown
Contributor

@shajder shajder commented Apr 2, 2026

Related to #1667

Adds a test verifying that a command-buffer can record and replay a
kernel which performs device-side enqueue via enqueue_kernel()
Copy link
Copy Markdown
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

I haven't got a device handy that can run this test but LGTM

Copy link
Copy Markdown
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

I didn't do a very thorough review but I did ensure that this test works on the Intel CPU OpenCL device when the OpenCL C version issue is fixed.

Comment on lines +121 to +129
error = create_single_kernel_helper_create_program(context, &program, 1,
&kernel_str);
test_error(error, "Failed to create program with source");

error = clBuildProgram(program, 1, &device, nullptr, nullptr, nullptr);
test_error(error, "Failed to build program");

kernel = clCreateKernel(program, "device_enqueue", &error);
test_error(error, "Failed to create device execution kernel");
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.

This is overly verbose and it doesn't work - device-side enqueue requires OpenCL C 2.0 or newer, and passing nullptr as build options means we're getting the default latest version of OpenCL C 1.x.

How about instead:

Suggested change
error = create_single_kernel_helper_create_program(context, &program, 1,
&kernel_str);
test_error(error, "Failed to create program with source");
error = clBuildProgram(program, 1, &device, nullptr, nullptr, nullptr);
test_error(error, "Failed to build program");
kernel = clCreateKernel(program, "device_enqueue", &error);
test_error(error, "Failed to create device execution kernel");
error = create_single_kernel_helper(context, &program, &kernel, 1,
&kernel_str, "device_enqueue");
test_error(error, "Failed to create test kernel");


} // anonymous namespace

REGISTER_TEST(device_execution)
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.

Nitpick: I think the name of this test is misleading, since almost all of the command buffer tests (except maybe the negative tests) are executing on the device.

Should the name of this test be "device_enqueue" instead?

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.

5 participants