未验证 提交 e2690526 编写于 作者: X XiaociZhang 提交者: GitHub

[XPU] avoid compile issue in non-xpu env (#54711)

* [kunlun] avoid compile issue in non-xpu env

also rename macro WITH_XPU_XPTI to WITH_XPTI

* move get_xpti_dependency.sh to tools/xpu

* move get_xpti_dependency.sh to tools/xpu

* call get_xpti_dependency.sh only in need
上级 6fe7b5e2
...@@ -98,9 +98,6 @@ set(XPU_PACK_DEPENCE_URL ...@@ -98,9 +98,6 @@ set(XPU_PACK_DEPENCE_URL
set(XPU_XFT_GET_DEPENCE_URL set(XPU_XFT_GET_DEPENCE_URL
"https://baidu-kunlun-public.su.bcebos.com/paddle_depence/get_xft_dependence.sh" "https://baidu-kunlun-public.su.bcebos.com/paddle_depence/get_xft_dependence.sh"
CACHE STRING "" FORCE) CACHE STRING "" FORCE)
set(XPU_XPTI_GET_DEPENCE_URL
"https://baidu-kunlun-public.su.bcebos.com/paddle_depence/get_xpti_dependence.sh"
CACHE STRING "" FORCE)
set(SNAPPY_PREFIX_DIR "${THIRD_PARTY_PATH}/xpu") set(SNAPPY_PREFIX_DIR "${THIRD_PARTY_PATH}/xpu")
set(XPU_DOWNLOAD_DIR "${SNAPPY_PREFIX_DIR}/src/${XPU_PROJECT}") set(XPU_DOWNLOAD_DIR "${SNAPPY_PREFIX_DIR}/src/${XPU_PROJECT}")
...@@ -140,8 +137,9 @@ ExternalProject_Add( ...@@ -140,8 +137,9 @@ ExternalProject_Add(
pack_paddle_depence.sh ${XPU_XRE_URL} ${XPU_XRE_DIR_NAME} ${XPU_XDNN_URL} 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_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_GET_DEPENCE_URL} && bash get_xft_dependence.sh ${XPU_XFT_URL}
${XPU_XFT_DIR_NAME} && wget ${XPU_XPTI_GET_DEPENCE_URL} && bash ${XPU_XFT_DIR_NAME} [ -n "$WITH_XPTI" ] && bash
get_xpti_dependence.sh ${XPU_XPTI_URL} ${XPU_XPTI_DIR_NAME} ${CMAKE_SOURCE_DIR}/tools/xpu/get_xpti_dependence.sh ${XPU_XPTI_URL}
${XPU_XPTI_DIR_NAME}
DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND "" UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XPU_INSTALL_ROOT} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XPU_INSTALL_ROOT}
...@@ -169,9 +167,9 @@ if(WITH_XPU_XFT) ...@@ -169,9 +167,9 @@ if(WITH_XPU_XFT)
set(XPU_XFT_LIB "${XPU_LIB_DIR}/${XPU_XFT_LIB_NAME}") set(XPU_XFT_LIB "${XPU_LIB_DIR}/${XPU_XFT_LIB_NAME}")
endif() endif()
if(WITH_XPU_XPTI) if(WITH_XPTI)
message(STATUS "Compile with XPU XPTI!") message(STATUS "Compile with XPU XPTI!")
add_definitions(-DPADDLE_WITH_XPU_XPTI) add_definitions(-DPADDLE_WITH_XPTI)
set(XPU_XPTI_LIB "${XPU_LIB_DIR}/${XPU_XPTI_LIB_NAME}") set(XPU_XPTI_LIB "${XPU_LIB_DIR}/${XPU_XPTI_LIB_NAME}")
endif() endif()
...@@ -186,7 +184,7 @@ else() ...@@ -186,7 +184,7 @@ else()
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB}) target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB})
endif() endif()
if(WITH_XPU_XPTI) if(WITH_XPTI)
target_link_libraries(xpulib ${XPU_XPTI_LIB}) target_link_libraries(xpulib ${XPU_XPTI_LIB})
endif() endif()
......
...@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifdef PADDLE_WITH_XPU #ifdef PADDLE_WITH_XPTI
#include "paddle/fluid/platform/dynload/xpti.h" #include "paddle/fluid/platform/dynload/xpti.h"
...@@ -28,4 +28,4 @@ XPTI_ROUTINE_EACH(DEFINE_WRAP); ...@@ -28,4 +28,4 @@ XPTI_ROUTINE_EACH(DEFINE_WRAP);
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
#endif // PADDLE_WITH_XPU #endif // PADDLE_WITH_XPTI
...@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and ...@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#pragma once #pragma once
#ifdef PADDLE_WITH_XPTI
#include <xpu/xpti.h> #include <xpu/xpti.h>
#include <mutex> // NOLINT #include <mutex> // NOLINT
...@@ -41,3 +43,5 @@ XPTI_RAND_ROUTINE_EACH(DECLARE_DYNAMIC_LOAD_XPTI_WRAP); ...@@ -41,3 +43,5 @@ XPTI_RAND_ROUTINE_EACH(DECLARE_DYNAMIC_LOAD_XPTI_WRAP);
} // namespace dynload } // namespace dynload
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
#endif // PADDLE_WITH_XPTI
...@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifdef PADDLE_WITH_XPU #ifdef PADDLE_WITH_XPTI
#include "paddle/phi/backends/dynload/xpti.h" #include "paddle/phi/backends/dynload/xpti.h"
...@@ -29,4 +29,4 @@ XPTI_ROUTINE_EACH(DEFINE_WRAP); ...@@ -29,4 +29,4 @@ XPTI_ROUTINE_EACH(DEFINE_WRAP);
} // namespace dynload } // namespace dynload
} // namespace phi } // namespace phi
#endif // PADDLE_WITH_XPU #endif // PADDLE_WITH_XPTI
...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#pragma once #pragma once
#ifdef PADDLE_WITH_XPU #ifdef PADDLE_WITH_XPTI
#include <xpu/xpti.h> #include <xpu/xpti.h>
......
#!/bin/bash
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
XPTI_URL=$1
XPTI_DIR_NAME=$2
wget --no-check-certificate ${XPTI_URL} -c -q -O xpti.tar.gz
if [[ $? -ne 0 ]]; then
echo "downloading failed: ${XPTI_URL}"
exit 1
else
echo "downloading ok: ${XPTI_URL}"
fi
tar -xvf xpti.tar.gz
# xpu/include/xpu already exists
cp -r ${XPTI_DIR_NAME}/include/* xpu/include/xpu
# xpu/lib already exists
cp -r ${XPTI_DIR_NAME}/so/* xpu/lib/
# copy libxpurt.so that support klprof
# commit fa894b83f9e2d1235564b93301265d8b55be5464 (HEAD -> trace)
rm xpu/lib/libxpurt.so*
cp -r ${XPTI_DIR_NAME}/runtime/libxpurt.so* xpu/lib/
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册