Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building System: Only build one shared library for the user #1243

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5bfd384
DONOTMERGE: Evaluate device code compression.
fengyuan14 Dec 9, 2024
89af91f
enable compiled into one library on windows
chunhuanMeng Dec 25, 2024
27e9f23
format
chunhuanMeng Dec 25, 2024
a9ee242
Move libname renaming logic to `BuildOnWindows.cmake`
chunhuanMeng Dec 25, 2024
a15c352
Merge branch 'main' into fy/combine-kernel-lib
fengyuan14 Dec 26, 2024
1ee12c3
Remove BMG in default linux aot target
chunhuanMeng Dec 26, 2024
23a68d8
Merge branch 'main' into fy/combine-kernel-lib
chunhuanMeng Dec 27, 2024
307eb95
Merge branch 'main' into fy/combine-kernel-lib
chunhuanMeng Dec 30, 2024
30915bd
Merge branch 'main' into fy/combine-kernel-lib
chunhuanMeng Dec 30, 2024
17c119e
Merge branch 'main' into fy/combine-kernel-lib
fengyuan14 Jan 2, 2025
34a4485
Merge branch 'main' into fy/combine-kernel-lib
chunhuanMeng Jan 2, 2025
a8f006f
Make the compiled output have only one library
chunhuanMeng Jan 2, 2025
02a8cf4
change `xpu-sycl` to `xpu_sycl`
chunhuanMeng Jan 3, 2025
9997224
Split SYCL kernels into 2 lib and build 1 lib for op level source whi…
chunhuanMeng Jan 15, 2025
1b7a383
Merge branch 'main' into meng_windows
chunhuanMeng Jan 15, 2025
803cc52
Update BuildOnLinux.cmake
chunhuanMeng Jan 15, 2025
6ba9f27
Update BuildOnWindows.cmake
chunhuanMeng Jan 15, 2025
f17758a
Merge branch 'main' into meng_windows
chunhuanMeng Jan 16, 2025
ded4a0d
fix list `torch_xpu_ops`
chunhuanMeng Jan 17, 2025
d23d11f
add comments
chunhuanMeng Jan 20, 2025
215bf85
Merge branch 'main' into meng_windows
chunhuanMeng Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 40 additions & 20 deletions src/BuildOnLinux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
set(TORCH_XPU_OPS_LIBRARIES)
set(SYCL_LINK_LIBRARIES_KEYWORD PRIVATE)

add_library(
torch_xpu_ops
STATIC
${ATen_XPU_CPP_SRCS}
${ATen_XPU_NATIVE_CPP_SRCS}
${ATen_XPU_GEN_SRCS}
${ATen_XPU_XCCL_SRCS})

if(USE_C10D_XCCL)
target_compile_definitions(torch_xpu_ops PRIVATE USE_C10D_XCCL)
target_link_libraries(torch_xpu_ops PUBLIC torch::xccl)
endif()

if(BUILD_SEPARATE_OPS)
add_library(
torch_xpu_ops
STATIC
${ATen_XPU_CPP_SRCS}
${ATen_XPU_NATIVE_CPP_SRCS}
${ATen_XPU_GEN_SRCS}
${ATen_XPU_XCCL_SRCS})

if(USE_C10D_XCCL)
target_compile_definitions(torch_xpu_ops PRIVATE USE_C10D_XCCL)
target_link_libraries(torch_xpu_ops PUBLIC torch::xccl)
endif()
list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops)
foreach(sycl_src ${ATen_XPU_SYCL_SRCS})
get_filename_component(name ${sycl_src} NAME_WLE REALPATH)
set(sycl_lib torch-xpu-ops-sycl-${name})
Expand All @@ -31,6 +32,19 @@ if(BUILD_SEPARATE_OPS)
install(TARGETS ${sycl_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
endforeach()
elseif(BUILD_SPLIT_KERNEL_LIB)
add_library(
torch_xpu_ops
STATIC
${ATen_XPU_CPP_SRCS}
${ATen_XPU_NATIVE_CPP_SRCS}
${ATen_XPU_GEN_SRCS}
${ATen_XPU_XCCL_SRCS})

if(USE_C10D_XCCL)
target_compile_definitions(torch_xpu_ops PRIVATE USE_C10D_XCCL)
target_link_libraries(torch_xpu_ops PUBLIC torch::xccl)
endif()
list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops)
# Split SYCL kernels into 4 libraries as categories 1) Unary+Binary 2) Reduce 3) Foreach 4) Others.
set(ATen_XPU_SYCL_UNARY_BINARY_SRCS)
set(ATen_XPU_SYCL_REDUCE_SRCS)
Expand Down Expand Up @@ -110,18 +124,24 @@ elseif(BUILD_SPLIT_KERNEL_LIB)
install(TARGETS ${sycl_lib} DESTINATION "${TORCH_INSTALL_LIB_DIR}")
else()
sycl_add_library(
torch_xpu_ops_sycl_kernels
SHARED
xpu_sycl
STATIC
CXX_SOURCES ${ATen_XPU_CPP_SRCS} ${ATen_XPU_NATIVE_CPP_SRCS} ${ATen_XPU_GEN_SRCS} ${ATen_XPU_XCCL_SRCS}
SYCL_SOURCES ${ATen_XPU_SYCL_SRCS})
target_link_libraries(torch_xpu_ops PUBLIC torch_xpu_ops_sycl_kernels)
list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops_sycl_kernels)

install(TARGETS torch_xpu_ops_sycl_kernels DESTINATION "${TORCH_INSTALL_LIB_DIR}")
add_library(torch_xpu_ops ALIAS xpu_sycl)
set_target_properties(xpu_sycl PROPERTIES OUTPUT_NAME torch_xpu_ops)
set(SYCL_TARGET xpu_sycl)
if(USE_C10D_XCCL)
target_compile_definitions(xpu_sycl PRIVATE USE_C10D_XCCL)
target_link_libraries(xpu_sycl PUBLIC torch::xccl)
endif()

install(TARGETS xpu_sycl DESTINATION "${TORCH_INSTALL_LIB_DIR}")
list(APPEND TORCH_XPU_OPS_LIBRARIES xpu_sycl)

endif()
set(SYCL_LINK_LIBRARIES_KEYWORD)

list(APPEND TORCH_XPU_OPS_LIBRARIES torch_xpu_ops)

foreach(lib ${TORCH_XPU_OPS_LIBRARIES})
# Align with PyTorch compile options PYTORCH_SRC_DIR/cmake/public/utils.cmake
torch_compile_options(${lib})
Expand Down
Loading
Loading