Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wmsofts
Paddle
提交
1b856420
P
Paddle
项目概览
wmsofts
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1b856420
编写于
3月 29, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use native cross-compiling support for Android of cmake.
上级
bb4a60d9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
45 addition
and
31 deletion
+45
-31
CMakeLists.txt
CMakeLists.txt
+24
-6
cmake/configure.cmake
cmake/configure.cmake
+2
-4
cmake/external/python.cmake
cmake/external/python.cmake
+4
-4
cmake/flags.cmake
cmake/flags.cmake
+1
-1
cmake/simd.cmake
cmake/simd.cmake
+4
-16
cmake/system.cmake
cmake/system.cmake
+6
-0
cmake/util.cmake
cmake/util.cmake
+4
-0
未找到文件。
CMakeLists.txt
浏览文件 @
1b856420
...
@@ -12,19 +12,26 @@
...
@@ -12,19 +12,26 @@
# 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
cmake_minimum_required
(
VERSION 3.0
)
project
(
paddle CXX C
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake"
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake"
)
set
(
PROJ_ROOT
${
CMAKE_SOURCE_DIR
}
)
set
(
PROJ_ROOT
${
CMAKE_SOURCE_DIR
}
)
include
(
system
)
if
(
ANDROID
)
cmake_minimum_required
(
VERSION 3.7
)
else
()
cmake_minimum_required
(
VERSION 3.0
)
endif
()
project
(
paddle CXX C
)
find_package
(
Sphinx
)
find_package
(
Sphinx
)
find_package
(
CUDA QUIET
)
if
(
NOT CMAKE_CROSSCOMPILING
)
find_package
(
CUDA QUIET
)
endif
(
NOT CMAKE_CROSSCOMPILING
)
find_package
(
Git REQUIRED
)
find_package
(
Git REQUIRED
)
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
include
(
system
)
include
(
simd
)
include
(
simd
)
################################ Configurations #######################################
################################ Configurations #######################################
...
@@ -51,6 +58,17 @@ if(NOT CMAKE_BUILD_TYPE)
...
@@ -51,6 +58,17 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE
)
FORCE
)
endif
()
endif
()
if
(
ANDROID
)
set
(
WITH_GPU OFF CACHE STRING
"Disable GPU when cross-compiling for Android"
FORCE
)
set
(
WITH_AVX OFF CACHE STRING
"Disable AVX when cross-compiling for Android"
FORCE
)
set
(
WITH_PYTHON OFF CACHE STRING
"Disable PYTHON when cross-compiling for Android"
FORCE
)
set
(
WITH_RDMA OFF CACHE STRING
"Disable RDMA when cross-compiling for Android"
FORCE
)
endif
(
ANDROID
)
set
(
THIRD_PARTY_PATH
"
${
PROJ_ROOT
}
/third_party"
CACHE STRING
set
(
THIRD_PARTY_PATH
"
${
PROJ_ROOT
}
/third_party"
CACHE STRING
"A path setting third party libraries download & build directories."
)
"A path setting third party libraries download & build directories."
)
########################################################################################
########################################################################################
...
...
cmake/configure.cmake
浏览文件 @
1b856420
...
@@ -32,15 +32,13 @@ if(NOT WITH_PROFILER)
...
@@ -32,15 +32,13 @@ if(NOT WITH_PROFILER)
add_definitions
(
-DPADDLE_DISABLE_PROFILER
)
add_definitions
(
-DPADDLE_DISABLE_PROFILER
)
endif
(
NOT WITH_PROFILER
)
endif
(
NOT WITH_PROFILER
)
if
(
NEON_FOUND
)
if
(
NOT CMAKE_CROSSCOMPILING
)
set
(
SIMD_FLAG
${
NEON_FLAG
}
)
else
(
NEON_FOUND
)
if
(
WITH_AVX
)
if
(
WITH_AVX
)
set
(
SIMD_FLAG
${
AVX_FLAG
}
)
set
(
SIMD_FLAG
${
AVX_FLAG
}
)
else
(
WITH_AVX
)
else
(
WITH_AVX
)
set
(
SIMD_FLAG
${
SSE3_FLAG
}
)
set
(
SIMD_FLAG
${
SSE3_FLAG
}
)
endif
(
WITH_AVX
)
endif
(
WITH_AVX
)
endif
(
NEON_FOUND
)
endif
()
if
(
NOT WITH_GPU
)
if
(
NOT WITH_GPU
)
add_definitions
(
-DPADDLE_ONLY_CPU
)
add_definitions
(
-DPADDLE_ONLY_CPU
)
...
...
cmake/external/python.cmake
浏览文件 @
1b856420
...
@@ -219,9 +219,9 @@ ELSE(PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
...
@@ -219,9 +219,9 @@ ELSE(PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
ENDIF
(
PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
)
ENDIF
(
PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
)
I
NCLUDE_DIRECTORIES
(
${
PYTHON_INCLUDE_DIR
}
)
I
F
(
WITH_PYTHON
)
INCLUDE_DIRECTORIES
(
${
PYTHON_NUMPY
_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
PYTHON
_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
PYTHON_NUMPY_INCLUDE_DIR
}
)
IF
(
NOT WITH_PYTHON
)
ELSE
(
)
SET
(
PYTHON_LIBRARIES
""
)
SET
(
PYTHON_LIBRARIES
""
)
ENDIF
()
ENDIF
()
cmake/flags.cmake
浏览文件 @
1b856420
...
@@ -26,7 +26,7 @@ function(CheckCompilerCXX11Flag)
...
@@ -26,7 +26,7 @@ function(CheckCompilerCXX11Flag)
endfunction
()
endfunction
()
CheckCompilerCXX11Flag
()
CheckCompilerCXX11Flag
()
LIST
(
APPEND CMAKE_CXX_FLAGS -std=c++11
)
string
(
APPEND CMAKE_CXX_FLAGS
" -std=c++11"
)
# safe_set_flag
# safe_set_flag
#
#
...
...
cmake/simd.cmake
浏览文件 @
1b856420
...
@@ -10,16 +10,16 @@ IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID
...
@@ -10,16 +10,16 @@ IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID
set
(
SSE3_FLAG
"-msse3"
)
set
(
SSE3_FLAG
"-msse3"
)
SET
(
AVX_FLAG
"-mavx"
)
SET
(
AVX_FLAG
"-mavx"
)
SET
(
AVX2_FLAG
"-mavx2"
)
SET
(
AVX2_FLAG
"-mavx2"
)
SET
(
NEON_FLAG
"-pie -fPIE -mfloat-abi=softfp -mfpu=neon"
)
ELSEIF
(
MSVC
)
ELSEIF
(
MSVC
)
set
(
MMX_FLAG
"/arch:MMX"
)
set
(
MMX_FLAG
"/arch:MMX"
)
set
(
SSE2_FLAG
"/arch:SSE2"
)
set
(
SSE2_FLAG
"/arch:SSE2"
)
set
(
SSE3_FLAG
"/arch:SSE3"
)
set
(
SSE3_FLAG
"/arch:SSE3"
)
SET
(
AVX_FLAG
"/arch:AVX"
)
SET
(
AVX_FLAG
"/arch:AVX"
)
SET
(
AVX2_FLAG
"/arch:AVX2"
)
SET
(
AVX2_FLAG
"/arch:AVX2"
)
#SET(NEON_FLAG "")
ENDIF
()
ENDIF
()
set
(
CMAKE_REQUIRED_FLAGS_RETAINED
${
CMAKE_REQUIRED_FLAGS
}
)
# Check MMX
# Check MMX
set
(
CMAKE_REQUIRED_FLAGS
${
MMX_FLAG
}
)
set
(
CMAKE_REQUIRED_FLAGS
${
MMX_FLAG
}
)
CHECK_CXX_SOURCE_RUNS
(
"
CHECK_CXX_SOURCE_RUNS
(
"
...
@@ -76,17 +76,5 @@ int main()
...
@@ -76,17 +76,5 @@ int main()
return 0;
return 0;
}"
AVX2_FOUND
)
}"
AVX2_FOUND
)
# Check NEON
set
(
CMAKE_REQUIRED_FLAGS
${
CMAKE_REQUIRED_FLAGS_RETAINED
}
)
set
(
CMAKE_REQUIRED_FLAGS
${
NEON_FLAG
}
)
mark_as_advanced
(
MMX_FOUND SSE2_FOUND SSE3_FOUND AVX_FOUND AVX2_FOUND
)
CHECK_CXX_SOURCE_COMPILES
(
"
#include <arm_neon.h>
int main()
{
float32x4_t a = {-1.0f, 2.0f, -3.0f, 4.0f};
float32x4_t b = {1.0f, 2.0f, 3.0f, 4.0f};
float32x4_t c = vaddq_f32(a, b);
return 0;
}"
NEON_FOUND
)
set
(
CMAKE_REQUIRED_FLAGS
""
)
mark_as_advanced
(
MMX_FOUND SSE2_FOUND SSE3_FOUND AVX_FOUND AVX2_FOUND NEON_FOUND
)
cmake/system.cmake
浏览文件 @
1b856420
...
@@ -67,6 +67,12 @@ MARK_AS_ADVANCED(HOST_SYSTEM CPU_CORES)
...
@@ -67,6 +67,12 @@ MARK_AS_ADVANCED(HOST_SYSTEM CPU_CORES)
MESSAGE
(
STATUS
"Found Paddle host system:
${
HOST_SYSTEM
}
"
)
MESSAGE
(
STATUS
"Found Paddle host system:
${
HOST_SYSTEM
}
"
)
MESSAGE
(
STATUS
"Found Paddle host system's CPU:
${
CPU_CORES
}
cores"
)
MESSAGE
(
STATUS
"Found Paddle host system's CPU:
${
CPU_CORES
}
cores"
)
IF
(
DEFINED CMAKE_SYSTEM_NAME
)
IF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Android"
)
SET
(
ANDROID TRUE
)
ENDIF
()
ENDIF
()
# external dependencies log output
# external dependencies log output
SET
(
EXTERNAL_PROJECT_LOG_ARGS
SET
(
EXTERNAL_PROJECT_LOG_ARGS
LOG_DOWNLOAD 0
# Wrap download in script to log output
LOG_DOWNLOAD 0
# Wrap download in script to log output
...
...
cmake/util.cmake
浏览文件 @
1b856420
...
@@ -90,6 +90,10 @@ function(link_paddle_exe TARGET_NAME)
...
@@ -90,6 +90,10 @@ function(link_paddle_exe TARGET_NAME)
${
RDMA_LD_FLAGS
}
${
RDMA_LD_FLAGS
}
${
RDMA_LIBS
}
)
${
RDMA_LIBS
}
)
if
(
ANDROID
)
target_link_libraries
(
${
TARGET_NAME
}
log
)
endif
(
ANDROID
)
add_dependencies
(
${
TARGET_NAME
}
${
external_project_dependencies
}
)
add_dependencies
(
${
TARGET_NAME
}
${
external_project_dependencies
}
)
endfunction
()
endfunction
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录