From 668f5c2860e26c0e30dc6cf616150c7c115995d4 Mon Sep 17 00:00:00 2001 From: chunhuanMeng <105194461+chunhuanMeng@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:20:59 +0800 Subject: [PATCH] SYCL: Fixing breaking issue of sort related kernel level API due to Intel SYCL compiler uplift (#1017) --- cmake/BuildFlags.cmake | 3 +- cmake/Modules/FindSYCLToolkit.cmake | 57 +++++++++++++++---- src/ATen/native/xpu/sycl/TensorModeKernel.cpp | 9 +++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/cmake/BuildFlags.cmake b/cmake/BuildFlags.cmake index 0fe19e360..a8784097a 100644 --- a/cmake/BuildFlags.cmake +++ b/cmake/BuildFlags.cmake @@ -50,7 +50,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" if(USE_PER_OPERATOR_HEADERS) list(APPEND SYCL_HOST_FLAGS -DAT_PER_OPERATOR_HEADERS) endif() - + list(APPEND SYCL_HOST_FLAGS -D__INTEL_LLVM_COMPILER_VERSION=${__INTEL_LLVM_COMPILER}) # -- Kernel flags (SYCL_KERNEL_OPTIONS) # The fast-math will be enabled by default in SYCL compiler. # Refer to [https://clang.llvm.org/docs/UsersManual.html#cmdoption-fno-fast-math] @@ -89,6 +89,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -D__INTEL_PREVIEW_BREAKING_CHANGES) set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -D_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}) endif() + set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -D__INTEL_LLVM_COMPILER_VERSION=${__INTEL_LLVM_COMPILER}) CHECK_SYCL_FLAG("-fsycl-fp64-conv-emu" SUPPORTS_FP64_CONV_EMU) if(SUPPORTS_FP64_CONV_EMU) diff --git a/cmake/Modules/FindSYCLToolkit.cmake b/cmake/Modules/FindSYCLToolkit.cmake index 46e34c7f8..88edd34a7 100644 --- a/cmake/Modules/FindSYCLToolkit.cmake +++ b/cmake/Modules/FindSYCLToolkit.cmake @@ -35,6 +35,7 @@ endif() if(SYCLTOOLKIT_FOUND) return() endif() + set(SYCLTOOLKIT_FOUND TRUE) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) @@ -77,7 +78,7 @@ endif() # Function to write a test case to verify SYCL features. -function(SYCL_CMPLR_TEST_WRITE src) +function(SYCL_CMPLR_TEST_WRITE src macro_name) set(cpp_macro_if "#if") set(cpp_macro_endif "#endif") @@ -88,8 +89,8 @@ function(SYCL_CMPLR_TEST_WRITE src) # Feature tests goes here - string(APPEND SYCL_CMPLR_TEST_CONTENT "${cpp_macro_if} defined(SYCL_LANGUAGE_VERSION)\n") - string(APPEND SYCL_CMPLR_TEST_CONTENT "cout << \"SYCL_LANGUAGE_VERSION=\"<= 20250000 + auto sort_scratch_memory_size = + sycl::ext::oneapi::experimental::default_sorters::group_sorter< + ModeOpValueIndex, + std::greater, + 1>::memory_required(sycl::memory_scope::work_group, group_size); +#else auto sort_scratch_memory_size = sycl::ext::oneapi::experimental:: default_sorter>::template memory_required< ModeOpValueIndex>( sycl::memory_scope::work_group, sycl::range<1>{static_cast(group_size)}); +#endif auto values_info = getTensorInfo(values_transposed); auto indices_info = getTensorInfo(indices_transposed);