From de855d3aa209e25f8aec6da2c9a8a509afd76064 Mon Sep 17 00:00:00 2001 From: Maosu Zhao Date: Tue, 29 Oct 2024 20:38:11 +0800 Subject: [PATCH 1/2] [UR][DeviceASAN] Sync the latest changes in asan_libdevice.hpp --- libdevice/sanitizer_utils.cpp | 29 ++++++++++---------- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 2 +- sycl/cmake/modules/UnifiedRuntimeTag.cmake | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/libdevice/sanitizer_utils.cpp b/libdevice/sanitizer_utils.cpp index e5d5ac5afdc30..7d93a3971d922 100644 --- a/libdevice/sanitizer_utils.cpp +++ b/libdevice/sanitizer_utils.cpp @@ -87,7 +87,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; \ } \ @@ -132,7 +133,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); } @@ -141,7 +142,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 @@ -221,7 +222,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 @@ -301,7 +302,7 @@ inline uptr MemToShadow_PVC(uptr addr, uint32_t as) { inline uptr MemToShadow(uptr addr, uint32_t as) { uptr shadow_ptr = 0; - 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) { @@ -378,12 +379,12 @@ void __asan_internal_report_save(DeviceSanitizerErrorType error_type) { __spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z + __spirv_BuiltInWorkgroupId.z; - auto &SanitizerReport = ((__SYCL_GLOBAL__ LaunchInfo *)__AsanLaunchInfo) + auto &SanitizerReport = ((__SYCL_GLOBAL__ AsanRuntimeData *)__AsanLaunchInfo) ->SanitizerReport[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.ErrorType = error_type; @@ -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) ->SanitizerReport[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) { @@ -818,7 +819,7 @@ DEVICE_EXTERN_C_NOINLINE void __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); @@ -849,7 +850,7 @@ DEVICE_EXTERN_C_NOINLINE void __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); @@ -885,7 +886,7 @@ DEVICE_EXTERN_C_NOINLINE void __asan_set_shadow_private(uptr begin, uptr size, char val) { 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; diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index 72841724fa01d..d6a0251d63c86 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -116,7 +116,7 @@ if(SYCL_UR_USE_FETCH_CONTENT) CACHE PATH "Path to external '${name}' adapter source dir" FORCE) endfunction() - set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") + set(UNIFIED_RUNTIME_REPO "https://github.com/zhaomaosu/unified-runtime.git") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake) set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") diff --git a/sycl/cmake/modules/UnifiedRuntimeTag.cmake b/sycl/cmake/modules/UnifiedRuntimeTag.cmake index 060f402ee7c35..a9170ddd248c6 100644 --- a/sycl/cmake/modules/UnifiedRuntimeTag.cmake +++ b/sycl/cmake/modules/UnifiedRuntimeTag.cmake @@ -4,4 +4,4 @@ # Date: Mon Oct 28 16:29:45 2024 +0100 # Merge pull request #2242 from nrspruit/sysman_env_disable # [L0] Enable Sysman Thru Env by default and have zesInit be optional -set(UNIFIED_RUNTIME_TAG dbd168cbed2d2590b47904728cd5762f1c2f4c6b) +set(UNIFIED_RUNTIME_TAG use-device-usm-for-rtl-data) From df5fe9f4f61ede5adaeefbdcc4d6e0225ed0ab17 Mon Sep 17 00:00:00 2001 From: Martin Morrison-Grant Date: Thu, 5 Dec 2024 12:37:57 +0000 Subject: [PATCH 2/2] [UR] Update tag for https://github.com/oneapi-src/unified-runtime/pull/2249 and https://github.com/oneapi-src/unified-runtime/pull/1811. --- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 2 +- sycl/cmake/modules/UnifiedRuntimeTag.cmake | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index d6a0251d63c86..72841724fa01d 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -116,7 +116,7 @@ if(SYCL_UR_USE_FETCH_CONTENT) CACHE PATH "Path to external '${name}' adapter source dir" FORCE) endfunction() - set(UNIFIED_RUNTIME_REPO "https://github.com/zhaomaosu/unified-runtime.git") + set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake) set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") diff --git a/sycl/cmake/modules/UnifiedRuntimeTag.cmake b/sycl/cmake/modules/UnifiedRuntimeTag.cmake index a9170ddd248c6..a1550de09acac 100644 --- a/sycl/cmake/modules/UnifiedRuntimeTag.cmake +++ b/sycl/cmake/modules/UnifiedRuntimeTag.cmake @@ -1,7 +1,7 @@ -# commit dbd168cbed2d2590b47904728cd5762f1c2f4c6b (HEAD, origin/main, origin/HEAD) -# Merge: 694c1b9a 27ad3f7d -# Author: Piotr Balcer -# Date: Mon Oct 28 16:29:45 2024 +0100 -# Merge pull request #2242 from nrspruit/sysman_env_disable -# [L0] Enable Sysman Thru Env by default and have zesInit be optional -set(UNIFIED_RUNTIME_TAG use-device-usm-for-rtl-data) +# commit a172cde4bc2857dcf74b0b2907a5b0f90566e808 (HEAD, origin/main, origin/HEAD) +# Merge: 1851eff47b0a cde0d4c820b0 +# Author: Martin Grant +# 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)