Skip to content

Commit f8b9da0

Browse files
add missing mutex lock
Signed-off-by: Tikhomirova, Kseniya <[email protected]>
1 parent 6d4ff8e commit f8b9da0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

sycl/source/detail/kernel_program_cache.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ class KernelProgramCache {
442442
return;
443443

444444
// Save reference between the program and the fast cache key.
445+
std::unique_lock<std::mutex> Lock(MKernelFastCacheMutex);
445446
MProgramToKernelFastCacheKeyMap[Program].emplace_back(CacheKey);
446447
}
447448

@@ -495,16 +496,18 @@ class KernelProgramCache {
495496
LockedCacheKP.get().erase(NativePrg);
496497
}
497498

498-
// Remove corresponding entries from KernelFastCache.
499-
auto FastCacheKeyItr =
500-
MProgramToKernelFastCacheKeyMap.find(NativePrg);
501-
if (FastCacheKeyItr != MProgramToKernelFastCacheKeyMap.end()) {
502-
for (const auto &FastCacheKey : FastCacheKeyItr->second) {
503-
std::unique_lock<std::mutex> Lock(MKernelFastCacheMutex);
504-
MKernelFastCache.erase(FastCacheKey);
505-
traceKernel("Kernel evicted.", std::get<2>(FastCacheKey), true);
499+
{
500+
// Remove corresponding entries from KernelFastCache.
501+
std::unique_lock<std::mutex> Lock(MKernelFastCacheMutex);
502+
if (auto FastCacheKeyItr =
503+
MProgramToKernelFastCacheKeyMap.find(NativePrg);
504+
FastCacheKeyItr != MProgramToKernelFastCacheKeyMap.end()) {
505+
for (const auto &FastCacheKey : FastCacheKeyItr->second) {
506+
MKernelFastCache.erase(FastCacheKey);
507+
traceKernel("Kernel evicted.", std::get<2>(FastCacheKey), true);
508+
}
509+
MProgramToKernelFastCacheKeyMap.erase(FastCacheKeyItr);
506510
}
507-
MProgramToKernelFastCacheKeyMap.erase(FastCacheKeyItr);
508511
}
509512

510513
// Remove entry from ProgramCache KeyMap.

0 commit comments

Comments
 (0)