mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Support XPU ABI=0 build (#130110)
# Motivation This PR intends to support ABI=0 build for XPU backend. # Additional Context The major change is adding a compilation option `-D__INTEL_PREVIEW_BREAKING_CHANGES` for the host compiler(gcc) and `-fpreview-breaking-changes` for XPU device kernel code compiler(icpx), why? Because we use - gcc to compile host code and link SYCL runtime. So we need to pass `-D__INTEL_PREVIEW_BREAKING_CHANGES` to tell the host compiler invoking the ABI-neutral API included in SYCL. And - use icpx to compile device kernel code and link SYCL runtime. So we need to pass `-fpreview-breaking-changes` to tell the device kernel compiler building ABI-neutral code. Besides, - `libsycl-preview.so` is an ABI-neutral library but `libsycl.so` is not. This PR depends on https://github.com/pytorch/pytorch/pull/131643. Pull Request resolved: https://github.com/pytorch/pytorch/pull/130110 Approved by: https://github.com/EikanWang, https://github.com/gujinghui, https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
997f64af38
commit
92bebb46fa
@ -252,6 +252,8 @@ If you would like to compile PyTorch with [new C++ ABI](https://gcc.gnu.org/onli
|
||||
export _GLIBCXX_USE_CXX11_ABI=1
|
||||
```
|
||||
|
||||
Please **note** that starting from PyTorch 2.5, the PyTorch build with XPU supports both new and old C++ ABIs. Previously, XPU only supported the new C++ ABI. If you want to compile with Intel GPU support, please follow [Intel GPU Support](#intel-gpu-support).
|
||||
|
||||
If you're compiling for AMD ROCm then first run this command:
|
||||
```bash
|
||||
# Only run this if you're compiling for ROCm
|
||||
|
@ -90,6 +90,10 @@ if(USE_XPU)
|
||||
message(WARNING "Not compiling with XPU. Could NOT find SYCL."
|
||||
"Suppress this warning with -DUSE_XPU=OFF.")
|
||||
caffe2_update_option(USE_XPU OFF)
|
||||
else()
|
||||
if(LINUX)
|
||||
string(APPEND CMAKE_CXX_FLAGS " -D__INTEL_PREVIEW_BREAKING_CHANGES")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -42,12 +42,16 @@ IF(NOT MKLDNN_FOUND)
|
||||
list(APPEND DNNL_MAKE_COMMAND "--" "-l" "$ENV{MAX_JOBS}")
|
||||
endif()
|
||||
endif()
|
||||
if(LINUX)
|
||||
set(ABI_NEUTRAL_FLAGS -fpreview-breaking-changes)
|
||||
endif()
|
||||
ExternalProject_Add(xpu_mkldnn_proj
|
||||
SOURCE_DIR ${MKLDNN_ROOT}
|
||||
PREFIX ${XPU_MKLDNN_DIR_PREFIX}
|
||||
BUILD_IN_SOURCE 0
|
||||
CMAKE_ARGS -DCMAKE_C_COMPILER=icx
|
||||
-DCMAKE_CXX_COMPILER=${SYCL_CXX_DRIVER}
|
||||
-DCMAKE_CXX_FLAGS=${ABI_NEUTRAL_FLAGS}
|
||||
-DDNNL_GPU_RUNTIME=SYCL
|
||||
-DDNNL_CPU_RUNTIME=THREADPOOL
|
||||
-DDNNL_BUILD_TESTS=OFF
|
||||
|
@ -51,7 +51,7 @@ find_file(
|
||||
# Find SYCL library fullname.
|
||||
find_library(
|
||||
SYCL_LIBRARY
|
||||
NAMES sycl
|
||||
NAMES sycl-preview
|
||||
HINTS ${SYCL_LIBRARY_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
Reference in New Issue
Block a user