Skip to content

Commit 772fe95

Browse files
committed
lock directly
1 parent b4f31b4 commit 772fe95

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

source/loader/layers/sanitizer/asan/asan_interceptor.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,19 @@ ur_result_t AsanInterceptor::postLaunchKernel(ur_kernel_handle_t Kernel,
310310
std::shared_ptr<ShadowMemory>
311311
AsanInterceptor::getOrCreateShadowMemory(ur_device_handle_t Device,
312312
DeviceType Type) {
313+
std::scoped_lock<ur_shared_mutex> Guard(m_ShadowMapMutex);
313314
if (m_ShadowMap.find(Type) == m_ShadowMap.end()) {
314-
std::scoped_lock<ur_shared_mutex> Guard(m_ShadowMapMutex);
315-
if (m_ShadowMap.find(Type) == m_ShadowMap.end()) {
316-
ur_context_handle_t InternalContext;
317-
auto Res = getContext()->urDdiTable.Context.pfnCreate(1, &Device, nullptr,
318-
&InternalContext);
319-
if (Res != UR_RESULT_SUCCESS) {
320-
getContext()->logger.error("Failed to create shadow context");
321-
return nullptr;
322-
}
323-
std::shared_ptr<ContextInfo> CI;
324-
insertContext(InternalContext, CI);
325-
m_ShadowMap[Type] = GetShadowMemory(InternalContext, Device, Type);
326-
m_ShadowMap[Type]->Setup();
315+
ur_context_handle_t InternalContext;
316+
auto Res = getContext()->urDdiTable.Context.pfnCreate(1, &Device, nullptr,
317+
&InternalContext);
318+
if (Res != UR_RESULT_SUCCESS) {
319+
getContext()->logger.error("Failed to create shadow context");
320+
return nullptr;
327321
}
322+
std::shared_ptr<ContextInfo> CI;
323+
insertContext(InternalContext, CI);
324+
m_ShadowMap[Type] = GetShadowMemory(InternalContext, Device, Type);
325+
m_ShadowMap[Type]->Setup();
328326
}
329327
return m_ShadowMap[Type];
330328
}

0 commit comments

Comments
 (0)