Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
16b65c55
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
16b65c55
编写于
8月 13, 2018
作者:
T
Tao Luo
提交者:
GitHub
8月 13, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12646 from tensor-tang/feature/jit/xbyak
introduce xbyak
上级
64824ac7
a50889f5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
120 addition
and
1 deletion
+120
-1
CMakeLists.txt
CMakeLists.txt
+1
-0
cmake/external/xbyak.cmake
cmake/external/xbyak.cmake
+58
-0
paddle/fluid/platform/CMakeLists.txt
paddle/fluid/platform/CMakeLists.txt
+5
-1
paddle/fluid/platform/cpu_info.cc
paddle/fluid/platform/cpu_info.cc
+36
-0
paddle/fluid/platform/cpu_info.h
paddle/fluid/platform/cpu_info.h
+20
-0
未找到文件。
CMakeLists.txt
浏览文件 @
16b65c55
...
...
@@ -160,6 +160,7 @@ endif()
########################################################################################
include
(
external/mklml
)
# download mklml package
include
(
external/xbyak
)
# download xbyak package
include
(
external/libxsmm
)
# download, build, install libxsmm
include
(
external/zlib
)
# download, build, install zlib
include
(
external/gflags
)
# download, build, install gflags
...
...
cmake/external/xbyak.cmake
0 → 100644
浏览文件 @
16b65c55
# Copyright (c) 2017 PaddlePaddle Authors. All Rights Reserved.
#
# 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.
set
(
WITH_XBYAK ON
)
if
(
WIN32 OR APPLE
)
SET
(
WITH_XBYAK OFF CACHE STRING
"Disable XBYAK in Windows and MacOS"
FORCE
)
return
()
endif
()
include
(
ExternalProject
)
set
(
XBYAK_PROJECT extern_xbyak
)
set
(
XBYAK_PREFIX_DIR
${
THIRD_PARTY_PATH
}
/xbyak
)
set
(
XBYAK_INSTALL_ROOT
${
THIRD_PARTY_PATH
}
/install/xbyak
)
set
(
XBYAK_INC_DIR
${
XBYAK_INSTALL_ROOT
}
/include
)
include_directories
(
${
XBYAK_INC_DIR
}
)
include_directories
(
${
XBYAK_INC_DIR
}
/xbyak
)
add_definitions
(
-DPADDLE_WITH_XBYAK
)
# xbyak options
add_definitions
(
-DXBYAK64
)
add_definitions
(
-DXBYAK_NO_OP_NAMES
)
ExternalProject_Add
(
${
XBYAK_PROJECT
}
${
EXTERNAL_PROJECT_LOG_ARGS
}
DEPENDS
""
GIT_REPOSITORY
"https://github.com/herumi/xbyak.git"
GIT_TAG
"v5.661"
# Jul 26th
PREFIX
${
XBYAK_PREFIX_DIR
}
UPDATE_COMMAND
""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=
${
XBYAK_INSTALL_ROOT
}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=
${
XBYAK_INSTALL_ROOT
}
)
if
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.3.0"
)
set
(
dummyfile
${
CMAKE_CURRENT_BINARY_DIR
}
/xbyak_dummy.c
)
file
(
WRITE
${
dummyfile
}
"const char *dummy_xbyak =
\"
${
dummyfile
}
\"
;"
)
add_library
(
xbyak STATIC
${
dummyfile
}
)
else
()
add_library
(
xbyak INTERFACE
)
endif
()
add_dependencies
(
xbyak
${
XBYAK_PROJECT
}
)
list
(
APPEND external_project_dependencies xbyak
)
paddle/fluid/platform/CMakeLists.txt
浏览文件 @
16b65c55
...
...
@@ -18,7 +18,11 @@ else()
endif
()
cc_test
(
enforce_test SRCS enforce_test.cc DEPS stringpiece enforce
)
cc_library
(
cpu_info SRCS cpu_info.cc DEPS gflags glog enforce
)
set
(
CPU_INFO_DEPS gflags glog enforce
)
IF
(
WITH_XBYAK
)
list
(
APPEND CPU_INFO_DEPS xbyak
)
ENDIF
()
cc_library
(
cpu_info SRCS cpu_info.cc DEPS
${
CPU_INFO_DEPS
}
)
cc_test
(
cpu_info_test SRCS cpu_info_test.cc DEPS cpu_info
)
nv_library
(
gpu_info SRCS gpu_info.cc DEPS gflags glog enforce
)
...
...
paddle/fluid/platform/cpu_info.cc
浏览文件 @
16b65c55
...
...
@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/platform/cpu_info.h"
#include "xbyak/xbyak.h"
#include "xbyak/xbyak_util.h"
#ifdef __APPLE__
#include <sys/sysctl.h>
...
...
@@ -98,5 +100,39 @@ size_t CUDAPinnedMaxChunkSize() {
return
CUDAPinnedMaxAllocSize
()
/
256
;
}
#ifdef PADDLE_WITH_XBYAK
namespace
jit
{
static
Xbyak
::
util
::
Cpu
cpu
;
bool
MayIUse
(
const
cpu_isa_t
cpu_isa
)
{
using
namespace
Xbyak
::
util
;
// NOLINT
switch
(
cpu_isa
)
{
case
sse42
:
return
cpu
.
has
(
Cpu
::
tSSE42
);
case
avx2
:
return
cpu
.
has
(
Cpu
::
tAVX2
);
case
avx512_common
:
return
cpu
.
has
(
Cpu
::
tAVX512F
);
case
avx512_core
:
return
true
&&
cpu
.
has
(
Cpu
::
tAVX512F
)
&&
cpu
.
has
(
Cpu
::
tAVX512BW
)
&&
cpu
.
has
(
Cpu
::
tAVX512VL
)
&&
cpu
.
has
(
Cpu
::
tAVX512DQ
);
case
avx512_core_vnni
:
return
true
&&
cpu
.
has
(
Cpu
::
tAVX512F
)
&&
cpu
.
has
(
Cpu
::
tAVX512BW
)
&&
cpu
.
has
(
Cpu
::
tAVX512VL
)
&&
cpu
.
has
(
Cpu
::
tAVX512DQ
)
&&
cpu
.
has
(
Cpu
::
tAVX512_VNNI
);
case
avx512_mic
:
return
true
&&
cpu
.
has
(
Cpu
::
tAVX512F
)
&&
cpu
.
has
(
Cpu
::
tAVX512CD
)
&&
cpu
.
has
(
Cpu
::
tAVX512ER
)
&&
cpu
.
has
(
Cpu
::
tAVX512PF
);
case
avx512_mic_4ops
:
return
true
&&
MayIUse
(
avx512_mic
)
&&
cpu
.
has
(
Cpu
::
tAVX512_4FMAPS
)
&&
cpu
.
has
(
Cpu
::
tAVX512_4VNNIW
);
case
isa_any
:
return
true
;
}
return
false
;
}
}
// namespace jit
#endif
}
// namespace platform
}
// namespace paddle
paddle/fluid/platform/cpu_info.h
浏览文件 @
16b65c55
...
...
@@ -37,5 +37,25 @@ size_t CUDAPinnedMinChunkSize();
//! Get the maximum chunk size for buddy allocator.
size_t
CUDAPinnedMaxChunkSize
();
#ifdef PADDLE_WITH_XBYAK
namespace
jit
{
typedef
enum
{
isa_any
,
sse42
,
avx2
,
avx512_common
,
avx512_core
,
avx512_core_vnni
,
avx512_mic
,
avx512_mic_4ops
,
}
cpu_isa_t
;
// Instruction set architecture
// May I use some instruction
inline
bool
MayIUse
(
const
cpu_isa_t
cpu_isa
);
}
// namespace jit
#endif
}
// namespace platform
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录