Repository navigation
[SYCL] Only use AOT images built for the device's architecture #23493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
uditagarwal97
merged 3 commits into
intel:sycl
from
srividya-sundaram:sycl-runtime-compile-target-match
Oct 15, 2026
+370
−10
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,4 @@ endif() | |
|
|
||
| add_subdirectory(arg_mask) | ||
| add_subdirectory(DynamicLinking) | ||
| add_subdirectory(CompileTargetSelection) | ||
5 changes: 5 additions & 0 deletions
5
sycl/unittests/program_manager/CompileTargetSelection/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Uses its own test binary: the registered images decide which devices have a | ||
| # compatible image, so other tests' images must not be visible. | ||
| add_sycl_unittest(CompileTargetSelectionTests OBJECT | ||
| CompileTargetSelection.cpp | ||
| ) |
103 changes: 103 additions & 0 deletions
103
sycl/unittests/program_manager/CompileTargetSelection/CompileTargetSelection.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| #include <sycl/sycl.hpp> | ||
|
|
||
| #include <helpers/MockDeviceImage.hpp> | ||
| #include <helpers/MockKernelInfo.hpp> | ||
| #include <helpers/UrMock.hpp> | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
srividya-sundaram marked this conversation as resolved.
|
||
|
|
||
| #include <algorithm> | ||
| #include <iterator> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| // Check that an AOT image built for one GPU architecture only makes devices of | ||
| // that architecture preferred by the default device selector. | ||
|
|
||
| class CompileTargetSelectionKernel; | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
| template <> | ||
| struct KernelInfo<CompileTargetSelectionKernel> | ||
| : public unittest::MockKernelInfoBase { | ||
| static constexpr const char *getName() { | ||
| return "CompileTargetSelectionKernel"; | ||
| } | ||
| }; | ||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
|
|
||
| namespace { | ||
| namespace exp = sycl::ext::oneapi::experimental; | ||
|
|
||
| sycl::unittest::MockDeviceImage generatePVCImage() { | ||
| std::string CompileTarget = "intel_gpu_pvc"; | ||
| std::vector<char> Data(8 + CompileTarget.size()); | ||
| std::copy(CompileTarget.begin(), CompileTarget.end(), Data.data() + 8); | ||
| sycl::unittest::MockPropertySet PropSet; | ||
| PropSet.insert(__SYCL_PROPERTY_SET_SYCL_DEVICE_REQUIREMENTS, | ||
| sycl::unittest::MockProperty("compile_target", Data, | ||
| SYCL_PROPERTY_TYPE_BYTE_ARRAY)); | ||
| return sycl::unittest::MockDeviceImage{ | ||
| SYCL_DEVICE_BINARY_TYPE_NATIVE, | ||
| __SYCL_DEVICE_BINARY_TARGET_SPIRV64_GEN, | ||
| "", // Compile options | ||
| "", // Link options | ||
| std::vector<unsigned char>{1}, | ||
| sycl::unittest::makeEmptyKernels({"CompileTargetSelectionKernel"}), | ||
| std::move(PropSet)}; | ||
| } | ||
| sycl::unittest::MockDeviceImage Imgs[] = {generatePVCImage()}; | ||
| sycl::unittest::MockDeviceImageArray<1> ImgArray{Imgs}; | ||
|
|
||
| // IP versions of a TGLLP and a PVC GPU. The TGLLP one comes first so that it | ||
| // would be chosen if both devices were preferred equally. | ||
| uint32_t MockDeviceIPs[] = {0x03000000, 0x030f0000}; | ||
|
|
||
| ur_result_t redefinedDeviceGet(void *pParams) { | ||
| auto Params = *static_cast<ur_device_get_params_t *>(pParams); | ||
| if (*Params.ppNumDevices) { | ||
| **Params.ppNumDevices = std::size(MockDeviceIPs); | ||
| return UR_RESULT_SUCCESS; | ||
| } | ||
| if (*Params.pphDevices) | ||
| for (uint32_t I = 0; I < *Params.pNumEntries; ++I) | ||
| (*Params.pphDevices)[I] = | ||
| reinterpret_cast<ur_device_handle_t>(&MockDeviceIPs[I]); | ||
| return UR_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| ur_result_t redefinedDeviceGetInfo(void *pParams) { | ||
| auto Params = *static_cast<ur_device_get_info_params_t *>(pParams); | ||
| if (*Params.ppropName == UR_DEVICE_INFO_IP_VERSION && *Params.ppPropValue) | ||
| *static_cast<uint32_t *>(*Params.ppPropValue) = | ||
| *reinterpret_cast<uint32_t *>(*Params.phDevice); | ||
| if (*Params.ppropName == UR_DEVICE_INFO_TYPE && *Params.ppPropValue) | ||
| *static_cast<ur_device_type_t *>(*Params.ppPropValue) = UR_DEVICE_TYPE_GPU; | ||
| return UR_RESULT_SUCCESS; | ||
| } | ||
| } // namespace | ||
|
|
||
| TEST(CompileTargetSelection, DefaultSelectorPrefersDeviceWithImage) { | ||
| sycl::unittest::UrMock<sycl::backend::ext_oneapi_level_zero> Mock; | ||
| mock::getCallbacks().set_replace_callback("urDeviceGet", &redefinedDeviceGet); | ||
| mock::getCallbacks().set_after_callback("urDeviceGetInfo", | ||
| &redefinedDeviceGetInfo); | ||
|
|
||
| std::vector<sycl::device> Devs = sycl::platform().get_devices(); | ||
| ASSERT_EQ(Devs.size(), 2u); | ||
| ASSERT_EQ(Devs[0].get_info<exp::info::device::architecture>(), | ||
| exp::architecture::intel_gpu_tgllp); | ||
| ASSERT_EQ(Devs[1].get_info<exp::info::device::architecture>(), | ||
| exp::architecture::intel_gpu_pvc); | ||
| EXPECT_LT(sycl::default_selector_v(Devs[0]), | ||
| sycl::default_selector_v(Devs[1])); | ||
|
|
||
| sycl::device Dev{sycl::default_selector_v}; | ||
| EXPECT_EQ(Dev.get_info<exp::info::device::architecture>(), | ||
| exp::architecture::intel_gpu_pvc); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.