Skip to content

[SYCL] Delete symbol based info with the last image referencing it #19659

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

Open
wants to merge 15 commits into
base: sycl
Choose a base branch
from

Conversation

sergey-semenov
Copy link
Contributor

@sergey-semenov sergey-semenov commented Jul 31, 2025

Prior to this patch, symbol based info (e.g. kernel id, kernel assert usage or images containing an exported symbol) was deleted whenever an image referencing it was removed. This is incorrect since multiple images can contain the same symbol.

While unlikely to cause any problems now (since those images usually all get removed with one call to removeImages after another), this will cause issues once kernel name based kernel caches start getting cleaned up in the same manner.

Prior to this patch, kernel name based info (e.g. kernel id or assert usage)
was deleted whenever an image referencing it was removed. This is technically
incorrect since multiple images can contain the same kernel name.
@sergey-semenov sergey-semenov changed the title [SYCL] Delete kernel name based info with the last image referencing it [SYCL] Delete entry name based info with the last image referencing it Aug 4, 2025
@sergey-semenov sergey-semenov changed the title [SYCL] Delete entry name based info with the last image referencing it [SYCL] Delete symbol based info with the last image referencing it Aug 8, 2025
@sergey-semenov sergey-semenov marked this pull request as ready for review August 8, 2025 16:25
@sergey-semenov sergey-semenov requested a review from a team as a code owner August 8, 2025 16:25
Copy link
Contributor

@KseniyaTikhomirova KseniyaTikhomirova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -2140,44 +2155,67 @@ void ProgramManager::removeImages(sycl_device_binaries DeviceBinary) {
// Unmap the unique kernel IDs for the offload entries
for (sycl_offload_entry EntriesIt = EntriesB; EntriesIt != EntriesE;
EntriesIt = EntriesIt->Increment()) {

const char *Name = EntriesIt->GetName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be std::string_view instead?

Copy link
Contributor Author

@sergey-semenov sergey-semenov Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to detail::KernelNameStrT, which maps to std::string_view in preview builds and std::string otherwise, since there are a lot of containers involved that use this key type and don't have heterogenous lookup support.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have hard objections any more.

m_KernelIDs2BinImage.erase(It->second);
m_KernelName2KernelIDs.erase(It);
auto Name2IDIt = m_KernelName2KernelIDs.find(Name);
if (Name2IDIt != m_KernelName2KernelIDs.end())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When isn't that true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing comes to mind, pretty sure this should be an assert. I'll make a follow up change for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants