Skip to content

[SYCL] Remove unnecessary kernel ID protector mutex #4537

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

Conversation

steffenlarsen
Copy link
Contributor

The kernel ID cache is only written to during ProgramManager::addImages which is done at the start of program execution. All subsequent accesses to the kernel ID cache are reads. As such, the mutex that protects the kernel ID cache is only guarding reads, which adds an unnecessary overhead.

The kernel ID cache is only written to during `ProgramManager::AddImages` which
is done at the start of the execution. All subsequent accesses to the kernel ID
cache are reads. As such, the mutex that protects the kernel ID cache is only
guarding reads, which adds an unnecessary overhead.

Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
@steffenlarsen steffenlarsen requested a review from a team as a code owner September 10, 2021 09:32
@@ -275,15 +275,8 @@ class ProgramManager {
/// Maps names of kernels to their unique kernel IDs.
/// TODO: Use std::unordered_set with transparent hash and equality functions
/// when C++20 is enabled for the runtime library.
/// Access must be guarded by the m_KernelIDsMutex mutex
std::unordered_map<std::string, kernel_id> m_KernelIDs;
Copy link
Contributor

Choose a reason for hiding this comment

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

A note should be placed here saying that write access is only allowed during start-up process in addImages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I've added a note.

Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
@steffenlarsen
Copy link
Contributor Author

@romanovvlad Pointed out in another comment that addImages may be triggered later in a program's life, so the mutex is still required.

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.

2 participants