@@ -246,25 +246,20 @@ class kernel_bundle_impl
246246
247247 // Due to a bug in L0, specializations with conflicting IDs will overwrite
248248 // each other when linked together, so to avoid this issue we link
249- // images with specialization constants in separation.
249+ // regular offline-compiled SYCL device images in separation.
250250 // TODO: Remove when spec const overwriting issue has been fixed in L0.
251- std::vector<const DevImgPlainWithDeps *> ImagesWithSpecConsts ;
252- std::unordered_set<device_image_impl *> ImagesWithSpecConstsSet ;
251+ std::vector<const DevImgPlainWithDeps *> OfflineDeviceImages ;
252+ std::unordered_set<device_image_impl *> OfflineDeviceImageSet ;
253253 for (const kernel_bundle<bundle_state::object> &ObjectBundle :
254254 ObjectBundles) {
255255 for (const DevImgPlainWithDeps &DeviceImageWithDeps :
256256 getSyclObjImpl (ObjectBundle)->MDeviceImages ) {
257- if (std::none_of (DeviceImageWithDeps.begin (), DeviceImageWithDeps.end (),
258- [](const device_image_plain &DevImg) {
259- const RTDeviceBinaryImage *BinImg =
260- getSyclObjImpl (DevImg)->get_bin_image_ref ();
261- return BinImg && BinImg->getSpecConstants ().size ();
262- }))
263- continue ;
264-
265- ImagesWithSpecConsts.push_back (&DeviceImageWithDeps);
266- for (const device_image_plain &DevImg : DeviceImageWithDeps)
267- ImagesWithSpecConstsSet.insert (&*getSyclObjImpl (DevImg));
257+ if (getSyclObjImpl (DeviceImageWithDeps.getMain ())->getOriginMask () &
258+ ImageOriginSYCLOffline) {
259+ OfflineDeviceImages.push_back (&DeviceImageWithDeps);
260+ for (const device_image_plain &DevImg : DeviceImageWithDeps)
261+ OfflineDeviceImageSet.insert (&*getSyclObjImpl (DevImg));
262+ }
268263 }
269264 }
270265
@@ -274,22 +269,16 @@ class kernel_bundle_impl
274269 std::set<device_image_impl *> DevImagesSet;
275270 std::unordered_set<const RTDeviceBinaryImage *> SeenBinImgs;
276271 for (const kernel_bundle<bundle_state::object> &ObjectBundle :
277- ObjectBundles) {
272+ ObjectBundles)
278273 for (device_image_impl &DevImg :
279- getSyclObjImpl (ObjectBundle)->device_images ()) {
280- const RTDeviceBinaryImage *BinImg = DevImg.get_bin_image_ref ();
281- // We have duplicate images if either the underlying binary image has
282- // been seen before or the device image implementation is in the
283- // image set already.
284- if ((BinImg && SeenBinImgs.count (BinImg)) ||
285- ImagesWithSpecConstsSet.count (&DevImg))
286- continue ;
287- SeenBinImgs.insert (BinImg);
288- DevImagesSet.insert (&DevImg);
289- }
290- }
291- DevImages = device_images_range{DevImagesSet}
292- .to <std::vector<device_image_plain>>();
274+ getSyclObjImpl (ObjectBundle)->device_images ())
275+ if (OfflineDeviceImageSet.find (&DevImg) ==
276+ OfflineDeviceImageSet.end ())
277+ DevImagesSet.insert (&DevImg);
278+ DevImages.reserve (DevImagesSet.size ());
279+ for (auto It = DevImagesSet.begin (); It != DevImagesSet.end ();)
280+ DevImages.push_back (createSyclObjFromImpl<device_image_plain>(
281+ *DevImagesSet.extract (It++).value ()));
293282 }
294283
295284 // Check for conflicting kernels in RTC kernel bundles.
@@ -392,8 +381,7 @@ class kernel_bundle_impl
392381 }
393382
394383 // ... And link the offline images in separation. (Workaround.)
395- for (const DevImgPlainWithDeps *DeviceImageWithDeps :
396- ImagesWithSpecConsts) {
384+ for (const DevImgPlainWithDeps *DeviceImageWithDeps : OfflineDeviceImages) {
397385 // Skip images which are not compatible with devices provided
398386 if (std::none_of (get_devices ().begin (), get_devices ().end (),
399387 [DeviceImageWithDeps](device_impl &Dev) {
0 commit comments