Repository navigation
[SYCL] Only use AOT images built for the device's architecture - #23493
uditagarwal97 merged 3 commits into
Conversation
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.
iclsrc
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
The fallbackif (Imgs.empty()) Imgs.assign(ImageSet...)can re-introduce… · New The comment says “Images without [compile_target] are matched by their target”, but the… · NewImgIndis used to indexImgswithout any validation. If the backend returns an out-of-range… · New Similar to the other newly added test, this file usesstd::string,std::vector,std::copy,… · New This test uses several standard library facilities (std::vector,std::string,std::copy,… · New
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 inProgramManager(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_pvcimage 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.
Also clarify the doesCompileTargetMatchDevice comment and include the standard headers used by the new unit tests.
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.


Fixes #23489.
With several
intel_gpu_*targets, each device image exists once per architecture, tagged with acompile_target. Only the kernel image was checked against thecompile_target; device image dependencies, kernel bundle images, the default device selector and device_global images only checked the triple (spir64_genfor all Intel GPUs). This caused "Unable to merge incompatible images", and the default selector could pick a GPU without a usable image.The
compile_targetcheck is now done incompatibleWithDeviceand when picking an image from a set. Images without acompile_targetare unaffected.Split out of #23441, whose tests need it.