Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,7 @@ ProgramManager::kernelImplicitLocalArgPos(KernelNameStrRefT KernelName) const {

DeviceKernelInfo &ProgramManager::getOrCreateDeviceKernelInfo(
const CompileTimeKernelInfoTy &Info) {
std::lock_guard<std::mutex> Guard(m_DeviceKernelInfoMapMutex);
auto Result =
m_DeviceKernelInfoMap.try_emplace(KernelNameStrT{Info.Name.data()}, Info);
Result.first->second.setCompileTimeInfoIfNeeded(Info);
Expand All @@ -1830,6 +1831,7 @@ DeviceKernelInfo &ProgramManager::getOrCreateDeviceKernelInfo(

DeviceKernelInfo &
ProgramManager::getOrCreateDeviceKernelInfo(KernelNameStrRefT KernelName) {
std::lock_guard<std::mutex> Guard(m_DeviceKernelInfoMapMutex);
auto Result = m_DeviceKernelInfoMap.try_emplace(
KernelName, CompileTimeKernelInfoTy{std::string_view(KernelName)});
return Result.first->second;
Expand Down Expand Up @@ -2137,6 +2139,9 @@ void ProgramManager::removeImages(sycl_device_binaries DeviceBinary) {
// Acquire lock to read and modify maps for kernel bundles
std::lock_guard<std::mutex> KernelIDsGuard(m_KernelIDsMutex);

// Acquire lock to erase DeviceKernelInfoMap
std::lock_guard<std::mutex> Guard(m_DeviceKernelInfoMapMutex);

for (int I = 0; I < DeviceBinary->NumDeviceBinaries; I++) {
sycl_device_binary RawImg = &(DeviceBinary->DeviceBinaries[I]);

Expand Down
3 changes: 3 additions & 0 deletions sycl/source/detail/program_manager/program_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ class ProgramManager {
// by caching the pointers when possible.
std::unordered_map<KernelNameStrT, DeviceKernelInfo> m_DeviceKernelInfoMap;

// Protects m_DeviceKernelInfoMap.
std::mutex m_DeviceKernelInfoMapMutex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the guard here:

m_DeviceKernelInfoMap.erase(Name);
as well?

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 catch. Fixed.


// Sanitizer type used in device image
SanitizerType m_SanitizerFoundInImage;

Expand Down