Skip to content

Commit 8d373ba

Browse files
authored
Few CMake improvements (#2204)
- align torch-xpu-ops version to match target PyTorch version - simplify install_xpu_headers macro and add `CONFIGURE_DEPENDS` to track these headers
1 parent ebd04c2 commit 8d373ba

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
# torch_xpu_ops
1919
# -- Static archive library target
2020

21-
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
21+
cmake_minimum_required(VERSION 3.27 FATAL_ERROR)
2222

23-
set(PROJECT_NAME "torch-xpu-ops")
24-
set(PROJECT_VERSION "2.3.0")
2523
# Avoid SYCL compiler error
2624
if(NOT WIN32)
2725
string(APPEND CMAKE_CXX_FLAGS " -Wno-error")
@@ -30,8 +28,7 @@ if(NOT WIN32)
3028
endif()
3129
endif()
3230

33-
cmake_policy(SET CMP0048 NEW)
34-
project(${PROJECT_NAME} VERSION "${PROJECT_VERSION}" LANGUAGES C CXX)
31+
project(torch-xpu-ops VERSION 2.10.0 LANGUAGES C CXX)
3532

3633
set(TORCH_XPU_OPS_FOUND FALSE)
3734

cmake/Modules/FindONEMKL.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,18 @@ find_file(
4444

4545
if((ONEMKL_INCLUDE_DIR STREQUAL "ONEMKL_INCLUDE_DIR-NOTFOUND")
4646
OR(ONEMKL_LIB_DIR STREQUAL "ONEMKL_LIB_DIR-NOTFOUND"))
47-
message(WARNING "oneMKL sdk is incomplete!!")
47+
message(WARNING "oneMKL SDK is incomplete!!")
4848
return()
4949
endif()
5050

51+
set(MKL_LIB_NAMES "mkl_sycl_blas" "mkl_sycl_dft" "mkl_sycl_lapack"
52+
"mkl_intel_lp64" "mkl_core")
53+
5154
if(WIN32)
52-
set(MKL_LIB_NAMES "mkl_sycl_blas" "mkl_sycl_dft" "mkl_sycl_lapack"
53-
"mkl_intel_lp64" "mkl_intel_thread" "mkl_core")
55+
list(APPEND MKL_LIB_NAMES "mkl_intel_thread")
5456
list(TRANSFORM MKL_LIB_NAMES APPEND "_dll.lib")
5557
else()
56-
set(MKL_LIB_NAMES "mkl_sycl_blas" "mkl_sycl_dft" "mkl_sycl_lapack"
57-
"mkl_intel_lp64" "mkl_gnu_thread" "mkl_core")
58+
list(APPEND MKL_LIB_NAMES "mkl_gnu_thread")
5859
list(TRANSFORM MKL_LIB_NAMES PREPEND "lib")
5960
list(TRANSFORM MKL_LIB_NAMES APPEND ".so")
6061
endif()

cmake/Modules/FindSYCL.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ macro(SYCL_INCLUDE_DEPENDENCIES dependency_file)
107107

108108
if(SYCL_DEPEND_REGENERATE)
109109
set(SYCL_DEPEND ${dependency_file})
110-
file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n")
110+
file(WRITE ${dependency_file} "#FindSYCL.cmake generated file. Do not edit.\n")
111111
endif()
112112
endmacro()
113113

src/ATen/CMakeLists.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# ATen XPU sources
22

33
file(GLOB xpu_cpp "xpu/*.cpp")
4-
file(GLOB xpu_mkl "native/xpu/mkl/*.cpp")
54
file(GLOB xpu_native_cpp "native/xpu/*.cpp" "native/sparse/*.cpp" "native/sparse/xpu/*.cpp" "native/nested/*.cpp" "native/nested/xpu/*.cpp" "native/transformers/*.cpp" "native/quantized/*.cpp")
65
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")
76

87
list(APPEND ATen_XPU_CPP_SRCS ${xpu_cpp})
98
if(USE_ONEMKL_XPU)
9+
file(GLOB xpu_mkl "native/xpu/mkl/*.cpp")
1010
list(APPEND ATen_XPU_MKL_SRCS ${xpu_mkl})
1111
endif()
1212
list(APPEND ATen_XPU_NATIVE_CPP_SRCS ${xpu_native_cpp})
@@ -19,25 +19,25 @@ set(ATen_XPU_SYCL_SRCS ${ATen_XPU_SYCL_SRCS} PARENT_SCOPE)
1919

2020
# ATen XPU headers
2121

22-
macro(install_xpu_headers glob_pattern dest_subdir)
23-
file(GLOB headers ${glob_pattern})
22+
macro(install_xpu_headers subdir)
23+
file(GLOB headers CONFIGURE_DEPENDS "${subdir}/*.h")
2424
if(headers)
25-
install(FILES ${headers} DESTINATION "${AT_INSTALL_INCLUDE_DIR}/${dest_subdir}")
25+
install(FILES ${headers} DESTINATION "${AT_INSTALL_INCLUDE_DIR}/ATen/${subdir}")
2626
endif()
2727
endmacro()
2828

29-
install_xpu_headers("xpu/*.h" "ATen/xpu")
30-
install_xpu_headers("native/xpu/*.h" "ATen/native/xpu")
31-
install_xpu_headers("native/xpu/sycl/*.h" "ATen/native/xpu/sycl")
32-
install_xpu_headers("native/xpu/mkl/*.h" "ATen/native/xpu/mkl")
33-
install_xpu_headers("native/nested/xpu/*.h" "ATen/native/nested/xpu")
34-
install_xpu_headers("native/nested/xpu/sycl/*.h" "ATen/native/nested/xpu/sycl")
35-
install_xpu_headers("native/quantized/*.h" "ATen/native/quantized/xpu")
36-
install_xpu_headers("native/quantized/sycl/*.h" "ATen/native/quantized/xpu/sycl")
37-
install_xpu_headers("native/sparse/xpu/*.h" "ATen/native/sparse/xpu")
38-
install_xpu_headers("native/sparse/xpu/sycl/*.h" "ATen/native/sparse/xpu/sycl")
39-
install_xpu_headers("native/transformers/*.h" "ATen/native/transformers/xpu")
40-
install_xpu_headers("native/transformers/sycl/*.h" "ATen/native/transformers/xpu/sycl")
29+
install_xpu_headers("xpu")
30+
install_xpu_headers("native/xpu")
31+
install_xpu_headers("native/xpu/sycl")
32+
install_xpu_headers("native/xpu/mkl")
33+
install_xpu_headers("native/nested/xpu")
34+
install_xpu_headers("native/nested/xpu/sycl")
35+
install_xpu_headers("native/quantized/xpu")
36+
install_xpu_headers("native/quantized/xpu/sycl")
37+
install_xpu_headers("native/sparse/xpu")
38+
install_xpu_headers("native/sparse/xpu/sycl")
39+
install_xpu_headers("native/transformers/xpu")
40+
install_xpu_headers("native/transformers/xpu/sycl")
4141

4242
if(xpu_ops_generated_headers)
4343
install(FILES ${xpu_ops_generated_headers} DESTINATION ${AT_INSTALL_INCLUDE_DIR}/ATen/ops)

0 commit comments

Comments
 (0)