Skip to content

Commit aa5b3dc

Browse files
authored
Refine oneMKL Build (#1725)
This pull request refactors the handling of oneMKL-related code in the XPU backend by improving conditional compilation and build configuration. The primary changes involve: - Filter oneMKL kernel files in CMAKE instead of wrapping the entire file with macros - Refine link group
1 parent 5b4d744 commit aa5b3dc

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

cmake/ONEMKL.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ set(TORCH_XPU_OPS_ONEMKL_INCLUDE_DIR ${ONEMKL_INCLUDE_DIR})
1919

2020
set(TORCH_XPU_OPS_ONEMKL_LIBRARIES ${ONEMKL_LIBRARIES})
2121

22-
list(INSERT TORCH_XPU_OPS_ONEMKL_LIBRARIES 1 "-Wl,--start-group")
22+
list(PREPEND TORCH_XPU_OPS_ONEMKL_LIBRARIES "-Wl,--start-group")
2323
list(APPEND TORCH_XPU_OPS_ONEMKL_LIBRARIES "-Wl,--end-group")

src/ATen/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ file(GLOB xpu_native_cpp "native/xpu/*.cpp" "native/sparse/*.cpp" "native/sparse
77
file(GLOB xpu_sycl "native/xpu/sycl/*.cpp" "native/sparse/xpu/sycl/*.cpp" "native/nested/xpu/sycl/*.cpp" "native/transformers/sycl/*.cpp" "native/quantized/sycl/*.cpp")
88

99
list(APPEND ATen_XPU_CPP_SRCS ${xpu_cpp})
10-
list(APPEND ATen_XPU_MKL_SRCS ${xpu_mkl})
10+
if(USE_ONEMKL_XPU)
11+
list(APPEND ATen_XPU_MKL_SRCS ${xpu_mkl})
12+
endif()
1113
list(APPEND ATen_XPU_NATIVE_CPP_SRCS ${xpu_native_cpp})
1214
list(APPEND ATen_XPU_SYCL_SRCS ${xpu_sycl})
1315

src/ATen/native/xpu/mkl/BatchLinearAlgebra.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if defined(USE_ONEMKL_XPU)
21
#include <ATen/ATen.h>
32
#include <ATen/Dispatch.h>
43
#include <ATen/ExpandUtils.h>
@@ -538,4 +537,3 @@ void lu_factor_mkl(
538537
}
539538

540539
} // namespace at::native::xpu
541-
#endif // USE_ONEMKL_XPU

src/ATen/native/xpu/mkl/SpectralOps.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if defined(USE_ONEMKL_XPU)
21
#include <ATen/native/Resize.h>
32
#include <ATen/native/SpectralOpsUtils.h>
43
#include <ATen/native/xpu/mkl/SpectralOps.h>
@@ -591,4 +590,3 @@ Tensor& _fft_r2c_mkl_out(
591590
}
592591

593592
} // namespace at::native::xpu
594-
#endif // USE_ONEMKL_XPU

0 commit comments

Comments
 (0)