Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f490d942
P
Paddle
项目概览
PaddlePaddle
/
Paddle
11 个月 前同步成功
通知
2292
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f490d942
编写于
7月 19, 2017
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
separate MKL_LITE from MKLDNN
上级
89a41580
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
121 addition
and
34 deletion
+121
-34
CMakeLists.txt
CMakeLists.txt
+8
-3
cmake/cblas.cmake
cmake/cblas.cmake
+16
-1
cmake/configure.cmake
cmake/configure.cmake
+20
-2
cmake/external/mkldnn.cmake
cmake/external/mkldnn.cmake
+16
-28
cmake/external/mkllite.cmake
cmake/external/mkllite.cmake
+61
-0
未找到文件。
CMakeLists.txt
浏览文件 @
f490d942
...
...
@@ -37,7 +37,8 @@ include(simd)
################################ Configurations #######################################
option
(
WITH_GPU
"Compile PaddlePaddle with NVIDIA GPU"
${
CUDA_FOUND
}
)
option
(
WITH_AVX
"Compile PaddlePaddle with AVX intrinsics"
${
AVX_FOUND
}
)
option
(
WITH_MKLDNN
"Compile PaddlePaddle with mkl-dnn support."
ON
)
option
(
WITH_MKLDNN
"Compile PaddlePaddle with mkl-dnn support."
${
AVX_FOUND
}
)
option
(
WITH_MKL_LITE
"Compile PaddlePaddle with mkl lite package."
${
AVX_FOUND
}
)
option
(
WITH_DSO
"Compile PaddlePaddle with dynamic linked CUDA"
ON
)
option
(
WITH_TESTING
"Compile PaddlePaddle with unit testing"
ON
)
option
(
WITH_SWIG_PY
"Compile PaddlePaddle with inference api"
ON
)
...
...
@@ -76,6 +77,10 @@ if(ANDROID)
"Disable PYTHON when cross-compiling for Android"
FORCE
)
set
(
WITH_RDMA OFF CACHE STRING
"Disable RDMA when cross-compiling for Android"
FORCE
)
set
(
WITH_MKLDNN OFF CACHE STRING
"Disable MKLDNN when cross-compiling for Android"
FORCE
)
set
(
WITH_MKL_LITE OFF CACHE STRING
"Disable MKL lite package when cross-compiling for Android"
FORCE
)
endif
(
ANDROID
)
set
(
THIRD_PARTY_PATH
"
${
CMAKE_BINARY_DIR
}
/third_party"
CACHE STRING
...
...
@@ -89,14 +94,15 @@ endif()
########################################################################################
include
(
external/mkllite
)
# download mkl minimal lite package
include
(
external/zlib
)
# download, build, install zlib
include
(
external/gflags
)
# download, build, install gflags
include
(
external/glog
)
# download, build, install glog
include
(
external/gtest
)
# download, build, install gtest
include
(
external/protobuf
)
# download, build, install protobuf
include
(
external/python
)
# download, build, install python
include
(
external/mkldnn
)
# download, build, install mkldnn
include
(
external/openblas
)
# download, build, install openblas
include
(
external/mkldnn
)
# download, build, install mkldnn
include
(
external/swig
)
# download, build, install swig
include
(
external/warpctc
)
# download, build, install warpctc
include
(
external/any
)
# download libn::any
...
...
@@ -139,7 +145,6 @@ if(WITH_GPU)
endif
(
WITH_GPU
)
if
(
WITH_MKLDNN
)
message
(
STATUS
"MKLDNN_LIBRARY:
${
MKLDNN_LIBRARY
}
"
)
list
(
APPEND EXTERNAL_LIBS
${
MKLDNN_LIBRARY
}
${
MKL_LITE_LIB_IOMP
}
)
endif
()
...
...
cmake/cblas.cmake
浏览文件 @
f490d942
...
...
@@ -15,7 +15,22 @@
set
(
CBLAS_FOUND OFF
)
## Find MKL First.
## Find MKL Lite First.
if
(
WITH_MKL_LITE AND MKL_LITE_INC_DIR AND MKL_LITE_LIB
)
set
(
CBLAS_FOUND ON
)
set
(
CBLAS_PROVIDER MKL_LITE
)
set
(
CBLAS_INC_DIR
${
MKL_LITE_INC_DIR
}
)
set
(
CBLAS_LIBRARIES
${
MKL_LITE_LIB
}
)
add_definitions
(
-DPADDLE_USE_MKL_LITE
)
add_definitions
(
-DLAPACK_FOUND
)
message
(
STATUS
"Found cblas and lapack in MKL Lite "
"(include:
${
CBLAS_INC_DIR
}
, library:
${
CBLAS_LIBRARIES
}
)"
)
return
()
endif
()
## Then find MKL.
set
(
INTEL_MKL_ROOT
"/opt/intel/mkl"
CACHE PATH
"Folder contains intel mkl libs"
)
set
(
MKL_ROOT $ENV{MKL_ROOT} CACHE PATH
"Folder contains env MKL"
)
...
...
cmake/configure.cmake
浏览文件 @
f490d942
...
...
@@ -69,8 +69,26 @@ endif(NOT WITH_GPU)
if
(
WITH_MKLDNN
)
add_definitions
(
-DPADDLE_USE_MKLDNN
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
OpenMP_C_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
OpenMP_CXX_FLAGS
}
"
)
if
(
WITH_MKL_LITE AND MKLDNN_IOMP_DIR
)
message
(
STATUS
"Enable Intel OpenMP at
${
MKLDNN_IOMP_DIR
}
"
)
set
(
OPENMP_FLAGS
"-fopenmp"
)
set
(
CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS
${
OPENMP_FLAGS
}
)
set
(
CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS
${
OPENMP_FLAGS
}
)
set
(
CMAKE_SHARED_LINKER_FLAGS
"
${
CMAKE_SHARED_LINKER_FLAGS
}
-L
${
MKLDNN_IOMP_DIR
}
-liomp5 -Wl,--as-needed"
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-L
${
MKLDNN_IOMP_DIR
}
-liomp5 -Wl,--as-needed"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
OPENMP_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
OPENMP_FLAGS
}
"
)
else
()
find_package
(
OpenMP
)
if
(
OPENMP_FOUND
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
OpenMP_C_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
OpenMP_CXX_FLAGS
}
"
)
else
()
message
(
WARNING
"Can not find OpenMP."
"Some performance features in MKLDNN may not be available"
)
endif
()
endif
()
endif
(
WITH_MKLDNN
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
SIMD_FLAG
}
"
)
...
...
cmake/external/mkldnn.cmake
浏览文件 @
f490d942
...
...
@@ -23,10 +23,6 @@ SET(MKLDNN_SOURCES_DIR ${THIRD_PARTY_PATH}/mkldnn)
SET
(
MKLDNN_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/mkldnn
)
SET
(
MKLDNN_INCLUDE_DIR
"
${
MKLDNN_INSTALL_DIR
}
/include"
CACHE PATH
"mkldnn include directory."
FORCE
)
# The following magic numbers should be updated regularly to keep latest version
SET
(
MKLDNN_TAG
"v0.9"
)
SET
(
MKLDNN_MKL_VER
"mklml_lnx_2018.0.20170425"
)
IF
(
WIN32
)
MESSAGE
(
WARNING
"It is not supported compiling with mkldnn in windows Paddle yet."
"Force WITH_MKLDNN=OFF"
)
...
...
@@ -42,37 +38,29 @@ ENDIF(WIN32)
INCLUDE_DIRECTORIES
(
${
MKLDNN_INCLUDE_DIR
}
)
SET
(
MKLDNN_CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
OpenMP_C_FLAGS
}
"
)
SET
(
MKLDNN_CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
OpenMP_CXX_FLAGS
}
"
)
IF
(
${
CBLAS_PROVIDER
}
STREQUAL
"MKL_LITE"
)
SET
(
MKLDNN_DEPENDS
${
MKL_LITE_PROJECT
}
)
SET
(
MKLDNN_MKLROOT
${
MKL_LITE_ROOT
}
)
SET
(
MKLDNN_IOMP_DIR
${
MKL_LITE_LIB_DIR
}
)
ENDIF
()
ExternalProject_Add
(
${
MKLDNN_PROJECT
}
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY
"https://github.com/01org/mkl-dnn.git"
GIT_TAG
"
${
MKLDNN_TAG
}
"
PREFIX
${
MKLDNN_SOURCES_DIR
}
PATCH_COMMAND cd <SOURCE_DIR>/scripts && ./prepare_mkl.sh
UPDATE_COMMAND
""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
CMAKE_ARGS -DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
CMAKE_ARGS -DCMAKE_CXX_FLAGS=
${
MKLDNN_CMAKE_CXX_FLAGS
}
CMAKE_ARGS -DCMAKE_C_FLAGS=
${
MKLDNN_CMAKE_C_FLAGS
}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=
${
MKLDNN_INSTALL_DIR
}
CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=
${
MKLDNN_INSTALL_DIR
}
/lib
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=
${
MKLDNN_INSTALL_DIR
}
-DCMAKE_INSTALL_LIBDIR:PATH=
${
MKLDNN_INSTALL_DIR
}
/lib
-DCMAKE_BUILD_TYPE:STRING=Release
DEPENDS
${
MKLDNN_DEPENDS
}
GIT_REPOSITORY
"https://github.com/01org/mkl-dnn.git"
GIT_TAG
"v0.9"
PREFIX
${
MKLDNN_SOURCES_DIR
}
CONFIGURE_COMMAND mkdir -p <SOURCE_DIR>/build
BUILD_COMMAND cd <SOURCE_DIR>/build
&& cmake .. -DCMAKE_INSTALL_PREFIX=
${
MKLDNN_INSTALL_DIR
}
-DMKLROOT=
${
MKLDNN_MKLROOT
}
&& make all -j
${
CPU_CORES
}
INSTALL_COMMAND cd <SOURCE_DIR>/build && make install
UPDATE_COMMAND
""
)
SET
(
MKL_LITE_DIR
${
MKLDNN_SOURCES_DIR
}
/src/
${
MKLDNN_PROJECT
}
/external/
${
MKLDNN_MKL_VER
}
)
SET
(
MKL_LITE_INC_DIR
${
MKL_LITE_DIR
}
/include
)
SET
(
MKL_LITE_LIB
${
MKL_LITE_DIR
}
/lib/libmklml_intel.so
)
SET
(
MKL_LITE_LIB_IOMP
${
MKL_LITE_DIR
}
/lib/libiomp5.so
)
SET
(
CMAKE_INSTALL_RPATH
"
${
CMAKE_INSTALL_RPATH
}
"
"
${
MKL_LITE_DIR
}
/lib"
)
ADD_LIBRARY
(
mkldnn STATIC IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET mkldnn PROPERTY IMPORTED_LOCATION
${
MKLDNN_LIBRARY
}
)
ADD_DEPENDENCIES
(
mkldnn
${
MKLDNN_PROJECT
}
)
MESSAGE
(
STATUS
"Mkldnn library:
${
MKLDNN_LIBRARY
}
"
)
LIST
(
APPEND external_project_dependencies mkldnn
)
cmake/external/mkllite.cmake
0 → 100644
浏览文件 @
f490d942
# Copyright (c) 2017 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.
IF
(
NOT
${
WITH_MKL_LITE
}
)
return
()
ENDIF
(
NOT
${
WITH_MKL_LITE
}
)
INCLUDE
(
ExternalProject
)
SET
(
MKL_LITE_PROJECT
"extern_mkllite"
)
SET
(
MKL_LITE_VER
"mklml_lnx_2018.0.20170425"
)
SET
(
MKL_LITE_URL
"https://github.com/01org/mkl-dnn/releases/download/v0.9/
${
MKL_LITE_VER
}
.tgz"
)
SET
(
MKL_LITE_DOWNLOAD_DIR
${
THIRD_PARTY_PATH
}
/mkllite
)
SET
(
MKL_LITE_ROOT
${
MKL_LITE_DOWNLOAD_DIR
}
/
${
MKL_LITE_VER
}
)
SET
(
MKL_LITE_INC_DIR
${
MKL_LITE_ROOT
}
/include
)
SET
(
MKL_LITE_LIB_DIR
${
MKL_LITE_ROOT
}
/lib
)
SET
(
MKL_LITE_LIB
${
MKL_LITE_LIB_DIR
}
/libmklml_intel.so
)
SET
(
MKL_LITE_IOMP_LIB
${
MKL_LITE_LIB_DIR
}
/libiomp5.so
)
SET
(
CMAKE_INSTALL_RPATH
"
${
CMAKE_INSTALL_RPATH
}
"
"
${
MKL_LITE_ROOT
}
/lib"
)
INCLUDE_DIRECTORIES
(
${
MKL_LITE_INC_DIR
}
)
ExternalProject_Add
(
${
MKL_LITE_PROJECT
}
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
MKL_LITE_DOWNLOAD_DIR
}
DOWNLOAD_DIR
${
MKL_LITE_DOWNLOAD_DIR
}
DOWNLOAD_COMMAND wget --no-check-certificate
${
MKL_LITE_URL
}
&& tar -xzf
${
MKL_LITE_DOWNLOAD_DIR
}
/
${
MKL_LITE_VER
}
.tgz
DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND
""
PATCH_COMMAND
""
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
TEST_COMMAND
""
)
IF
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.3.0"
)
SET
(
dummyfile
${
CMAKE_CURRENT_BINARY_DIR
}
/mkllite_dummy.c
)
FILE
(
WRITE
${
dummyfile
}
"const char * dummy_mkllite =
\"
${
dummyfile
}
\"
;"
)
ADD_LIBRARY
(
mkllite STATIC
${
dummyfile
}
)
ELSE
()
ADD_LIBRARY
(
mkllite INTERFACE
)
ENDIF
()
ADD_DEPENDENCIES
(
mkllite
${
MKL_LITE_PROJECT
}
)
LIST
(
APPEND external_project_dependencies mkllite
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录