@@ -1032,6 +1032,19 @@ class device_image_impl {
10321032 for (auto &[NewImage, KernelIDs] : NewImages) {
10331033 const RTDeviceBinaryImage &NewImageRef = *NewImage;
10341034
1035+ // Filter the devices that support the image requirements.
1036+ std::vector<sycl::device> SupportingDevs = Devices;
1037+ auto NewSupportingDevsEnd = std::remove_if (
1038+ SupportingDevs.begin (), SupportingDevs.end (),
1039+ [&NewImageRef](const sycl::device &SDev) {
1040+ return !doesDevSupportDeviceRequirements (SDev, NewImageRef);
1041+ });
1042+
1043+ // If there are no devices that support the image, we skip it.
1044+ if (NewSupportingDevsEnd == SupportingDevs.begin ())
1045+ continue ;
1046+ SupportingDevs.erase (NewSupportingDevsEnd, SupportingDevs.end ());
1047+
10351048 std::set<std::string> KernelNames;
10361049 std::unordered_map<std::string, std::string> MangledKernelNames;
10371050 std::unordered_set<std::string> DeviceGlobalIDSet;
@@ -1106,19 +1119,6 @@ class device_image_impl {
11061119 getSyclObjImpl (MContext), std::string{Prefix},
11071120 std::move (DeviceGlobalNames), std::move (DeviceGlobalAllocations));
11081121
1109- // Filter the devices that support the image requirements.
1110- std::vector<sycl::device> SupportingDevs = Devices;
1111- auto NewSupportingDevsEnd = std::remove_if (
1112- SupportingDevs.begin (), SupportingDevs.end (),
1113- [&NewImageRef](const sycl::device &SDev) {
1114- return !doesDevSupportDeviceRequirements (SDev, NewImageRef);
1115- });
1116-
1117- // If there are no devices that support the image, we skip it.
1118- if (NewSupportingDevsEnd == SupportingDevs.begin ())
1119- continue ;
1120- SupportingDevs.erase (NewSupportingDevsEnd, SupportingDevs.end ());
1121-
11221122 // Mark the image as input so the program manager will bring it into
11231123 // the right state.
11241124 auto DevImgImpl = std::make_shared<device_image_impl>(
0 commit comments