Skip to content

Commit d0b3bf1

Browse files
zhaomaosumartygrant
authored andcommitted
[UR][DeviceASAN] Sync the latest changes in asan_libdevice.hpp (#15911)
UR Part: oneapi-src/unified-runtime#2249 --------- Co-authored-by: Martin Morrison-Grant <[email protected]>
1 parent 5d09fb4 commit d0b3bf1

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

libdevice/sanitizer/asan_rtl.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static __SYCL_CONSTANT__ const char __generic_to[] =
4949

5050
#define ASAN_DEBUG(X) \
5151
do { \
52-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo; \
52+
auto launch_info = \
53+
(__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo; \
5354
if (launch_info->Debug) { \
5455
X; \
5556
} \
@@ -86,7 +87,7 @@ inline void ConvertGenericPointer(uptr &addr, uint32_t &as) {
8687
}
8788

8889
inline uptr MemToShadow_CPU(uptr addr) {
89-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
90+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
9091
return launch_info->GlobalShadowOffset + (addr >> ASAN_SHADOW_SCALE);
9192
}
9293

@@ -95,7 +96,7 @@ inline uptr MemToShadow_DG2(uptr addr, uint32_t as) {
9596
ConvertGenericPointer(addr, as);
9697
}
9798

98-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
99+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
99100
if (as == ADDRESS_SPACE_GLOBAL) { // global
100101
uptr shadow_ptr;
101102
if (addr & 0xFFFF000000000000ULL) { // Device USM
@@ -175,7 +176,7 @@ inline uptr MemToShadow_PVC(uptr addr, uint32_t as) {
175176
ConvertGenericPointer(addr, as);
176177
}
177178

178-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
179+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
179180
if (as == ADDRESS_SPACE_GLOBAL) { // global
180181
uptr shadow_ptr;
181182
if (addr & 0xFF00000000000000) { // Device USM
@@ -262,7 +263,7 @@ inline uptr MemToShadow(uptr addr, uint32_t as) {
262263
#elif defined(__LIBDEVICE_DG2__)
263264
shadow_ptr = MemToShadow_DG2(addr, as);
264265
#else
265-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
266+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
266267
if (launch_info->DeviceTy == DeviceType::CPU) {
267268
shadow_ptr = MemToShadow_CPU(addr);
268269
} else if (launch_info->DeviceTy == DeviceType::GPU_PVC) {
@@ -340,12 +341,12 @@ void __asan_internal_report_save(ErrorType error_type) {
340341
__spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
341342
__spirv_BuiltInWorkgroupId.z;
342343

343-
auto &SanitizerReport = ((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)
344+
auto &SanitizerReport = ((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)
344345
->Report[WG_LID % ASAN_MAX_NUM_REPORTS];
345346

346347
if (atomicCompareAndSet(
347-
&(((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)->ReportFlag), 1,
348-
0) == 0 &&
348+
&(((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)->ReportFlag),
349+
1, 0) == 0 &&
349350
atomicCompareAndSet(&SanitizerReport.Flag, Desired, Expected) ==
350351
Expected) {
351352
SanitizerReport.ErrorTy = error_type;
@@ -376,13 +377,13 @@ void __asan_internal_report_save(
376377
__spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
377378
__spirv_BuiltInWorkgroupId.z;
378379

379-
auto &SanitizerReport = ((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)
380+
auto &SanitizerReport = ((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)
380381
->Report[WG_LID % ASAN_MAX_NUM_REPORTS];
381382

382383
if ((is_recover ||
383384
atomicCompareAndSet(
384-
&(((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)->ReportFlag), 1,
385-
0) == 0) &&
385+
&(((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)->ReportFlag),
386+
1, 0) == 0) &&
386387
atomicCompareAndSet(&SanitizerReport.Flag, Desired, Expected) ==
387388
Expected) {
388389

@@ -814,7 +815,7 @@ __asan_set_shadow_dynamic_local(uptr ptr, uint32_t num_args) {
814815

815816
ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_dynamic_local_begin));
816817

817-
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
818+
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
818819
if (num_args != launch_info->NumLocalArgs) {
819820
__spirv_ocl_printf(__mem_report_arg_count_incorrect, num_args,
820821
launch_info->NumLocalArgs);
@@ -848,7 +849,7 @@ __asan_unpoison_shadow_dynamic_local(uptr ptr, uint32_t num_args) {
848849

849850
ASAN_DEBUG(__spirv_ocl_printf(__mem_unpoison_shadow_dynamic_local_begin));
850851

851-
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
852+
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
852853
if (num_args != launch_info->NumLocalArgs) {
853854
__spirv_ocl_printf(__mem_report_arg_count_incorrect, num_args,
854855
launch_info->NumLocalArgs);
@@ -887,7 +888,7 @@ DEVICE_EXTERN_C_NOINLINE void __asan_set_shadow_private(uptr begin, uptr size,
887888

888889
ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_private_begin));
889890

890-
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
891+
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
891892
if (launch_info->PrivateShadowOffset == 0)
892893
return;
893894

0 commit comments

Comments
 (0)