Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
8e5f5432
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8e5f5432
编写于
9月 04, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine the toolchain file of Android to use clang as default compiler.
上级
79397053
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
53 addition
and
35 deletion
+53
-35
cmake/cross_compiling/android.cmake
cmake/cross_compiling/android.cmake
+53
-20
cmake/external/warpctc.cmake
cmake/external/warpctc.cmake
+0
-1
paddle/math/Matrix.cpp
paddle/math/Matrix.cpp
+0
-5
paddle/scripts/docker/build_android.sh
paddle/scripts/docker/build_android.sh
+0
-9
未找到文件。
cmake/cross_compiling/android.cmake
浏览文件 @
8e5f5432
...
...
@@ -20,6 +20,7 @@
# The supported variables are listed belows:
#
# ANDROID_STANDALONE_TOOLCHAIN
# ANDROID_TOOLCHAIN
# ANDROID_ABI
# ANDROID_NATIVE_API_LEVEL
# ANDROID_ARM_MODE
...
...
@@ -57,6 +58,10 @@ IF(NOT DEFINED CMAKE_SYSTEM_VERSION AND ANDROID_NATIVE_API_LEVEL)
ENDIF
()
ENDIF
()
IF
(
NOT DEFINED ANDROID_TOOLCHAIN
)
SET
(
ANDROID_TOOLCHAIN clang
)
ENDIF
()
IF
(
NOT DEFINED ANDROID_ABI
)
SET
(
ANDROID_ABI
"armeabi-v7a"
)
ENDIF
()
...
...
@@ -82,6 +87,7 @@ IF("${CMAKE_VERSION}" VERSION_LESS "3.7.0")
"
${
CMAKE_VERSION
}
), when cross-compiling for Android."
)
IF
(
ANDROID_STANDALONE_TOOLCHAIN
)
# Use standalone toolchain
SET
(
CMAKE_SYSROOT
"
${
ANDROID_STANDALONE_TOOLCHAIN
}
/sysroot"
)
IF
(
NOT CMAKE_SYSTEM_VERSION
)
...
...
@@ -96,26 +102,44 @@ IF("${CMAKE_VERSION}" VERSION_LESS "3.7.0")
ENDIF
()
# Toolchain
SET
(
ANDROID_TOOLCHAIN
"gcc"
)
SET
(
ANDROID_TOOLCHAIN_ROOT
${
ANDROID_STANDALONE_TOOLCHAIN
}
)
ELSE
(
ANDROID_NDK
)
# TODO: use android ndk
ENDIF
()
IF
(
ANDROID_ABI MATCHES
"^armeabi(-v7a)?$"
)
SET
(
ANDROID_TOOLCHAIN_NAME arm-linux-androideabi
)
IF
(
ANDROID_ABI STREQUAL
"armeabi"
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv5te
)
SET
(
ANDROID_CLANG_TRIPLE armv5te-none-linux-androideabi
)
ELSEIF
(
ANDROID_ABI STREQUAL
"armeabi-v7a"
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv7-a
)
SET
(
ANDROID_CLANG_TRIPLE armv7-none-linux-androideabi
)
ENDIF
()
ENDIF
()
IF
(
ANDROID_ABI STREQUAL
"arm64-v8a"
)
ELSEIF
(
ANDROID_ABI STREQUAL
"arm64-v8a"
)
SET
(
ANDROID_TOOLCHAIN_NAME aarch64-linux-android
)
SET
(
CMAKE_SYSTEM_PROCESSOR aarch64
)
SET
(
ANDROID_CLANG_TRIPLE aarch64-none-linux-android
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Invalid Android ABI:
${
ANDROID_ABI
}
."
)
ENDIF
()
SET
(
ANDROID_TOOLCHAIN_PREFIX
"
${
ANDROID_TOOLCHAIN_ROOT
}
/bin/
${
ANDROID_TOOLCHAIN_NAME
}
-"
)
IF
(
ANDROID_TOOLCHAIN STREQUAL clang
)
SET
(
ANDROID_C_COMPILER_NAME clang
)
SET
(
ANDROID_CXX_COMPILER_NAME clang++
)
SET
(
CMAKE_C_COMPILER_TARGET
${
ANDROID_CLANG_TRIPLE
}
)
SET
(
CMAKE_CXX_COMPILER_TARGET
${
ANDROID_CLANG_TRIPLE
}
)
ELSEIF
(
ANDROID_TOOLCHAIN STREQUAL gcc
)
SET
(
ANDROID_C_COMPILER_NAME gcc
)
SET
(
ANDROID_CXX_COMPILER_NAME g++
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Invalid Android toolchain:
${
ANDROID_TOOLCHAIN
}
"
)
ENDIF
()
# C compiler
IF
(
NOT CMAKE_C_COMPILER
)
SET
(
ANDROID_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc
"
)
SET
(
ANDROID_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
${
ANDROID_C_COMPILER_NAME
}
"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_C_COMPILER
${
CMAKE_C_COMPILER
}
PROGRAM
)
ENDIF
()
...
...
@@ -125,7 +149,7 @@ IF("${CMAKE_VERSION}" VERSION_LESS "3.7.0")
# CXX compiler
IF
(
NOT CMAKE_CXX_COMPILER
)
SET
(
ANDROID_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++
"
)
SET
(
ANDROID_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
${
ANDROID_CXX_COMPILER_NAME
}
"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_CXX_COMPILER
${
CMAKE_CXX_COMPILER
}
PROGRAM
)
ENDIF
()
...
...
@@ -137,7 +161,7 @@ IF("${CMAKE_VERSION}" VERSION_LESS "3.7.0")
SET
(
CMAKE_CXX_COMPILER
${
ANDROID_CXX_COMPILER
}
CACHE PATH
"CXX compiler"
FORCE
)
# Toolchain and ABI specific flags.
SET
(
ANDROID_COMPILER_FLAGS
"-ffunction-sections -fdata-sections
-finline-limit=64
"
)
SET
(
ANDROID_COMPILER_FLAGS
"-ffunction-sections -fdata-sections"
)
SET
(
ANDROID_LINKER_FLAGS
"-Wl,--gc-sections"
)
IF
(
ANDROID_ABI STREQUAL
"armeabi"
)
...
...
@@ -145,8 +169,7 @@ IF("${CMAKE_VERSION}" VERSION_LESS "3.7.0")
-march=armv5te
-mtune=xscale
-msoft-float
)
ENDIF
()
IF
(
ANDROID_ABI STREQUAL
"armeabi-v7a"
)
ELSEIF
(
ANDROID_ABI STREQUAL
"armeabi-v7a"
)
LIST
(
APPEND ANDROID_COMPILER_FLAGS
-march=armv7-a
-mfloat-abi=softfp
)
...
...
@@ -156,6 +179,8 @@ IF("${CMAKE_VERSION}" VERSION_LESS "3.7.0")
LIST
(
APPEND ANDROID_COMPILER_FLAGS -mfpu=vfpv3-d16
)
ENDIF
()
LIST
(
APPEND ANDROID_LINKER_FLAGS -Wl,--fix-cortex-a8
)
ELSEIF
(
ANDROID_ABI STREQUAL
"arm64-v8a"
)
LIST
(
APPEND ANDROID_COMPILER_FLAGS -march=armv8-a
)
ENDIF
()
IF
(
ANDROID_ABI MATCHES
"^armeabi(-v7a)?$"
)
...
...
@@ -164,10 +189,18 @@ IF("${CMAKE_VERSION}" VERSION_LESS "3.7.0")
ELSE
()
LIST
(
APPEND ANDROID_COMPILER_FLAGS -mthumb
)
ENDIF
()
IF
(
ANDROID_TOOLCHAIN STREQUAL clang
)
# Disable integrated-as for better compatibility.
LIST
(
APPEND ANDROID_COMPILER_FLAGS -fno-integrated-as
)
ENDIF
()
ENDIF
()
IF
(
ANDROID_ABI STREQUAL
"arm64-v8a"
)
LIST
(
APPEND ANDROID_COMPILER_FLAGS -march=armv8-a
)
IF
(
ANDROID_TOOLCHAIN STREQUAL clang
)
# CMake automatically forwards all compiler flags to the linker,
# and clang doesn't like having -Wa flags being used for linking.
# To prevent CMake from doing this would require meddling with
# the CMAKE_<LANG>_COMPILE_OBJECT rules, which would get quite messy.
LIST
(
APPEND ANDROID_LINKER_FLAGS -Qunused-arguments
)
ENDIF
()
STRING
(
REPLACE
";"
" "
ANDROID_COMPILER_FLAGS
"
${
ANDROID_COMPILER_FLAGS
}
"
)
...
...
cmake/external/warpctc.cmake
浏览文件 @
8e5f5432
...
...
@@ -41,7 +41,6 @@ IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "App
ELSE
()
SET
(
USE_OMP ON
)
ENDIF
()
SET
(
USE_OMP OFF FORCE
)
ExternalProject_Add
(
extern_warpctc
...
...
paddle/math/Matrix.cpp
浏览文件 @
8e5f5432
...
...
@@ -2774,28 +2774,23 @@ void CpuMatrix::mul(CpuMatrix* a, CpuMatrix* b, real scaleAB, real scaleT) {
CHECK
(
!
isTransposed
())
<<
"Not supported"
;
size_t
a_col
,
b_col
,
a_row
,
b_row
;
// CBLAS_TRANSPOSE a_trans, b_trans;
bool
a_trans
,
b_trans
;
if
(
!
a
->
isTransposed
())
{
a_col
=
a
->
getWidth
();
a_row
=
a
->
getHeight
();
// a_trans = CblasNoTrans;
a_trans
=
false
;
}
else
{
a_col
=
a
->
getHeight
();
a_row
=
a
->
getWidth
();
// a_trans = CblasTrans;
a_trans
=
true
;
}
if
(
!
b
->
isTransposed
())
{
b_col
=
b
->
getWidth
();
b_row
=
b
->
getHeight
();
// b_trans = CblasNoTrans;
b_trans
=
false
;
}
else
{
b_col
=
b
->
getHeight
();
b_row
=
b
->
getWidth
();
// b_trans = CblasTrans;
b_trans
=
true
;
}
...
...
paddle/scripts/docker/build_android.sh
浏览文件 @
8e5f5432
...
...
@@ -9,20 +9,15 @@ rm -rf $BUILD_ROOT 2>/dev/null || true
mkdir
-p
$BUILD_ROOT
cd
$BUILD_ROOT
THIRD_PARTY_PATH
=
/paddle/third_party_android
$SUFFIX
/
$ANDROID_ABI
if
[
$ANDROID_ABI
==
"armeabi-v7a"
]
;
then
cmake
-DCMAKE_SYSTEM_NAME
=
Android
\
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_ARM_STANDALONE_TOOLCHAIN
\
-DANDROID_ABI
=
$ANDROID_ABI
\
-DANDROID_ARM_NEON
=
ON
\
-DANDROID_ARM_MODE
=
ON
\
-DCMAKE_C_COMPILER
=
$ANDROID_ARM_STANDALONE_TOOLCHAIN
/bin/arm-linux-androideabi-clang
\
-DCMAKE_CXX_COMPILER
=
$ANDROID_ARM_STANDALONE_TOOLCHAIN
/bin/arm-linux-androideabi-clang++
\
-DHOST_C_COMPILER
=
/usr/bin/gcc
\
-DHOST_CXX_COMPILER
=
/usr/bin/g++
\
-DCMAKE_INSTALL_PREFIX
=
$DEST_ROOT
\
-DTHIRD_PARTY_PATH
=
$THIRD_PARTY_PATH
\
-DCMAKE_BUILD_TYPE
=
Release
\
-DUSE_EIGEN_FOR_BLAS
=
ON
\
-DWITH_C_API
=
ON
\
...
...
@@ -34,12 +29,9 @@ elif [ $ANDROID_ABI == "arm64-v8a" ]; then
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_ARM64_STANDALONE_TOOLCHAIN
\
-DANDROID_ABI
=
$ANDROID_ABI
\
-DANDROID_ARM_MODE
=
ON
\
-DCMAKE_C_COMPILER
=
$ANDROID_ARM64_STANDALONE_TOOLCHAIN
/bin/aarch64-linux-android-clang
\
-DCMAKE_CXX_COMPILER
=
$ANDROID_ARM64_STANDALONE_TOOLCHAIN
/bin/aarch64-linux-android-clang++
\
-DHOST_C_COMPILER
=
/usr/bin/gcc
\
-DHOST_CXX_COMPILER
=
/usr/bin/g++
\
-DCMAKE_INSTALL_PREFIX
=
$DEST_ROOT
\
-DTHIRD_PARTY_PATH
=
$THIRD_PARTY_PATH
\
-DCMAKE_BUILD_TYPE
=
Release
\
-DUSE_EIGEN_FOR_BLAS
=
OFF
\
-DWITH_C_API
=
ON
\
...
...
@@ -53,7 +45,6 @@ elif [ $ANDROID_ABI == "armeabi" ]; then
-DHOST_C_COMPILER
=
/usr/bin/gcc
\
-DHOST_CXX_COMPILER
=
/usr/bin/g++
\
-DCMAKE_INSTALL_PREFIX
=
/paddle/install
\
-DTHIRD_PARTY_PATH
=
$THIRD_PARTY_PATH
\
-DCMAKE_BUILD_TYPE
=
Release
\
-DWITH_C_API
=
ON
\
-DWITH_SWIG_PY
=
OFF
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录