-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[XPU]add support for XHPC #59895
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
[XPU]add support for XHPC #59895
Changes from 4 commits
7d449c9
818e4d0
a8c5685
9bb2570
4bf1c5e
ec73740
9329106
78eae41
4461e7f
70d7f58
bcd96ed
14af5b7
329f449
669c441
1d57d58
c23f3f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,15 @@ set(XPU_API_LIB_NAME "libxpuapi.so") | |
set(XPU_RT_LIB_NAME "libxpurt.so") | ||
set(XPU_XFT_LIB_NAME "libxft.so") | ||
set(XPU_XPTI_LIB_NAME "libxpti.so") | ||
set(XPU_XBLAS_LIB_NAME "libxpu_blas.so") | ||
set(XPU_XFA_LIB_NAME "libxpu_flash_attention.so") | ||
|
||
if(NOT DEFINED XPU_BASE_DATE) | ||
set(XPU_BASE_DATE "20231128") | ||
endif() | ||
if(NOT DEFINED XPU_XHPC_BASE_DATE) | ||
set(XPU_XHPC_BASE_DATE "20231208") | ||
endif() | ||
set(XPU_XCCL_BASE_VERSION "1.1.6.1") | ||
if(NOT DEFINED XPU_XFT_BASE_VERSION) | ||
set(XPU_XFT_BASE_VERSION "20230602") | ||
|
@@ -75,11 +80,13 @@ elseif(WITH_BDCENTOS) | |
set(XPU_XDNN_DIR_NAME "xdnn-bdcentos_x86_64") | ||
set(XPU_XCCL_DIR_NAME "${XPU_XCCL_PREFIX}-bdcentos_x86_64") | ||
set(XPU_XFT_DIR_NAME "xft_bdcentos6u3_x86_64_gcc82") | ||
set(XPU_XHPC_DIR_NAME "xhpc-bdcentos_x86_64") | ||
elseif(WITH_UBUNTU) | ||
set(XPU_XRE_DIR_NAME "xre-ubuntu_x86_64") | ||
set(XPU_XDNN_DIR_NAME "xdnn-ubuntu_x86_64") | ||
set(XPU_XCCL_DIR_NAME "${XPU_XCCL_PREFIX}-ubuntu_x86_64") | ||
set(XPU_XFT_DIR_NAME "xft_ubuntu1604_x86_64") | ||
set(XPU_XHPC_DIR_NAME "xhpc-ubuntu_x86_64") | ||
elseif(WITH_CENTOS) | ||
set(XPU_XRE_DIR_NAME "xre-centos7_x86_64") | ||
set(XPU_XDNN_DIR_NAME "xdnn-centos7_x86_64") | ||
|
@@ -90,6 +97,7 @@ else() | |
set(XPU_XDNN_DIR_NAME "xdnn-ubuntu_x86_64") | ||
set(XPU_XCCL_DIR_NAME "${XPU_XCCL_PREFIX}-ubuntu_x86_64") | ||
set(XPU_XFT_DIR_NAME "xft_ubuntu1604_x86_64") | ||
set(XPU_XHPC_DIR_NAME "xhpc-ubuntu_x86_64") | ||
endif() | ||
set(XPU_XPTI_DIR_NAME "xpti") | ||
|
||
|
@@ -110,14 +118,22 @@ set(XPU_XFT_GET_DEPENCE_URL | |
"https://baidu-kunlun-public.su.bcebos.com/paddle_depence/get_xft_dependence.sh" | ||
CACHE STRING "" FORCE) | ||
|
||
if(WITH_XPU_XHPC) | ||
set(XPU_XHPC_URL | ||
"https://klx-sdk-release-public.su.bcebos.com/xhpc/dev/${XPU_XHPC_BASE_DATE}/${XPU_XHPC_DIR_NAME}.tar.gz" | ||
CACHE STRING "" FORCE) | ||
endif() | ||
|
||
set(SNAPPY_PREFIX_DIR "${THIRD_PARTY_PATH}/xpu") | ||
set(XPU_DOWNLOAD_DIR "${SNAPPY_PREFIX_DIR}/src/${XPU_PROJECT}") | ||
set(XPU_INSTALL_DIR "${THIRD_PARTY_PATH}/install/xpu") | ||
set(XPU_INC_DIR "${THIRD_PARTY_PATH}/install/xpu/include") | ||
set(XPU_LIB_DIR "${THIRD_PARTY_PATH}/install/xpu/lib") | ||
|
||
set(XPU_API_LIB "${XPU_LIB_DIR}/${XPU_API_LIB_NAME}") | ||
set(XPU_XBLAS_LIB "${XPU_LIB_DIR}/${XPU_XBLAS_LIB_NAME}") | ||
set(XPU_RT_LIB "${XPU_LIB_DIR}/${XPU_RT_LIB_NAME}") | ||
set(XPU_XFA_LIB "${XPU_LIB_DIR}/${XPU_XFA_LIB_NAME}") | ||
|
||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${XPU_INSTALL_DIR}/lib") | ||
|
||
|
@@ -144,19 +160,20 @@ ExternalProject_Add( | |
DOWNLOAD_DIR ${XPU_DOWNLOAD_DIR} | ||
DOWNLOAD_COMMAND | ||
bash ${CMAKE_SOURCE_DIR}/tools/xpu/check_xpu_dependence.sh ${XPU_BASE_URL} | ||
${XPU_XCCL_BASE_URL} && bash | ||
${XPU_XCCL_BASE_URL} && WITH_XPU_XHPC=${WITH_XPU_XHPC} bash | ||
${CMAKE_SOURCE_DIR}/tools/xpu/pack_paddle_depence.sh ${XPU_XRE_URL} | ||
${XPU_XRE_DIR_NAME} ${XPU_XDNN_URL} ${XPU_XDNN_DIR_NAME} ${XPU_XCCL_URL} | ||
${XPU_XCCL_DIR_NAME} && wget ${XPU_XFT_GET_DEPENCE_URL} && bash | ||
get_xft_dependence.sh ${XPU_XFT_URL} ${XPU_XFT_DIR_NAME} && | ||
WITH_XPTI=${WITH_XPTI} bash | ||
${XPU_XCCL_DIR_NAME} ${XPU_XHPC_URL} ${XPU_XHPC_DIR_NAME} && wget | ||
${XPU_XFT_GET_DEPENCE_URL} && bash get_xft_dependence.sh ${XPU_XFT_URL} | ||
${XPU_XFT_DIR_NAME} && WITH_XPTI=${WITH_XPTI} bash | ||
${CMAKE_SOURCE_DIR}/tools/xpu/get_xpti_dependence.sh ${XPU_XPTI_URL} | ||
${XPU_XPTI_DIR_NAME} | ||
DOWNLOAD_NO_PROGRESS 1 | ||
UPDATE_COMMAND "" | ||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XPU_INSTALL_ROOT} | ||
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${XPU_INSTALL_ROOT} | ||
BUILD_BYPRODUCTS ${XPU_API_LIB} | ||
BUILD_BYPRODUCTS ${XPU_API_LIB} BUILD_BYPORDUCTS ${XPU_XBLAS_LIB} | ||
BUILD_BYPRODUCTS ${XPU_XFA_LIB} | ||
BUILD_BYPRODUCTS ${XPU_RT_LIB} | ||
BUILD_BYPRODUCTS ${XPU_BKCL_LIB}) | ||
|
||
|
@@ -179,6 +196,20 @@ if(WITH_XPU_XFT) | |
set(XPU_XFT_LIB "${XPU_LIB_DIR}/${XPU_XFT_LIB_NAME}") | ||
endif() | ||
|
||
if(WITH_XPU_XHPC) | ||
message(STATUS "Compile with XPU XHPC!") | ||
add_definitions(-DPADDLE_WITH_XPU_XHPC) | ||
|
||
set(XPU_XHPC_INC_DIR "${XPU_INC_DIR}/xhpc") | ||
include_directories(${XPU_XHPC_INC_DIR}) | ||
set(XPU_XBLAS_INC_DIR "${XPU_INC_DIR}/xhpc/xblas") | ||
include_directories(${XPU_XBLAS_INC_DIR}) | ||
|
||
set(XPU_XFA_INC_DIR "${XPU_INC_DIR}/xhpc/xfa") | ||
include_directories(${XPU_XFA_INC_DIR}) | ||
|
||
endif() | ||
|
||
if(WITH_XPTI) | ||
message(STATUS "Compile with XPU XPTI!") | ||
add_definitions(-DPADDLE_WITH_XPTI) | ||
|
@@ -206,6 +237,11 @@ if(WITH_XPTI) | |
target_link_libraries(xpulib ${XPU_XPTI_LIB}) | ||
endif() | ||
|
||
if(WITH_XPU_XHPC) | ||
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_XBLAS_LIB}) | ||
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_XFA_LIB}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 241行和242行可以拼接在一起么? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 另外,和225-234行这一堆可以拼接在一起么? |
||
endif() | ||
|
||
add_dependencies(xpulib ${XPU_PROJECT}) | ||
|
||
# Ensure that xpu/api.h can be included without dependency errors. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1151,6 +1151,12 @@ def get_package_data_and_package_dir(): | |
shutil.copy(env_dict.get("XPU_XPTI_LIB"), libs_path) | ||
package_data['paddle.libs'] += [env_dict.get("XPU_XPTI_LIB_NAME")] | ||
|
||
if env_dict.get("WITH_XPU_XHPC") == 'ON': | ||
shutil.copy(env_dict.get("XPU_XBLAS_LIB"), libs_path) | ||
package_data['paddle.libs'] += [env_dict.get("XPU_XBLAS_LIB_NAME")] | ||
shutil.copy(env_dict.get("XPU_XFA_LIB"), libs_path) | ||
package_data['paddle.libs'] += [env_dict.get("XPU_XFA_LIB_NAME")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 注意看一下, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已添加 |
||
|
||
# remove unused paddle/libs/__init__.py | ||
if os.path.isfile(libs_path + '/__init__.py'): | ||
os.remove(libs_path + '/__init__.py') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,12 @@ | |
set -e | ||
set -x | ||
|
||
if [[ $# -eq 8 ]]; then | ||
echo "Compiling Paddle with XHPC" | ||
XHPC_URL=$7 | ||
XHPC_DIR_NAME=$8 | ||
fi | ||
|
||
XRE_URL=$1 | ||
XRE_DIR_NAME=$2 | ||
|
||
|
@@ -35,12 +41,31 @@ tar xvf xdnn.tar.gz | |
wget --no-check-certificate ${XCCL_URL} -q -O xccl.tar.gz | ||
tar xvf xccl.tar.gz | ||
|
||
if [ -n ${XHPC_URL} ]; then | ||
wget --no-check-certificate ${XHPC_URL} -q -O xhpc.tar.gz | ||
tar xvf xphc.tar.gz | ||
mkdir -p xpu/include/xhpc/xblas | ||
mkdir -p xpu/include/xhpc/xfa | ||
|
||
cp -r output/${XHPC_DIR_NAME}/xblas/include/* xpu/include/xhpc/xblas | ||
cp -r output/${XHPC_DIR_NAME}/xblas/so/* xpu/lib/ | ||
|
||
cp -r output/${XHPC_DIR_NAME}/xdnn/include/* xpu/include/ | ||
cp -r output/${XHPC_DIR_NAME}/xdnn/so/* xpu/lib | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 53-54行的这两个cp,是否依赖下面60-61行的mkdir(对应原版38-39行的mkdir)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改 |
||
|
||
cp -r output/${XHPC_DIR_NAME}/xfa/include/* xpu/include/xhpc/xfa | ||
cp -r output/${XHPC_DIR_NAME}/xfa/so/* xpu/lib/ | ||
fi | ||
|
||
mkdir -p xpu/include/xpu | ||
mkdir -p xpu/lib | ||
|
||
if ! [ -n ${XHPC_URL} ]; then | ||
cp -r $XDNN_DIR_NAME/include/xpu/* xpu/include/xpu/ | ||
cp -r $XDNN_DIR_NAME/so/libxpuapi.so xpu/lib/ | ||
fi | ||
|
||
cp -r $XRE_DIR_NAME/include/xpu/* xpu/include/xpu/ | ||
cp -r $XRE_DIR_NAME/so/libxpurt* xpu/lib/ | ||
cp -r $XDNN_DIR_NAME/include/xpu/* xpu/include/xpu/ | ||
cp -r $XDNN_DIR_NAME/so/libxpuapi.so xpu/lib/ | ||
cp -r $XCCL_DIR_NAME/include/* xpu/include/xpu/ | ||
cp -r $XCCL_DIR_NAME/so/* xpu/lib/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是格式限定么?每行一个感觉会更清楚一些。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit格式检查的时候自动改的