Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c914f636
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
c914f636
编写于
5月 02, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add toolchain for raspberry pi.
上级
af80ff94
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
126 addition
and
30 deletion
+126
-30
cmake/cross_compiling/android.cmake
cmake/cross_compiling/android.cmake
+18
-23
cmake/cross_compiling/host.cmake
cmake/cross_compiling/host.cmake
+2
-2
cmake/cross_compiling/raspberry_pi.cmake
cmake/cross_compiling/raspberry_pi.cmake
+95
-0
cmake/external/openblas.cmake
cmake/external/openblas.cmake
+8
-5
cmake/system.cmake
cmake/system.cmake
+3
-0
未找到文件。
cmake/cross_compiling/android.cmake
浏览文件 @
c914f636
...
...
@@ -17,12 +17,11 @@
# https://github.com/taka-no-me/android-cmake
# Most of the variables are compatible with that used in
# https://developer.android.com/ndk/guides/cmake.html
# The supported are listed belows:
# The supported
variables
are listed belows:
#
# ANDROID_STANDALONE_TOOLCHAIN
# ANDROID_ABI
# ANDROID_NATIVE_API_LEVEL
# ANDROID_PLATFORM
# ANDROID_ARM_MODE
# ANDROID_ARM_NEON
#
...
...
@@ -41,22 +40,21 @@ IF(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN)
CACHE PATH
"Folder holds the standalone toolchain of Android NDK"
)
ENDIF
()
IF
(
NOT ANDROID_STANDALONE_TOOLCHAIN
)
MESSAGE
(
WARNING
"It is recommened to set ANDROID_STANDALONE_TOOLCHAIN to "
MESSAGE
(
WARNING
"It is recommen
d
ed to set ANDROID_STANDALONE_TOOLCHAIN to "
"use a standalone toolchain.
\n
"
"To cross-compile for Android, you need to:
\n
"
"1. Download an Android NDK from"
" https://developer.android.com/ndk/downloads/index.html
\n
"
"2. Setup a standalone toolchain"
"
https://developer.android.google.cn/ndk/guides/standalone_toolchain.html?hl=zh-c
n"
)
"
https://developer.android.google.cn/ndk/guides/standalone_toolchain.html?hl=zh-cn
\
n
"
)
ENDIF
()
IF
(
DEFINE
D ANDROID_NATIVE_API_LEVEL
)
IF
(
NOT DEFINED CMAKE_SYSTEM_VERSION AN
D ANDROID_NATIVE_API_LEVEL
)
IF
(
ANDROID_NATIVE_API_LEVEL MATCHES
"^android-[0-9]+$"
)
STRING
(
REPLACE
"android-"
""
CMAKE_SYSTEM_VERSION
"
${
CMAKE_MATCH_0
}
"
)
ELSEIF
(
ANDROID_NATIVE_API_LEVEL MATCHES
"^[0-9]+$"
)
SET
(
CMAKE_SYSTEM_VERSION
${
ANDROID_NATIVE_API_LEVEL
}
)
ENDIF
()
SET
(
ANDROID_PLATFORM android-
${
CMAKE_SYSTEM_VERSION
}
)
ENDIF
()
IF
(
NOT DEFINED ANDROID_ABI
)
...
...
@@ -66,13 +64,11 @@ ENDIF()
IF
(
NOT DEFINED ANDROID_ARM_MODE
)
SET
(
ANDROID_ARM_MODE ON
)
ENDIF
()
IF
(
NOT ANDROID_ARM_MODE OR ANDROID_ARM_MODE STREQUAL
"thumb"
)
SET
(
ANDROID_ARM_MODE OFF
)
SET
(
ANDROID_ARM_MODE_NAME
"thumb"
)
ELSEIF
(
ANDROID_ARM_MODE OR ANDROID_ARM_MODE STREQUAL
"arm"
)
SET
(
ANDROID_ARM_MODE ON
)
IF
(
ANDROID_ARM_MODE
)
SET
(
ANDROID_ARM_MODE_NAME
"arm"
)
ENDIF
()
ELSE
(
ANDROID_ARM_MODE
)
SET
(
ANDROID_ARM_MODE_NAME
"thumb"
)
ENDIF
(
ANDROID_ARM_MODE
)
IF
(
NOT DEFINED ANDROID_ARM_NEON
)
SET
(
ANDROID_ARM_NEON ON
)
...
...
@@ -117,30 +113,27 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.7.0")
IF
(
NOT CMAKE_C_COMPILER
)
SET
(
ANDROID_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_C_COMPILER_PATH
${
CMAKE_C_COMPILER
}
PROGRAM
)
SET
(
ANDROID_C_COMPILER
${
ANDROID_C_COMPILER_PATH
}
)
GET_FILENAME_COMPONENT
(
ANDROID_C_COMPILER
${
CMAKE_C_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_C_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot f
ou
nd C compiler:
${
ANDROID_C_COMPILER
}
"
)
MESSAGE
(
FATAL_ERROR
"Cannot f
i
nd C compiler:
${
ANDROID_C_COMPILER
}
"
)
ENDIF
()
# CXX compiler
IF
(
NOT CMAKE_CXX_COMPILER
)
SET
(
ANDROID_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_CXX_COMPILER_PATH
${
CMAKE_CXX_COMPILER
}
PROGRAM
)
SET
(
ANDROID_CXX_COMPILER
${
ANDROID_CXX_COMPILER_PATH
}
)
GET_FILENAME_COMPONENT
(
ANDROID_CXX_COMPILER
${
CMAKE_CXX_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_CXX_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot f
ou
nd CXX compiler:
${
ANDROID_CXX_COMPILER
}
"
)
MESSAGE
(
FATAL_ERROR
"Cannot f
i
nd CXX compiler:
${
ANDROID_CXX_COMPILER
}
"
)
ENDIF
()
# Fortran compiler
IF
(
NOT CMAKE_Fortran_COMPILER
)
SET
(
ANDROID_Fortran_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gfortran"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_Fortran_COMPILER_PATH
${
CMAKE_Fortran_COMPILER
}
)
SET
(
ANDROID_Fortran_COMPILER
${
ANDROID_Fortran_COMPILER_PATH
}
)
GET_FILENAME_COMPONENT
(
ANDROID_Fortran_COMPILER
${
CMAKE_Fortran_COMPILER
}
)
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_Fortran_COMPILER
}
)
SET
(
ANDROID_Fortran_COMPILER
""
)
...
...
@@ -184,9 +177,9 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.7.0")
STRING
(
REPLACE
";"
" "
ANDROID_LINKER_FLAGS
"
${
ANDROID_LINKER_FLAGS
}
"
)
SET
(
CMAKE_C_FLAGS
"
${
ANDROID_COMPILER_FLAGS
}
${
CMAKE_C_FLAGS
}
"
CACHE STRING
"
c
flags"
)
CACHE STRING
"
C
flags"
)
SET
(
CMAKE_CXX_FLAGS
"
${
ANDROID_COMPILER_FLAGS
}
${
CMAKE_CXX_FLAGS
}
"
CACHE STRING
"
c++
flags"
)
CACHE STRING
"
CXX
flags"
)
SET
(
CMAKE_SHARED_LINKER_FLAGS
"
${
ANDROID_LINKER_FLAGS
}
${
CMAKE_SHARED_LINKER_FLAGS
}
"
CACHE STRING
"shared linker flags"
)
...
...
@@ -200,7 +193,9 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.7.0")
MESSAGE
(
STATUS
"System CMAKE_C_FLAGS: "
${
CMAKE_C_FLAGS
}
)
MESSAGE
(
STATUS
"System CMAKE_CXX_FLAGS: "
${
CMAKE_CXX_FLAGS
}
)
ELSE
()
IF
(
ANDROID_STANDALONE_TOOLCHAIN
)
SET
(
CMAKE_ANDROID_STANDALONE_TOOLCHAIN
${
ANDROID_STANDALONE_TOOLCHAIN
}
)
ENDIF
()
SET
(
CMAKE_ANDROID_ARCH_ABI
${
ANDROID_ABI
}
)
SET
(
CMAKE_ANDROID_ARM_MODE
${
ANDROID_ARM_MODE
}
)
SET
(
CMAKE_ANDROID_ARM_NEON
${
ANDROID_ARM_NEON
}
)
...
...
cmake/cross_compiling/host.cmake
浏览文件 @
c914f636
...
...
@@ -23,7 +23,7 @@ ENDIF()
GET_FILENAME_COMPONENT
(
HOST_C_COMPILER_PATH
${
HOST_C_COMPILER_NAME
}
PROGRAM
)
IF
(
NOT HOST_C_COMPILER_PATH OR NOT EXISTS
${
HOST_C_COMPILER_PATH
}
)
MESSAGE
(
FATAL_ERROR
"Cannot f
ou
nd host C compiler, set host C compiler:
\n
"
MESSAGE
(
FATAL_ERROR
"Cannot f
i
nd host C compiler, set host C compiler:
\n
"
"
\t
cmake .. -DHOST_C_COMPILER=..."
)
ENDIF
()
...
...
@@ -38,7 +38,7 @@ ENDIF()
GET_FILENAME_COMPONENT
(
HOST_CXX_COMPILER_PATH
${
HOST_CXX_COMPILER_NAME
}
PROGRAM
)
IF
(
NOT HOST_CXX_COMPILER_PATH OR NOT EXISTS
${
HOST_CXX_COMPILER_PATH
}
)
MESSAGE
(
FATAL_ERROR
"Cannot f
ou
nd host CXX compiler, set host CXX compiler:
\n
"
MESSAGE
(
FATAL_ERROR
"Cannot f
i
nd host CXX compiler, set host CXX compiler:
\n
"
"
\t
cmake .. -DHOST_CXX_COMPILER=..."
)
ENDIF
()
...
...
cmake/cross_compiling/raspberry_pi.cmake
0 → 100644
浏览文件 @
c914f636
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
#
# 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.
# This is a toolchain file for cross-compiling for Raspberry Pi.
# The supported variables are listed belows:
#
# RPI_TOOLCHAIN
# RPI_ARM_NEON
#
# Also you can set CMAKE_C/CXX_COMPILER yourself, through cmake arguments.
IF
(
NOT RPI
)
return
()
ENDIF
()
SET
(
CMAKE_SYSTEM_NAME Linux
)
SET
(
CMAKE_SYSTEM_VERSION 1
)
SET
(
CMAKE_SYSTEM_PROCESSOR arm
)
# check the exist of raspberry pi toolchain
IF
(
NOT DEFINED RPI_TOOLCHAIN
)
SET
(
RPI_TOOLCHAIN $ENV{RPI_TOOLCHAIN}
CACHE PATH
"Folder holds the toolchain of Raspberr Pi"
)
ENDIF
()
IF
(
NOT RPI_TOOLCHAIN
)
MESSAGE
(
WARNING
"It is recommended to set RPI_TOOLCHAIN to use toolchain.
\n
"
"To cross-compile for Raspberry Pi, you need to download the tools using:
\n
"
" git clone https://github.com/raspberrypi/tools
\n
"
)
ENDIF
()
IF
(
NOT DEFINED RPI_ARM_NEON
)
SET
(
RPI_ARM_NEON ON
)
ENDIF
()
IF
(
RPI_TOOLCHAIN
)
SET
(
RPI_TOOLCHAIN_ROOT
${
RPI_TOOLCHAIN
}
)
IF
(
RPI_TOOLCHAIN_ROOT MATCHES
"gcc-linaro-arm-linux-gnueabihf-raspbian(-x64)?$"
)
# gcc-linaro-arm-linux-gnueabihf-raspbian
# gcc-linaro-arm-linux-gnueabihf-raspbian-x64
SET
(
RPI_TOOLCHAIN_NAME arm-linux-gnueabihf
)
ENDIF
()
SET
(
RPI_TOOLCHAIN_PREFIX
"
${
RPI_TOOLCHAIN_ROOT
}
/bin/
${
RPI_TOOLCHAIN_NAME
}
-"
)
ENDIF
()
# C compiler
IF
(
NOT CMAKE_C_COMPILER
)
SET
(
RPI_C_COMPILER
"
${
RPI_TOOLCHAIN_PREFIX
}
gcc"
)
ELSE
()
GET_FILENAME_COMPONENT
(
RPI_C_COMPILER
${
CMAKE_C_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
RPI_C_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find C compiler:
${
RPI_C_COMPILER
}
"
)
ENDIF
()
# CXX compiler
IF
(
NOT CMAKE_CXX_COMPILER
)
SET
(
RPI_CXX_COMPILER
"
${
RPI_TOOLCHAIN_PREFIX
}
g++"
)
ELSE
()
GET_FILENAME_COMPONENT
(
RPI_CXX_COMPILER
${
CMAKE_CXX_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
RPI_CXX_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find CXX compiler:
${
RPI_CXX_COMPILER
}
"
)
ENDIF
()
# Fortran compiler
IF
(
NOT CMAKE_Fortran_COMPILER
)
SET
(
RPI_Fortran_COMPILER
"
${
RPI_TOOLCHAIN_PREFIX
}
gfortran"
)
ELSE
()
GET_FILENAME_COMPONENT
(
RPI_Fortran_COMPILER
${
CMAKE_Fortran_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS RPI_Fortran_COMPILER
)
SET
(
RPI_Fortran_COMPILER
""
)
ENDIF
()
SET
(
CMAKE_C_COMPILER
${
RPI_C_COMPILER
}
CACHE PATH
"C compiler"
FORCE
)
SET
(
CMAKE_CXX_COMPILER
${
RPI_CXX_COMPILER
}
CACHE PATH
"CXX compiler"
FORCE
)
SET
(
CMAKE_Fortran_COMPILER
${
RPI_Fortran_COMPILER
}
CACHE PATH
"Fortran compiler"
FORCE
)
IF
(
RPI_ARM_NEON
)
SET
(
RPI_C_FLAGS
"
${
RPI_C_FLAGS
}
-mfpu=neon"
)
ENDIF
()
SET
(
CMAKE_C_FLAGS
"
${
RPI_C_FLAGS
}
${
CMAKE_C_FLAGS
}
"
CACHE STRING
"C flags"
)
SET
(
CMAKE_CXX_FLAGS
"
${
RPI_C_FLAGS
}
${
CMAKE_CXX_FLAGS
}
"
CACHE STRING
"CXX flags"
)
cmake/external/openblas.cmake
浏览文件 @
c914f636
...
...
@@ -25,7 +25,13 @@ IF(NOT ${CBLAS_FOUND})
CACHE FILEPATH
"openblas library."
FORCE
)
# check fortran compiler and library
IF
(
NOT ANDROID
)
IF
(
ANDROID
)
SET
(
OPENBLAS_COMMIT
"b5c96fcfcdc82945502a2303116a64d89985daf5"
)
SET
(
OPTIONAL_ARGS HOSTCC=
${
HOST_C_COMPILER
}
TARGET=ARMV7 ARM_SOFTFP_ABI=1 NOFORTRAN=1 USE_THREAD=0 libs
)
ELSEIF
(
RPI
)
SET
(
OPENBLAS_COMMIT
"v0.2.19"
)
SET
(
OPTIONAL_ARGS HOSTCC=
${
HOST_C_COMPILER
}
TARGET=ARMV7 NOFORTRAN=1 USE_THREAD=0 libs
)
ELSE
()
IF
(
CMAKE_COMPILER_IS_GNUCC
)
ENABLE_LANGUAGE
(
Fortran
)
if
(
NOT CMAKE_Fortran_COMPILER_VERSION
)
...
...
@@ -57,9 +63,6 @@ IF(NOT ${CBLAS_FOUND})
SET
(
OPENBLAS_COMMIT
"v0.2.19"
)
SET
(
OPENBLAS_ARGS FC=
${
CMAKE_Fortran_COMPILER
}
DYNAMIC_ARCH=1 libs netlib
)
ELSE
()
SET
(
OPENBLAS_COMMIT
"b5c96fcfcdc82945502a2303116a64d89985daf5"
)
SET
(
OPTIONAL_ARGS HOSTCC=
${
HOST_C_COMPILER
}
TARGET=ARMV7 ARM_SOFTFP_ABI=1 NOFORTRAN=1 USE_THREAD=0 libs
)
ENDIF
()
ExternalProject_Add
(
...
...
@@ -76,7 +79,7 @@ IF(NOT ${CBLAS_FOUND})
CONFIGURE_COMMAND
""
)
IF
(
NOT ANDROID
)
IF
(
NOT ANDROID
AND NOT RPI
)
ExternalProject_Add_Step
(
openblas lapacke_install
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke_mangling_with_flags.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke_mangling.h"
...
...
cmake/system.cmake
浏览文件 @
c914f636
...
...
@@ -78,6 +78,9 @@ IF(DEFINED CMAKE_SYSTEM_NAME)
IF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Android"
)
SET
(
ANDROID TRUE
)
INCLUDE
(
cross_compiling/android
)
ELSEIF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"RPi"
)
SET
(
RPI TRUE
)
INCLUDE
(
cross_compiling/raspberry_pi
)
ENDIF
()
ENDIF
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录