Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
613beeb6
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
613beeb6
编写于
8月 03, 2023
作者:
H
hong19860320
提交者:
GitHub
8月 03, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] Fix compilation errors of XPU plugin on multiple versions of GCC (#55924)
上级
445d7337
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
32 deletion
+41
-32
paddle/phi/kernels/xpu/plugin/CMakeLists.txt
paddle/phi/kernels/xpu/plugin/CMakeLists.txt
+18
-19
paddle/phi/kernels/xpu/plugin/build.sh
paddle/phi/kernels/xpu/plugin/build.sh
+4
-4
paddle/phi/kernels/xpu/plugin/example/CMakeLists.txt
paddle/phi/kernels/xpu/plugin/example/CMakeLists.txt
+1
-1
paddle/phi/kernels/xpu/plugin/example/build.sh
paddle/phi/kernels/xpu/plugin/example/build.sh
+2
-2
paddle/phi/kernels/xpu/plugin/example/run.sh
paddle/phi/kernels/xpu/plugin/example/run.sh
+16
-6
未找到文件。
paddle/phi/kernels/xpu/plugin/CMakeLists.txt
浏览文件 @
613beeb6
cmake_minimum_required
(
VERSION 3.1
6
)
cmake_minimum_required
(
VERSION 3.1
0
)
project
(
xpuplugin LANGUAGES CXX
)
project
(
xpuplugin LANGUAGES CXX
)
...
@@ -62,14 +62,13 @@ message(STATUS "Build with XPU_CLANG=" ${XPU_CLANG})
...
@@ -62,14 +62,13 @@ message(STATUS "Build with XPU_CLANG=" ${XPU_CLANG})
if
(
NOT DEFINED HOST_SYSROOT
)
if
(
NOT DEFINED HOST_SYSROOT
)
set
(
HOST_SYSROOT $ENV{HOST_SYSROOT}
)
set
(
HOST_SYSROOT $ENV{HOST_SYSROOT}
)
endif
()
endif
()
if
(
NOT HOST_SYSROOT
)
if
(
HOST_SYSROOT
)
set
(
HOST_SYSROOT /opt/compiler/gcc-8.2
)
if
(
NOT IS_DIRECTORY
${
HOST_SYSROOT
}
)
endif
()
message
(
if
(
NOT IS_DIRECTORY
${
HOST_SYSROOT
}
)
FATAL_ERROR
message
(
"Directory
${
HOST_SYSROOT
}
not found, please export HOST_SYSROOT=<path_to_gcc>."
FATAL_ERROR
)
"Directory
${
HOST_SYSROOT
}
not found, please export HOST_SYSROOT=<path_to_gcc>."
endif
()
)
endif
()
endif
()
if
(
NOT DEFINED HOST_ARCH
)
if
(
NOT DEFINED HOST_ARCH
)
...
@@ -89,13 +88,12 @@ endif()
...
@@ -89,13 +88,12 @@ endif()
if
(
NOT DEFINED TOOLCHAIN_ARGS
)
if
(
NOT DEFINED TOOLCHAIN_ARGS
)
set
(
TOOLCHAIN_ARGS $ENV{TOOLCHAIN_ARGS}
)
set
(
TOOLCHAIN_ARGS $ENV{TOOLCHAIN_ARGS}
)
endif
()
endif
()
set
(
TOOLCHAIN_ARGS -isystem
${
HOST_SYSROOT
}
/include/c++/8.2.0 -isystem
/usr/include/ -isystem /usr/include/x86_64-linux-gnu
)
if
(
HOST_ARCH MATCHES
"x86_64"
)
if
(
HOST_ARCH MATCHES
"x86_64"
)
if
(
TARGET_ARCH MATCHES
"x86_64"
)
if
(
TARGET_ARCH MATCHES
"x86_64"
)
if
(
EXISTS
${
HOST_SYSROOT
}
/bin/g++
)
if
(
EXISTS
${
HOST_SYSROOT
}
/bin/g++
)
set
(
HOST_CXX
${
HOST_SYSROOT
}
/bin/g++
)
set
(
HOST_CXX
${
HOST_SYSROOT
}
/bin/g++
)
if
(
NOT EXISTS
${
HOST_SYSROOT
}
/bin/ar
)
set
(
HOST_AR
${
HOST_SYSROOT
}
/bin/ar
)
if
(
NOT EXISTS
${
HOST_AR
}
)
# try gcc-ar
# try gcc-ar
set
(
HOST_AR
${
HOST_SYSROOT
}
/bin/gcc-ar
)
set
(
HOST_AR
${
HOST_SYSROOT
}
/bin/gcc-ar
)
endif
()
endif
()
...
@@ -105,7 +103,7 @@ if(HOST_ARCH MATCHES "x86_64")
...
@@ -105,7 +103,7 @@ if(HOST_ARCH MATCHES "x86_64")
endif
()
endif
()
endif
()
endif
()
if
(
TARGET_ARCH MATCHES
"aarch64"
)
if
(
TARGET_ARCH MATCHES
"aarch64"
)
set
(
TOOLCHAIN_ARGS
--gcc-toolchain=
${
HOST_SYSROOT
}
)
set
(
TOOLCHAIN_ARGS
"
${
TOOLCHAIN_ARGS
}
--gcc-toolchain=
${
HOST_SYSROOT
}
"
)
set
(
HOST_SYSROOT
${
HOST_SYSROOT
}
/aarch64-linux-gnu/libc
)
set
(
HOST_SYSROOT
${
HOST_SYSROOT
}
/aarch64-linux-gnu/libc
)
set
(
HOST_CXX
${
CMAKE_CXX_COMPILER
}
)
set
(
HOST_CXX
${
CMAKE_CXX_COMPILER
}
)
set
(
HOST_AR
${
CMAKE_AR
}
)
set
(
HOST_AR
${
CMAKE_AR
}
)
...
@@ -130,6 +128,7 @@ message(STATUS "Build with HOST_SYSROOT=" ${HOST_SYSROOT})
...
@@ -130,6 +128,7 @@ message(STATUS "Build with HOST_SYSROOT=" ${HOST_SYSROOT})
message
(
STATUS
"Build with HOST_CXX="
${
HOST_CXX
}
)
message
(
STATUS
"Build with HOST_CXX="
${
HOST_CXX
}
)
message
(
STATUS
"Build with HOST_AR="
${
HOST_AR
}
)
message
(
STATUS
"Build with HOST_AR="
${
HOST_AR
}
)
separate_arguments
(
TOOLCHAIN_ARGS
)
# compile xpu kernel macro function
# compile xpu kernel macro function
macro
(
macro
(
compile_kernel
compile_kernel
...
@@ -303,9 +302,9 @@ foreach(xpu_wrapper IN LISTS xpu_wrappers)
...
@@ -303,9 +302,9 @@ foreach(xpu_wrapper IN LISTS xpu_wrappers)
${
xpu_wrapper
}
-I
${
XDNN_INC_DIR
}
-I
${
XRE_INC_DIR
}
${
xpu_wrapper
}
-I
${
XDNN_INC_DIR
}
-I
${
XRE_INC_DIR
}
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/include -I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/include -I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/wrapper -D_GNU_SOURCE
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/wrapper -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -DNDEBUG
--sysroot=
${
HOST_SYSROOT
}
${
TOOLCHAIN_ARGS
}
-D__STDC_LIMIT_MACROS -DNDEBUG
${
TOOLCHAIN_ARGS
}
--target=
${
TARGET_ARCH
}
-
-target=
${
TARGET_ARCH
}
-fPIC -Werror -Wreorder -fvisibility=hidden
-
fPIC -Werror -Wreorder -fvisibility=hidden --xpu-host-only
--xpu-host-only
${
XPU_MF_FLAGS
}
${
XPU_MF_FLAGS
}
COMMAND
COMMAND
${
CMAKE_COMMAND
}
-E cmake_depends
"Unix Makefiles"
${
CMAKE_SOURCE_DIR
}
${
CMAKE_COMMAND
}
-E cmake_depends
"Unix Makefiles"
${
CMAKE_SOURCE_DIR
}
${
CMAKE_SOURCE_DIR
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_SOURCE_DIR
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
...
@@ -325,9 +324,9 @@ foreach(xpu_wrapper IN LISTS xpu_wrappers)
...
@@ -325,9 +324,9 @@ foreach(xpu_wrapper IN LISTS xpu_wrappers)
-I
${
XDNN_INC_DIR
}
-I
${
XRE_INC_DIR
}
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
-I
${
XDNN_INC_DIR
}
-I
${
XRE_INC_DIR
}
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/wrapper -D_GNU_SOURCE
-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/wrapper -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -DNDEBUG
--sysroot=
${
HOST_SYSROOT
}
${
TOOLCHAIN_ARGS
}
-D__STDC_LIMIT_MACROS -DNDEBUG
${
TOOLCHAIN_ARGS
}
--target=
${
TARGET_ARCH
}
-
-target=
${
TARGET_ARCH
}
-fPIC -Wunused-variable -Werror -Wreorder
-
fPIC -Wunused-variable -Werror -Wreorder -fvisibility=hidden
-
fvisibility=hidden -
-xpu-host-only
${
HOST_XPU_FLAGS
}
--xpu-host-only
${
HOST_XPU_FLAGS
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
DEPENDS wrapper_build/
${
wrapper_name
}
.wrapper.d
DEPENDS wrapper_build/
${
wrapper_name
}
.wrapper.d
COMMENT wrapper_build/
${
wrapper_name
}
.wrapper.o
COMMENT wrapper_build/
${
wrapper_name
}
.wrapper.o
...
...
paddle/phi/kernels/xpu/plugin/build.sh
浏览文件 @
613beeb6
...
@@ -16,10 +16,10 @@
...
@@ -16,10 +16,10 @@
set
-e
set
-e
export
XDNN_PATH
=
/opt/xdnn
# <path_to_xdnn>
#
export XDNN_PATH=/opt/xdnn # <path_to_xdnn>
export
XRE_PATH
=
/opt/xre
# <path_to_xre>
#
export XRE_PATH=/opt/xre # <path_to_xre>
export
CLANG_PATH
=
/opt/xtdk
# <path_to_xtdk>
#
export CLANG_PATH=/opt/xtdk # <path_to_xtdk>
export
HOST_SYSROOT
=
/opt/compiler/gcc-8.2
# <path_to_gcc>
#
export HOST_SYSROOT=/opt/compiler/gcc-8.2 # <path_to_gcc>
rm
-rf
build
rm
-rf
build
mkdir
build
mkdir
build
...
...
paddle/phi/kernels/xpu/plugin/example/CMakeLists.txt
浏览文件 @
613beeb6
cmake_minimum_required
(
VERSION 3.1
6
)
cmake_minimum_required
(
VERSION 3.1
0
)
project
(
example LANGUAGES CXX
)
project
(
example LANGUAGES CXX
)
...
...
paddle/phi/kernels/xpu/plugin/example/build.sh
浏览文件 @
613beeb6
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
set
-e
set
-e
export
XDNN_PATH
=
/opt/xdnn
# <path_to_xdnn>
#
export XDNN_PATH=/opt/xdnn # <path_to_xdnn>
export
XRE_PATH
=
/opt/xre
# <path_to_xre>
#
export XRE_PATH=/opt/xre # <path_to_xre>
export
LINK_TYPE
=
static
# shared/static
export
LINK_TYPE
=
static
# shared/static
rm
-rf
build
rm
-rf
build
...
...
paddle/phi/kernels/xpu/plugin/example/run.sh
浏览文件 @
613beeb6
...
@@ -16,10 +16,20 @@
...
@@ -16,10 +16,20 @@
set
-e
set
-e
XDNN_PATH
=
/opt/xdnn
# <path_to_xdnn>
#
XDNN_PATH=/opt/xdnn # <path_to_xdnn>
XRE_PATH
=
/opt/xre
# <path_to_xre>
#
XRE_PATH=/opt/xre # <path_to_xre>
:<<
!
if
[[
"
$XDNN_PATH
"
==
""
]]
||
[[
!
-d
"
$XDNN_PATH
"
]]
;
then
echo
"XDNN_PATH not set, or directory
${
XDNN_PATH
}
not found, please export XDNN_PATH=<path_to_xdnn>."
exit
-1
fi
if
[[
"
$XRE_PATH
"
==
""
]]
||
[[
!
-d
"
$XRE_PATH
"
]]
;
then
echo
"XRE_PATH not set, or directory
${
XRE_PATH
}
not found, please export XRE_PATH=<path_to_xre>."
exit
-1
fi
#:<<!
export
GLOG_v
=
0
export
GLOG_v
=
0
export
XPU_VISIBLE_DEVICES
=
0
;
export
XPU_VISIBLE_DEVICES
=
0
;
export
XPUAPI_DEBUG
=
1
;
export
XPUAPI_DEBUG
=
1
;
...
@@ -27,9 +37,9 @@ export LD_LIBRARY_PATH=$XDNN_PATH/so:$XRE_PATH/so:$LD_LIBRARY_PATH
...
@@ -27,9 +37,9 @@ export LD_LIBRARY_PATH=$XDNN_PATH/so:$XRE_PATH/so:$LD_LIBRARY_PATH
chmod
+x ./build/example
chmod
+x ./build/example
./build/example
./build/example
!
#
!
#
:<<!
:<<
!
SSH_IP_ADDR
=
localhost
SSH_IP_ADDR
=
localhost
SSH_PORT
=
9031
SSH_PORT
=
9031
SSH_USR_ID
=
root
SSH_USR_ID
=
root
...
@@ -46,4 +56,4 @@ sshpass -p $SSH_USR_PWD scp -v -r -o ConnectTimeout=60 -o StrictHostKeyChecking=
...
@@ -46,4 +56,4 @@ sshpass -p $SSH_USR_PWD scp -v -r -o ConnectTimeout=60 -o StrictHostKeyChecking=
sshpass
-p
$SSH_USR_PWD
scp
-v
-r
-o
ConnectTimeout
=
60
-o
StrictHostKeyChecking
=
no
-P
$SSH_PORT
../build/libxpuplugin.so
$SSH_USR_ID
@
$SSH_IP_ADDR
:
$WORK_SPACE
sshpass
-p
$SSH_USR_PWD
scp
-v
-r
-o
ConnectTimeout
=
60
-o
StrictHostKeyChecking
=
no
-P
$SSH_PORT
../build/libxpuplugin.so
$SSH_USR_ID
@
$SSH_IP_ADDR
:
$WORK_SPACE
sshpass
-p
$SSH_USR_PWD
scp
-v
-r
-o
ConnectTimeout
=
60
-o
StrictHostKeyChecking
=
no
-P
$SSH_PORT
build/example
$SSH_USR_ID
@
$SSH_IP_ADDR
:
$WORK_SPACE
sshpass
-p
$SSH_USR_PWD
scp
-v
-r
-o
ConnectTimeout
=
60
-o
StrictHostKeyChecking
=
no
-P
$SSH_PORT
build/example
$SSH_USR_ID
@
$SSH_IP_ADDR
:
$WORK_SPACE
sshpass
-p
$SSH_USR_PWD
ssh
-v
-o
ConnectTimeout
=
60
-o
StrictHostKeyChecking
=
no
-p
$SSH_PORT
$SSH_USR_ID
@
$SSH_IP_ADDR
"cd
$WORK_SPACE
;
${
EXPORT_ENVIRONMENT_VARIABLES
}
chmod +x ./example; ./example"
sshpass
-p
$SSH_USR_PWD
ssh
-v
-o
ConnectTimeout
=
60
-o
StrictHostKeyChecking
=
no
-p
$SSH_PORT
$SSH_USR_ID
@
$SSH_IP_ADDR
"cd
$WORK_SPACE
;
${
EXPORT_ENVIRONMENT_VARIABLES
}
chmod +x ./example; ./example"
#
!
!
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录