Skip to content

[UR][DeviceASAN] Sync the latest changes in asan_libdevice.hpp #15911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions libdevice/sanitizer/asan_rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static __SYCL_CONSTANT__ const char __generic_to[] =

#define ASAN_DEBUG(X) \
do { \
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo; \
auto launch_info = \
(__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo; \
if (launch_info->Debug) { \
X; \
} \
Expand Down Expand Up @@ -125,7 +126,7 @@ inline void ConvertGenericPointer(uptr &addr, uint32_t &as) {
}

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

Expand All @@ -134,7 +135,7 @@ inline uptr MemToShadow_DG2(uptr addr, uint32_t as) {
ConvertGenericPointer(addr, as);
}

auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
if (as == ADDRESS_SPACE_GLOBAL) { // global
uptr shadow_ptr;
if (addr & 0xFFFF000000000000ULL) { // Device USM
Expand Down Expand Up @@ -214,7 +215,7 @@ inline uptr MemToShadow_PVC(uptr addr, uint32_t as) {
ConvertGenericPointer(addr, as);
}

auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
if (as == ADDRESS_SPACE_GLOBAL) { // global
uptr shadow_ptr;
if (addr & 0xFF00000000000000) { // Device USM
Expand Down Expand Up @@ -301,7 +302,7 @@ inline uptr MemToShadow(uptr addr, uint32_t as) {
#elif defined(__LIBDEVICE_DG2__)
shadow_ptr = MemToShadow_DG2(addr, as);
#else
auto launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
auto launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
if (launch_info->DeviceTy == DeviceType::CPU) {
shadow_ptr = MemToShadow_CPU(addr);
} else if (launch_info->DeviceTy == DeviceType::GPU_PVC) {
Expand Down Expand Up @@ -379,12 +380,12 @@ void __asan_internal_report_save(ErrorType error_type) {
__spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
__spirv_BuiltInWorkgroupId.z;

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

if (atomicCompareAndSet(
&(((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)->ReportFlag), 1,
0) == 0 &&
&(((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)->ReportFlag),
1, 0) == 0 &&
atomicCompareAndSet(&SanitizerReport.Flag, Desired, Expected) ==
Expected) {
SanitizerReport.ErrorTy = error_type;
Expand Down Expand Up @@ -415,13 +416,13 @@ void __asan_internal_report_save(
__spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
__spirv_BuiltInWorkgroupId.z;

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

if ((is_recover ||
atomicCompareAndSet(
&(((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo)->ReportFlag), 1,
0) == 0) &&
&(((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo)->ReportFlag),
1, 0) == 0) &&
atomicCompareAndSet(&SanitizerReport.Flag, Desired, Expected) ==
Expected) {

Expand Down Expand Up @@ -853,7 +854,7 @@ __asan_set_shadow_dynamic_local(uptr ptr, uint32_t num_args) {

ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_dynamic_local_begin));

auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
if (num_args != launch_info->NumLocalArgs) {
__spirv_ocl_printf(__mem_report_arg_count_incorrect, num_args,
launch_info->NumLocalArgs);
Expand Down Expand Up @@ -887,7 +888,7 @@ __asan_unpoison_shadow_dynamic_local(uptr ptr, uint32_t num_args) {

ASAN_DEBUG(__spirv_ocl_printf(__mem_unpoison_shadow_dynamic_local_begin));

auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
if (num_args != launch_info->NumLocalArgs) {
__spirv_ocl_printf(__mem_report_arg_count_incorrect, num_args,
launch_info->NumLocalArgs);
Expand Down Expand Up @@ -926,7 +927,7 @@ DEVICE_EXTERN_C_NOINLINE void __asan_set_shadow_private(uptr begin, uptr size,

ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_private_begin));

auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
auto *launch_info = (__SYCL_GLOBAL__ const AsanRuntimeData *)__AsanLaunchInfo;
if (launch_info->PrivateShadowOffset == 0)
return;

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