Skip to content

Commit bee8a39

Browse files
[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 33a0411 commit bee8a39

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

libdevice/sanitizer/asan_rtl.cpp

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

8181
#define ASAN_DEBUG(X) \
8282
do { \
83-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo; \
83+
auto launch_info = \
84+
(__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo; \
8485
if (launch_info->Debug) { \
8586
X; \
8687
} \
@@ -125,7 +126,7 @@ inline void ConvertGenericPointer(uptr &addr, uint32_t &as) {
125126
}
126127

127128
inline uptr MemToShadow_CPU(uptr addr) {
128-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
129+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
129130
return launch_info->GlobalShadowOffset + (addr >> ASAN_SHADOW_SCALE);
130131
}
131132

@@ -134,7 +135,7 @@ inline uptr MemToShadow_DG2(uptr addr, uint32_t as) {
134135
ConvertGenericPointer(addr, as);
135136
}
136137

137-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
138+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
138139
if (as == ADDRESS_SPACE_GLOBAL) { // global
139140
uptr shadow_ptr;
140141
if (addr & 0xFFFF000000000000ULL) { // Device USM
@@ -214,7 +215,7 @@ inline uptr MemToShadow_PVC(uptr addr, uint32_t as) {
214215
ConvertGenericPointer(addr, as);
215216
}
216217

217-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
218+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
218219
if (as == ADDRESS_SPACE_GLOBAL) { // global
219220
uptr shadow_ptr;
220221
if (addr & 0xFF00000000000000) { // Device USM
@@ -301,7 +302,7 @@ inline uptr MemToShadow(uptr addr, uint32_t as) {
301302
#elif defined(__LIBDEVICE_DG2__)
302303
shadow_ptr = MemToShadow_DG2(addr, as);
303304
#else
304-
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
305+
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
305306
if (launch_info->DeviceTy == DeviceType::CPU) {
306307
shadow_ptr = MemToShadow_CPU(addr);
307308
} else if (launch_info->DeviceTy == DeviceType::GPU_PVC) {
@@ -379,12 +380,12 @@ void __asan_internal_report_save(ErrorType error_type) {
379380
__spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
380381
__spirv_BuiltInWorkgroupId.z;
381382

382-
auto &SanitizerReport = ((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)
383+
auto &SanitizerReport = ((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)
383384
->Report[WG_LID % ASAN_MAX_NUM_REPORTS];
384385

385386
if (atomicCompareAndSet(
386-
&(((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)->ReportFlag), 1,
387-
0) == 0 &&
387+
&(((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)->ReportFlag),
388+
1, 0) == 0 &&
388389
atomicCompareAndSet(&SanitizerReport.Flag, Desired, Expected) ==
389390
Expected) {
390391
SanitizerReport.ErrorTy = error_type;
@@ -415,13 +416,13 @@ void __asan_internal_report_save(
415416
__spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
416417
__spirv_BuiltInWorkgroupId.z;
417418

418-
auto &SanitizerReport = ((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)
419+
auto &SanitizerReport = ((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)
419420
->Report[WG_LID % ASAN_MAX_NUM_REPORTS];
420421

421422
if ((is_recover ||
422423
atomicCompareAndSet(
423-
&(((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)->ReportFlag), 1,
424-
0) == 0) &&
424+
&(((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)->ReportFlag),
425+
1, 0) == 0) &&
425426
atomicCompareAndSet(&SanitizerReport.Flag, Desired, Expected) ==
426427
Expected) {
427428

@@ -853,7 +854,7 @@ __asan_set_shadow_dynamic_local(uptr ptr, uint32_t num_args) {
853854

854855
ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_dynamic_local_begin));
855856

856-
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
857+
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
857858
if (num_args != launch_info->NumLocalArgs) {
858859
__spirv_ocl_printf(__mem_report_arg_count_incorrect, num_args,
859860
launch_info->NumLocalArgs);
@@ -887,7 +888,7 @@ __asan_unpoison_shadow_dynamic_local(uptr ptr, uint32_t num_args) {
887888

888889
ASAN_DEBUG(__spirv_ocl_printf(__mem_unpoison_shadow_dynamic_local_begin));
889890

890-
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
891+
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
891892
if (num_args != launch_info->NumLocalArgs) {
892893
__spirv_ocl_printf(__mem_report_arg_count_incorrect, num_args,
893894
launch_info->NumLocalArgs);
@@ -926,7 +927,7 @@ DEVICE_EXTERN_C_NOINLINE void __asan_set_shadow_private(uptr begin, uptr size,
926927

927928
ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_private_begin));
928929

929-
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
930+
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
930931
if (launch_info->PrivateShadowOffset == 0)
931932
return;
932933

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# commit 5f4a5a27e8192ee41ce21c8fb140d770c779af78
2-
# Merge: 4111306dc9d2 039cf144f535
1+
# commit a172cde4bc2857dcf74b0b2907a5b0f90566e808 (HEAD, origin/main, origin/HEAD)
2+
# Merge: 1851eff47b0a cde0d4c820b0
33
# Author: Martin Grant <[email protected]>
4-
# Date: Thu Dec 5 10:49:58 2024 +0000
5-
# Merge pull request #2334 from winstonzhang-intel/interrupt-based
6-
# [L0] Interrupt-based event implementation
7-
set(UNIFIED_RUNTIME_TAG 5f4a5a27e8192ee41ce21c8fb140d770c779af78)
4+
# Date: Thu Dec 5 12:29:44 2024 +0000
5+
# Merge pull request #2249 from zhaomaosu/use-device-usm-for-rtl-data
6+
# [DeviceASAN] Use device usm to sync asan runtime data instead of shared usm
7+
set(UNIFIED_RUNTIME_TAG a172cde4bc2857dcf74b0b2907a5b0f90566e808)

0 commit comments

Comments
 (0)