Skip to content

Commit fbbf961

Browse files
[NFC][SYCL] Clarify intent of device_image_impl::get_kernel_ids_ptr
1 parent 22ee417 commit fbbf961

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

sycl/source/detail/device_image_impl.hpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ class device_image_impl
417417
const std::vector<kernel_id> &get_kernel_ids() const noexcept {
418418
return *MKernelIDs;
419419
}
420+
// This should only be used when creating new device_image_impls that have the
421+
// exact same set of kernels as the source one. In all other scenarios the
422+
// getter above is the one needed:
423+
std::shared_ptr<std::vector<kernel_id>> &get_kernel_ids_ptr() noexcept {
424+
return MKernelIDs;
425+
}
426+
420427

421428
bool has_specialization_constants() const noexcept {
422429
// Lock the mutex to prevent when one thread in the middle of writing a
@@ -563,10 +570,6 @@ class device_image_impl
563570

564571
const context &get_context() const noexcept { return MContext; }
565572

566-
std::shared_ptr<std::vector<kernel_id>> &get_kernel_ids_ptr() noexcept {
567-
return MKernelIDs;
568-
}
569-
570573
std::vector<unsigned char> &get_spec_const_blob_ref() noexcept {
571574
return MSpecConstsBlob;
572575
}
@@ -1300,7 +1303,9 @@ class device_image_impl
13001303
ur_program_handle_t MProgram = nullptr;
13011304

13021305
// List of kernel ids available in this image, elements should be sorted
1303-
// according to LessByNameComp
1306+
// according to LessByNameComp. Shared between images for performance reasons
1307+
// (e.g. when we compile a single image it keeps the same kernels in it as the
1308+
// original source image).
13041309
std::shared_ptr<std::vector<kernel_id>> MKernelIDs;
13051310

13061311
// List of known kernel names.

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,10 +2905,8 @@ mergeImageData(const std::vector<device_image_plain> &Imgs,
29052905
for (const device_image_plain &Img : Imgs) {
29062906
device_image_impl &DeviceImageImpl = *getSyclObjImpl(Img);
29072907
// Duplicates are not expected here, otherwise urProgramLink should fail
2908-
if (DeviceImageImpl.get_kernel_ids_ptr())
2909-
KernelIDs.insert(KernelIDs.end(),
2910-
DeviceImageImpl.get_kernel_ids_ptr()->begin(),
2911-
DeviceImageImpl.get_kernel_ids_ptr()->end());
2908+
KernelIDs.insert(KernelIDs.end(), DeviceImageImpl.get_kernel_ids().begin(),
2909+
DeviceImageImpl.get_kernel_ids().end());
29122910
// To be able to answer queries about specialziation constants, the new
29132911
// device image should have the specialization constants from all the linked
29142912
// images.

sycl/source/kernel_bundle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ bool has_kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,
288288
const std::shared_ptr<device_image_impl> &DeviceImageImpl =
289289
getSyclObjImpl(DeviceImage);
290290

291-
CombinedKernelIDs.insert(DeviceImageImpl->get_kernel_ids_ptr()->begin(),
292-
DeviceImageImpl->get_kernel_ids_ptr()->end());
291+
CombinedKernelIDs.insert(DeviceImageImpl->get_kernel_ids().begin(),
292+
DeviceImageImpl->get_kernel_ids().end());
293293
}
294294
}
295295

0 commit comments

Comments
 (0)