Skip to content

OpenCL: fail the module when the built program lacks a source kernel - #1541

Draft
pvelesko wants to merge 2 commits into
mainfrom
2026-08-30-github-1539-missing-kernel-after-build
Draft

OpenCL: fail the module when the built program lacks a source kernel#1541
pvelesko wants to merge 2 commits into
mainfrom
2026-08-30-github-1539-missing-kernel-after-build

Conversation

@pvelesko

Copy link
Copy Markdown
Collaborator

Fixes #1539

On Mali the driver accepts a SPIR-V module with an unresolved __device__ function import: clBuildProgram returns CL_SUCCESS with an empty log but the kernel calling the import is left out of the program, so the runtime registered the module as compiled and then failed in the kernel binding with hipErrorLaunchFailure on every launch. After clCreateKernelsInProgram, CHIPModuleOpenCL::compile now compares the program's kernels with the source module's registered kernels and throws hipErrorSharedObjectInitFailed naming the missing ones, the same path a rejected build takes, so the module gets remembered as failed by #1525 (this complements that PR). The program is stored in the module cache only after the check passes.

Validated on Mali G52 (salami: both launches now return hipErrorSharedObjectInitFailed, warm and cold module cache) and on the Intel CPU OpenCL runtime (unchanged, clBuildProgram rejects the module). New test: tests/runtime/TestFix1539MissingKernelAfterBuild.hip.

…ernel

On Mali the OpenCL driver accepts a SPIR-V module with an unresolved
__device__ function import, returns CL_SUCCESS from clBuildProgram with
an empty log, and leaves the kernel that calls the import out of the
program. The runtime then fails in the kernel binding of
Device::getOrCreateModule with hipErrorLaunchFailure and the module is
never remembered as failed.

#1539
The Arm Mali driver accepts a SPIR-V module with an unresolved function
import: clBuildProgram returns CL_SUCCESS with an empty build log, but
clCreateKernelsInProgram returns a program without the kernels that call
the import. The module was registered as compiled and the kernel binding
in Device::getOrCreateModule then failed with hipErrorLaunchFailure on
every launch, and since compile() had not thrown, the module could never
be remembered as failed.

After clCreateKernelsInProgram, compare the program's kernels with the
source module's registered kernels and throw
hipErrorSharedObjectInitFailed naming the missing ones, the same path a
rejected build takes. The program is stored in the module cache only
after that check passes.

#1539
@pvelesko

Copy link
Copy Markdown
Collaborator Author

/run-aurora-ci

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.

OpenCL: Mali builds a module with an unresolved __device__ symbol and drops the kernel, reported as hipErrorLaunchFailure instead of a module load error

1 participant