@@ -246,25 +246,20 @@ class kernel_bundle_impl
246
246
247
247
// Due to a bug in L0, specializations with conflicting IDs will overwrite
248
248
// 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.
250
250
// 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 ;
253
253
for (const kernel_bundle<bundle_state::object> &ObjectBundle :
254
254
ObjectBundles) {
255
255
for (const DevImgPlainWithDeps &DeviceImageWithDeps :
256
256
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
+ }
268
263
}
269
264
}
270
265
@@ -274,22 +269,16 @@ class kernel_bundle_impl
274
269
std::set<device_image_impl *> DevImagesSet;
275
270
std::unordered_set<const RTDeviceBinaryImage *> SeenBinImgs;
276
271
for (const kernel_bundle<bundle_state::object> &ObjectBundle :
277
- ObjectBundles) {
272
+ ObjectBundles)
278
273
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 ()));
293
282
}
294
283
295
284
// Check for conflicting kernels in RTC kernel bundles.
@@ -392,8 +381,7 @@ class kernel_bundle_impl
392
381
}
393
382
394
383
// ... And link the offline images in separation. (Workaround.)
395
- for (const DevImgPlainWithDeps *DeviceImageWithDeps :
396
- ImagesWithSpecConsts) {
384
+ for (const DevImgPlainWithDeps *DeviceImageWithDeps : OfflineDeviceImages) {
397
385
// Skip images which are not compatible with devices provided
398
386
if (std::none_of (get_devices ().begin (), get_devices ().end (),
399
387
[DeviceImageWithDeps](device_impl &Dev) {
0 commit comments