Skip to content

api: Add test for clCreateProgramWithBinary with an embedded header - #2843

Open
funch0za wants to merge 3 commits into
KhronosGroup:mainfrom
funch0za:feature/binary_create_with_header
Open

funch0za wants to merge 3 commits into
KhronosGroup:mainfrom
funch0za:feature/binary_create_with_header

Conversation

@funch0za

Copy link
Copy Markdown
Contributor

The test verifies that a compiled binary obtained from a source program with an embedded header can be loaded with clCreateProgramWithBinary.

The test crashes on Rusticl radeonsi during clCreateProgramWithBinary. The process aborts with the assertion nir_shader_gather_info only works with linked shaders.

Tested on:

  • PoCL: passed.
  • Rusticl llvmpipe: passed.
  • Rusticl radeonsi: crash.

[run-test: test_api binary_create_with_header]

The test verifies that a compiled binary from a program with an embedded
header and an unresolved external kernel can be loaded using
`clCreateProgramWithBinary` and retains the
`CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT` type (per OpenCL spec).

[run-test: test_api binary_create_with_header]

REGISTER_TEST(binary_create_with_header)
{
cl_int error;

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.

Suggested change
cl_int error;
check_compiler_available(device);
cl_int error;

I think that test should also be added to subtests_to_skip_with_offline_compiler in test_common/harness/errorHelpers.cpp

Comment thread test_conformance/api/test_binary.cpp Outdated
Comment on lines +29 to +35
const char *sample_header_source =
"extern __kernel void CopyBuffer(__global float *src,\n"
" __global float *dst);\n";

const char *sample_header_name = "simple_header.h";

const char *sample_source_with_header =

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.

Suggested change
const char *sample_header_source =
"extern __kernel void CopyBuffer(__global float *src,\n"
" __global float *dst);\n";
const char *sample_header_name = "simple_header.h";
const char *sample_source_with_header =
static const char *sample_header_source =
"extern __kernel void CopyBuffer(__global float *src,\n"
" __global float *dst);\n";
static const char *sample_header_name = "simple_header.h";
static const char *sample_source_with_header =

Use check_compiler_available and skip the test in offline compilation
modes.
@funch0za
funch0za requested a review from rjodinchr October 11, 2026 23:27
Comment thread test_conformance/api/testBase.h Outdated
//
// Not all compiler tests need to use this macro, only those that don't use the
// test harness compiler helpers.
#define check_compiler_available(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.

Rather than duplicating check_compiler_available from test_conformance/compiler/testBase.h into test_conformance/api/testBase.h, could you move its definition from test_conformance/compiler/testBase.h to test_common/harness/testHarness.h (e.g. next to REQUIRE_EXTENSION) so both test suites share it?

@karolherbst

karolherbst commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

So I've looked into why this used to crash in rusticl (it doesn't anymore since 26.1) and the reason is simply that a binary was created from a program that has unresolved symbols left, meaning it can't be turned into an executable yet.

I think it would be better to reflect that in the test name explicitly.

Move the macro to testHarness.h next to REQUIRE_EXTENSION and remove
the duplicate definitions from both testBase.h headers.
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