Skip to content

Commit 3b0530b

Browse files
committed
fix local memory tests
1 parent 041fcbe commit 3b0530b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

source/loader/layers/sanitizer/asan_interceptor.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,8 @@ ur_result_t SanitizerInterceptor::prepareLaunch(
743743
// Write shadow memory offset for local memory
744744
if (cl_DetectLocals) {
745745
// CPU needn't this
746-
if (DeviceInfo->Type == DeviceType::GPU_PVC) {
746+
if (DeviceInfo->Type == DeviceType::GPU_PVC ||
747+
DeviceInfo->Type == DeviceType::GPU_DG2) {
747748
size_t LocalMemorySize = GetLocalMemorySize(DeviceInfo->Handle);
748749
size_t LocalShadowMemorySize =
749750
(NumWG * LocalMemorySize) >> ASAN_SHADOW_SCALE;
@@ -762,6 +763,14 @@ ur_result_t SanitizerInterceptor::prepareLaunch(
762763
context.logger.info("ShadowMemory(Local, {} - {})",
763764
(void *)LaunchInfo.LocalShadowOffset,
764765
(void *)LaunchInfo.LocalShadowOffsetEnd);
766+
767+
// Write shadow memory offset for local memory
768+
EnqueueWriteGlobal(kSPIR_AsanShadowMemoryLocalStart,
769+
&LaunchInfo.LocalShadowOffset,
770+
sizeof(LaunchInfo.LocalShadowOffset));
771+
EnqueueWriteGlobal(kSPIR_AsanShadowMemoryLocalEnd,
772+
&LaunchInfo.LocalShadowOffsetEnd,
773+
sizeof(LaunchInfo.LocalShadowOffsetEnd));
765774
}
766775
}
767776
} while (false);

source/loader/layers/sanitizer/asan_libdevice.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ constexpr auto kSPIR_AsanShadowMemoryGlobalStart =
9090
"__AsanShadowMemoryGlobalStart";
9191
constexpr auto kSPIR_AsanShadowMemoryGlobalEnd = "__AsanShadowMemoryGlobalEnd";
9292

93+
constexpr auto kSPIR_AsanShadowMemoryLocalStart =
94+
"__AsanShadowMemoryLocalStart";
95+
constexpr auto kSPIR_AsanShadowMemoryLocalEnd = "__AsanShadowMemoryLocalEnd";
96+
9397
constexpr auto kSPIR_DeviceType = "__DeviceType";
9498
constexpr auto kSPIR_AsanDebug = "__AsanDebug";
9599

0 commit comments

Comments
 (0)