Skip to content

Commit dbf6b0d

Browse files
authored
Remove BUILD_SPLIT_KERNEL_LIB flag (#2208)
`BUILD_SPLIT_KERNEL_LIB` looks like workaround, which is no longer needed in new compiler versions. From release notes > The compiler team introduced device image compression in version 2025.0.1, and this feature is now enabled in oneMKL 2025.2 builds. It facilitates the reduction in size of SYCL libraries with large kernels by approximately 12% to 40% for both static and dynamic libraries on Linux, as well as dynamic libraries on Windows. Also this flag can't be used for Debug/RelWithDefInfo builds, as for these configs `BUILD_SEPARATE_OPS` takes precedence ```CMake if(CMAKE_BUILD_TYPE MATCHES "(Debug|RelWithDebInfo)") set(BUILD_SEPARATE_OPS TRUE) endif() ... if(BUILD_SEPARATE_OPS) ... elseif(BUILD_SPLIT_KERNEL_LIB OR __INTEL_LLVM_COMPILER LESS 20250004 OR ICX_DATE LESS 20241205) ... else() ... endif() ``` Continuation of #2204
1 parent e26f6a8 commit dbf6b0d

File tree

2 files changed

+0
-281
lines changed

2 files changed

+0
-281
lines changed

src/BuildOnLinux.cmake

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -36,87 +36,6 @@ if(BUILD_SEPARATE_OPS)
3636
# Decouple with PyTorch cmake definition.
3737
install(TARGETS ${sycl_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
3838
endforeach()
39-
# Working with the compilers which don't support device code compression, we have to split kernels
40-
# into multiple libraries to meet the bin size limitation.
41-
elseif(BUILD_SPLIT_KERNEL_LIB OR __INTEL_LLVM_COMPILER LESS 20250004 OR ICX_DATE LESS 20241205)
42-
setup_common_libraries()
43-
# Split SYCL kernels into 4 libraries as categories 1) Unary+Binary 2) Reduce 3) Foreach 4) Others.
44-
set(ATen_XPU_SYCL_UNARY_BINARY_SRCS)
45-
set(ATen_XPU_SYCL_REDUCE_SRCS)
46-
set(ATen_XPU_SYCL_FOREACH_SRCS)
47-
set(ATen_XPU_SYCL_OTHERS_SRCS)
48-
49-
foreach(sycl_src ${ATen_XPU_SYCL_SRCS})
50-
string(REGEX MATCH "Binary" IS_BINARY ${sycl_src})
51-
string(REGEX MATCH "Unary" IS_UNARY ${sycl_src})
52-
string(REGEX MATCH "Pow" IS_POW ${sycl_src})
53-
string(REGEX MATCH "Copy" IS_COPY ${sycl_src})
54-
string(REGEX MATCH "Reduce" IS_REDUCE ${sycl_src})
55-
string(REGEX MATCH "Activation" IS_ACTIVATION ${sycl_src})
56-
string(REGEX MATCH "Foreach" IS_FOREACH ${sycl_src})
57-
58-
if(NOT IS_FOREACH STREQUAL "")
59-
list(APPEND ATen_XPU_SYCL_FOREACH_SRCS ${sycl_src})
60-
elseif(NOT IS_REDUCE STREQUAL "")
61-
list(APPEND ATen_XPU_SYCL_REDUCE_SRCS ${sycl_src})
62-
elseif(NOT IS_UNARY STREQUAL "" OR NOT IS_BINARY STREQUAL "")
63-
list(APPEND ATen_XPU_SYCL_UNARY_BINARY_SRCS ${sycl_src})
64-
elseif(NOT IS_COPY STREQUAL "" OR NOT IS_POW STREQUAL "")
65-
list(APPEND ATen_XPU_SYCL_UNARY_BINARY_SRCS ${sycl_src})
66-
elseif(NOT IS_ACTIVATION STREQUAL "")
67-
list(APPEND ATen_XPU_SYCL_UNARY_BINARY_SRCS ${sycl_src})
68-
else()
69-
list(APPEND ATen_XPU_SYCL_OTHERS_SRCS ${sycl_src})
70-
endif()
71-
endforeach()
72-
73-
# Unary binary kernel lib
74-
set(sycl_unary_binary_lib torch_xpu_ops_sycl_unary_binary_kernels)
75-
sycl_add_library(
76-
${sycl_unary_binary_lib}
77-
SHARED
78-
SYCL_SOURCES ${ATen_XPU_SYCL_UNARY_BINARY_SRCS})
79-
target_link_libraries(torch_xpu_ops PUBLIC ${sycl_unary_binary_lib})
80-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_unary_binary_lib})
81-
82-
# Decouple with PyTorch cmake definition.
83-
install(TARGETS ${sycl_unary_binary_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
84-
85-
# Reduce kernel lib
86-
set(sycl_reduce_lib torch_xpu_ops_sycl_reduce_kernels)
87-
sycl_add_library(
88-
${sycl_reduce_lib}
89-
SHARED
90-
SYCL_SOURCES ${ATen_XPU_SYCL_REDUCE_SRCS})
91-
target_link_libraries(torch_xpu_ops PUBLIC ${sycl_reduce_lib})
92-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_reduce_lib})
93-
94-
# Decouple with PyTorch cmake definition.
95-
install(TARGETS ${sycl_reduce_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
96-
97-
# Foreach kernel lib
98-
set(sycl_foreach_lib torch_xpu_ops_sycl_foreach_kernels)
99-
sycl_add_library(
100-
${sycl_foreach_lib}
101-
SHARED
102-
SYCL_SOURCES ${ATen_XPU_SYCL_FOREACH_SRCS})
103-
target_link_libraries(torch_xpu_ops PUBLIC ${sycl_foreach_lib})
104-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_foreach_lib})
105-
106-
# Decouple with PyTorch cmake definition.
107-
install(TARGETS ${sycl_foreach_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
108-
109-
# Other kernel lib
110-
set(sycl_lib torch_xpu_ops_sycl_kernels)
111-
sycl_add_library(
112-
${sycl_lib}
113-
SHARED
114-
SYCL_SOURCES ${ATen_XPU_SYCL_OTHERS_SRCS})
115-
target_link_libraries(torch_xpu_ops PUBLIC ${sycl_lib})
116-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_lib})
117-
118-
# Decouple with PyTorch cmake definition.
119-
install(TARGETS ${sycl_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
12039
else()
12140
sycl_add_library(
12241
torch_xpu_ops

src/BuildOnWindows.cmake

Lines changed: 0 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -39,206 +39,6 @@ if(BUILD_SEPARATE_OPS)
3939
# Decouple with PyTorch cmake definition.
4040
install(TARGETS ${sycl_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
4141
endforeach()
42-
list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops)
43-
list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops_aten)
44-
# Working with the compilers which don't support device code compression, we have to split kernels
45-
# into multiple libraries to meet the bin size limitation.
46-
elseif(BUILD_SPLIT_KERNEL_LIB OR __INTEL_LLVM_COMPILER LESS 20250004 OR ICX_DATE LESS 20241205)
47-
setup_common_libraries()
48-
# Split SYCL kernels into 2 libraries as categories 1) Unary+Binary 2) Others.
49-
set(ATen_XPU_SYCL_BINARY_SRCS)
50-
set(ATen_XPU_SYCL_UNARY_SRCS)
51-
set(ATen_XPU_SYCL_REDUCE_SRCS)
52-
set(ATen_XPU_SYCL_ACTIVATION_SRCS)
53-
set(ATen_XPU_SYCL_FOREACH_SRCS)
54-
set(ATen_XPU_SYCL_TENSOR_SRCS)
55-
set(ATen_XPU_SYCL_NORM_LOSS_SRCS)
56-
set(ATen_XPU_SYCL_POLY_SRCS)
57-
set(ATen_XPU_SYCL_DISTRIBUTION_SRCS)
58-
set(ATen_XPU_SYCL_OTHERS_SRCS)
59-
foreach(sycl_src ${ATen_XPU_SYCL_SRCS})
60-
string(REGEX MATCH "Binary" IS_BINARY ${sycl_src})
61-
string(REGEX MATCH "Unary" IS_UNARY ${sycl_src})
62-
# Resolve cyclic dependences between
63-
# torch_xpu_ops_sycl_unary_binary_kernels.dll and
64-
# torch_xpu_ops_sycl_kernels.dll. Move definition and invoke of kernels
65-
# into a same kernel library. Here we move elementwise kernel pow and copy
66-
# into torch_xpu_ops_sycl_unary_binary_kernels.dll.
67-
string(REGEX MATCH "Pow" IS_POW ${sycl_src})
68-
string(REGEX MATCH "Copy" IS_COPY ${sycl_src})
69-
string(REGEX MATCH "Activation" IS_ACTIVATION ${sycl_src})
70-
string(REGEX MATCH "Foreach" IS_FOREACH ${sycl_src})
71-
string(REGEX MATCH "Reduce" IS_REDUCE ${sycl_src})
72-
string(REGEX MATCH "Tensor" IS_TENSOR ${sycl_src})
73-
string(REGEX MATCH "Norm" IS_NORM ${sycl_src})
74-
string(REGEX MATCH "Loss" IS_LOSS ${sycl_src})
75-
string(REGEX MATCH "Polynomial" IS_POLY ${sycl_src})
76-
#Move resize kernel to Norm and Loss lib, to resolve symbol.
77-
string(REGEX MATCH "Resize" IS_RESIZE ${sycl_src})
78-
string(REGEX MATCH "Distribution" IS_DISTRIBUTION ${sycl_src})
79-
80-
if(NOT IS_FOREACH STREQUAL "")
81-
list(APPEND ATen_XPU_SYCL_FOREACH_SRCS ${sycl_src})
82-
elseif(NOT IS_BINARY STREQUAL "")
83-
list(APPEND ATen_XPU_SYCL_BINARY_SRCS ${sycl_src})
84-
elseif(NOT IS_UNARY STREQUAL "" OR NOT IS_COPY STREQUAL "" OR NOT IS_POW STREQUAL "")
85-
list(APPEND ATen_XPU_SYCL_UNARY_SRCS ${sycl_src})
86-
elseif(NOT IS_REDUCE STREQUAL "")
87-
list(APPEND ATen_XPU_SYCL_REDUCE_SRCS ${sycl_src})
88-
elseif(NOT IS_ACTIVATION STREQUAL "")
89-
list(APPEND ATen_XPU_SYCL_ACTIVATION_SRCS ${sycl_src})
90-
elseif(NOT IS_TENSOR STREQUAL "")
91-
list(APPEND ATen_XPU_SYCL_TENSOR_SRCS ${sycl_src})
92-
elseif(NOT IS_DISTRIBUTION STREQUAL "")
93-
list(APPEND ATen_XPU_SYCL_DISTRIBUTION_SRCS ${sycl_src})
94-
elseif(NOT IS_NORM STREQUAL "" OR NOT IS_LOSS STREQUAL "" OR NOT IS_RESIZE STREQUAL "")
95-
list(APPEND ATen_XPU_SYCL_NORM_LOSS_SRCS ${sycl_src})
96-
elseif(NOT IS_POLY STREQUAL "")
97-
list(APPEND ATen_XPU_SYCL_POLY_SRCS ${sycl_src})
98-
else()
99-
list(APPEND ATen_XPU_SYCL_OTHERS_SRCS ${sycl_src})
100-
endif()
101-
endforeach()
102-
# Binary kernel lib
103-
set(sycl_binary_lib torch_xpu_ops_sycl_binary_kernels)
104-
sycl_add_library(
105-
${sycl_binary_lib}
106-
SHARED
107-
SYCL_SOURCES ${ATen_XPU_SYCL_BINARY_SRCS})
108-
target_compile_definitions(${sycl_binary_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
109-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_binary_lib})
110-
target_link_libraries(${sycl_binary_lib} PUBLIC torch_xpu)
111-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_binary_lib})
112-
113-
# Decouple with PyTorch cmake definition.
114-
install(TARGETS ${sycl_binary_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
115-
116-
# Unary kernel lib
117-
set(sycl_unary_lib torch_xpu_ops_sycl_unary_kernels)
118-
sycl_add_library(
119-
${sycl_unary_lib}
120-
SHARED
121-
SYCL_SOURCES ${ATen_XPU_SYCL_UNARY_SRCS})
122-
target_compile_definitions(${sycl_unary_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
123-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_unary_lib})
124-
target_link_libraries(${sycl_unary_lib} PUBLIC torch_xpu)
125-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_unary_lib})
126-
127-
# Decouple with PyTorch cmake definition.
128-
install(TARGETS ${sycl_unary_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
129-
130-
# Reduce kernel lib
131-
set(sycl_reduce_lib torch_xpu_ops_sycl_reduce_kernels)
132-
sycl_add_library(
133-
${sycl_reduce_lib}
134-
SHARED
135-
SYCL_SOURCES ${ATen_XPU_SYCL_REDUCE_SRCS})
136-
target_compile_definitions(${sycl_reduce_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
137-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_reduce_lib})
138-
target_link_libraries(${sycl_reduce_lib} PUBLIC torch_xpu)
139-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_reduce_lib})
140-
141-
# Decouple with PyTorch cmake definition.
142-
install(TARGETS ${sycl_reduce_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
143-
144-
# Activation kernel lib
145-
set(sycl_activation_lib torch_xpu_ops_sycl_activation_kernels)
146-
sycl_add_library(
147-
${sycl_activation_lib}
148-
SHARED
149-
SYCL_SOURCES ${ATen_XPU_SYCL_ACTIVATION_SRCS})
150-
target_compile_definitions(${sycl_activation_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
151-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_activation_lib})
152-
target_link_libraries(${sycl_activation_lib} PUBLIC torch_xpu)
153-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_activation_lib})
154-
155-
# Decouple with PyTorch cmake definition.
156-
install(TARGETS ${sycl_activation_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
157-
158-
# Foreach kernel lib
159-
set(sycl_foreach_lib torch_xpu_ops_sycl_foreach_kernels)
160-
sycl_add_library(
161-
${sycl_foreach_lib}
162-
SHARED
163-
SYCL_SOURCES ${ATen_XPU_SYCL_FOREACH_SRCS})
164-
target_compile_definitions(${sycl_foreach_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
165-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_foreach_lib})
166-
target_link_libraries(${sycl_foreach_lib} PUBLIC torch_xpu)
167-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_foreach_lib})
168-
169-
# Decouple with PyTorch cmake definition.
170-
install(TARGETS ${sycl_foreach_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
171-
172-
# Tensor kernel lib
173-
set(sycl_tensor_lib torch_xpu_ops_sycl_tensor_kernels)
174-
sycl_add_library(
175-
${sycl_tensor_lib}
176-
SHARED
177-
SYCL_SOURCES ${ATen_XPU_SYCL_TENSOR_SRCS})
178-
target_compile_definitions(${sycl_tensor_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
179-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_tensor_lib})
180-
target_link_libraries(${sycl_tensor_lib} PUBLIC torch_xpu)
181-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_tensor_lib})
182-
183-
# Decouple with PyTorch cmake definition.
184-
install(TARGETS ${sycl_tensor_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
185-
186-
# Norm and Loss kernel lib
187-
set(sycl_norm_loss_lib torch_xpu_ops_sycl_norm_loss_kernels)
188-
sycl_add_library(
189-
${sycl_norm_loss_lib}
190-
SHARED
191-
SYCL_SOURCES ${ATen_XPU_SYCL_NORM_LOSS_SRCS})
192-
target_compile_definitions(${sycl_norm_loss_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
193-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_norm_loss_lib})
194-
target_link_libraries(${sycl_norm_loss_lib} PUBLIC torch_xpu)
195-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_norm_loss_lib})
196-
197-
# Decouple with PyTorch cmake definition.
198-
install(TARGETS ${sycl_norm_loss_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
199-
200-
# Polynomial kernel lib
201-
set(sycl_poly_lib torch_xpu_ops_sycl_poly_kernels)
202-
sycl_add_library(
203-
${sycl_poly_lib}
204-
SHARED
205-
SYCL_SOURCES ${ATen_XPU_SYCL_POLY_SRCS})
206-
target_compile_definitions(${sycl_poly_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
207-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_poly_lib})
208-
target_link_libraries(${sycl_poly_lib} PUBLIC torch_xpu)
209-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_poly_lib})
210-
211-
# Decouple with PyTorch cmake definition.
212-
install(TARGETS ${sycl_poly_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
213-
214-
# Distribution kernel lib
215-
set(sycl_dist_lib torch_xpu_ops_sycl_dist_kernels)
216-
sycl_add_library(
217-
${sycl_dist_lib}
218-
SHARED
219-
SYCL_SOURCES ${ATen_XPU_SYCL_DISTRIBUTION_SRCS})
220-
target_compile_definitions(${sycl_dist_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
221-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_dist_lib})
222-
target_link_libraries(${sycl_dist_lib} PUBLIC torch_xpu)
223-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_dist_lib})
224-
225-
# Decouple with PyTorch cmake definition.
226-
install(TARGETS ${sycl_dist_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
227-
228-
# Other kernel lib
229-
set(sycl_lib torch_xpu_ops_sycl_kernels)
230-
sycl_add_library(
231-
${sycl_lib}
232-
SHARED
233-
SYCL_SOURCES ${ATen_XPU_SYCL_OTHERS_SRCS})
234-
target_compile_definitions(${sycl_lib} PRIVATE TORCH_XPU_BUILD_MAIN_LIB)
235-
target_link_libraries(torch_xpu_ops_aten PUBLIC ${sycl_lib})
236-
target_link_libraries(${sycl_lib} PUBLIC torch_xpu)
237-
list(APPEND TORCH_XPU_OPS_LIBRARIES ${sycl_lib})
238-
239-
# Decouple with PyTorch cmake definition.
240-
install(TARGETS ${sycl_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
241-
24242
list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops)
24343
list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops_aten)
24444
else()

0 commit comments

Comments
 (0)