Skip to content

[SYCL] Only use AOT images built for the device's architecture - #23493

Merged
uditagarwal97 merged 3 commits into
intel:syclfrom
srividya-sundaram:sycl-runtime-compile-target-match
Oct 15, 2026
Merged

uditagarwal97 merged 3 commits into
intel:syclfrom
srividya-sundaram:sycl-runtime-compile-target-match

Conversation

@srividya-sundaram

Copy link
Copy Markdown
Contributor

Fixes #23489.

With several intel_gpu_* targets, each device image exists once per architecture, tagged with a compile_target. Only the kernel image was checked against the compile_target; device image dependencies, kernel bundle images, the default device selector and device_global images only checked the triple (spir64_gen for all Intel GPUs). This caused "Unable to merge incompatible images", and the default selector could pick a GPU without a usable image.

The compile_target check is now done in compatibleWithDevice and when picking an image from a set. Images without a compile_target are unaffected.

Split out of #23441, whose tests need it.

When an application is compiled for several -fsycl-targets=intel_gpu_*
architectures, each device image is present once per architecture, tagged
with a compile_target. Only the kernel image was checked against the
compile_target; device image dependencies, kernel bundle images, the images
considered by the default device selector and device_global images were only
checked against the target triple, which is spir64_gen for all of them. So an
image built for another architecture could be used, e.g. a PVC kernel image
linked with the TGLLP image of its dependency, failing with "Unable to merge
incompatible images", or a TGLLP device selected for a PVC-only application.

Check the compile_target in compatibleWithDevice, and when picking an image
from a set. Images without a compile_target are unaffected.

Make the mock device in SYCLBINSerialize a PVC GPU, since its executable
bundle is built from an intel_gpu_pvc image.
@srividya-sundaram srividya-sundaram added the new-offload-model Enables testing with NewOffloadModel. label Oct 14, 2026

@iclsrc iclsrc left a comment

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.

The PR makes the runtime ignore AOT images whose compile_target doesn't match the device's architecture. It does this in compatibleWithDevice (which feeds device selection), in the virtual-function dependency collection, and in getDeviceImage. It adds unit tests and fixes up the SYCLBINSerialize tests.

I found no correctness issues. The logic is consistent with the existing doesImageTargetMatchDevice semantics: images without compile_target are treated as matching, which is only a contract-level concern. I have two minor suggestions below.

Comment thread sycl/source/detail/program_manager/program_manager.cpp
Comment thread sycl/source/detail/program_manager/program_manager.cpp

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

5 open findings
What changed in this PR

This PR tightens SYCL AOT device image selection so that images (and their dependencies) are only considered compatible when their compile_target matches the actual device architecture, preventing “Unable to merge incompatible images” and incorrect default-selector choices.

Changes:

  • Add compile_target-aware compatibility checks in ProgramManager (including image-set selection).
  • Add new unit tests covering multi-architecture dependency resolution, kernel bundle selection, image-from-set selection, and default selector behavior.
  • Update existing SYCLBIN serialization tests to force a PVC mock device so the intel_gpu_pvc image path is exercised.
File Description
sycl/​source/​detail/​program_manager/​program_manager.cpp Filters/validates device images against compile_target and applies this during compatibility checks and image selection from sets.
sycl/​unittests/​program_manager/​DynamicLinking/​DynamicLinkingCompileTarget.cpp Adds tests ensuring dependencies and image selection respect compile_target across multiple GPU architectures.
sycl/​unittests/​program_manager/​DynamicLinking/​CMakeLists.txt Registers the new DynamicLinking compile-target unit test source.
sycl/​unittests/​program_manager/​CompileTargetSelection/​CompileTargetSelection.cpp Adds a test verifying the default selector prefers devices with compatible AOT images.
sycl/​unittests/​program_manager/​CompileTargetSelection/​CMakeLists.txt Adds a dedicated test target to isolate registered images for selector behavior.
sycl/​unittests/​program_manager/​CMakeLists.txt Adds the new CompileTargetSelection subdirectory to the unit test build.
sycl/​unittests/​SYCL2020/​SYCLBINSerialize.cpp Forces mock device info to PVC so compile_target image selection is deterministic in serialization round-trip tests.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sycl/source/detail/program_manager/program_manager.cpp Outdated
Comment thread sycl/source/detail/program_manager/program_manager.cpp Outdated
Comment thread sycl/source/detail/program_manager/program_manager.cpp
Also clarify the doesCompileTargetMatchDevice comment and include the
standard headers used by the new unit tests.
@srividya-sundaram
srividya-sundaram marked this pull request as ready for review October 15, 2026 01:52
@srividya-sundaram
srividya-sundaram requested a review from a team as a code owner October 15, 2026 01:52
@uditagarwal97
uditagarwal97 merged commit 2cb9a81 into intel:sycl Oct 15, 2026
36 checks passed
srividya-sundaram added a commit to srividya-sundaram/llvm that referenced this pull request Oct 19, 2026
The bundler, runtime and sanitizer library fixes have landed in sycl
(intel#23491, intel#23493, intel#23494), so their copies are dropped here. The linker
wrapper fix is updated to the version in intel#23492.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-offload-model Enables testing with NewOffloadModel.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SYCL] Runtime uses intel_gpu_* device images built for another architecture

4 participants