Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
3424a4c0
P
Paddle
项目概览
机器未来
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3424a4c0
编写于
11月 03, 2016
作者:
G
gangliao
提交者:
luotao1
11月 04, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug and redundant code in hl_dso_loader.cc (#306)
上级
ed83a1d6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
81 deletion
+27
-81
paddle/cuda/src/hl_cuda_cudnn.cc
paddle/cuda/src/hl_cuda_cudnn.cc
+19
-54
paddle/cuda/src/hl_cuda_device.cc
paddle/cuda/src/hl_cuda_device.cc
+6
-25
paddle/cuda/src/hl_dso_loader.cc
paddle/cuda/src/hl_dso_loader.cc
+2
-2
未找到文件。
paddle/cuda/src/hl_cuda_cudnn.cc
浏览文件 @
3424a4c0
...
...
@@ -41,65 +41,28 @@ void* cudnn_dso_handle = nullptr;
#ifdef PADDLE_USE_DSO
#define DYNAMIC_LOAD_CUDNN_WRAP(__name) \
struct DynLoad__##__name { \
template <typename... Args> \
cudnnStatus_t operator()(Args... args) {
\
typedef cudnnStatus_t (*cudnnFunc)(Args...);
\
std::call_once(cudnn_dso_flag, GetCudnnDsoHandle, \
&cudnn_dso_handle); \
void* p_##__name = dlsym(cudnn_dso_handle, #__name); \
return reinterpret_cast<cudnn
F
unc>(p_##__name)(args...); \
} \
#define DYNAMIC_LOAD_CUDNN_WRAP(__name)
\
struct DynLoad__##__name {
\
template <typename... Args>
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
using cudnn_func = decltype(__name(args...))(*)(Args...);
\
std::call_once(cudnn_dso_flag, GetCudnnDsoHandle,
\
&cudnn_dso_handle);
\
void* p_##__name = dlsym(cudnn_dso_handle, #__name);
\
return reinterpret_cast<cudnn
_f
unc>(p_##__name)(args...); \
}
\
} __name;
/* struct DynLoad__##__name */
struct
DynLoad__cudnnGetVersion
{
template
<
typename
...
Args
>
size_t
operator
()(
Args
...
args
)
{
typedef
size_t
(
*
cudnnFunc
)(
Args
...);
std
::
call_once
(
cudnn_dso_flag
,
GetCudnnDsoHandle
,
&
cudnn_dso_handle
);
void
*
p_name
=
dlsym
(
cudnn_dso_handle
,
"cudnnGetVersion"
);
return
reinterpret_cast
<
cudnnFunc
>
(
p_name
)(
args
...);
}
}
cudnnGetVersion
;
/* struct DynLoad__##__name */
struct
DynLoad__cudnnGetErrorString
{
template
<
typename
...
Args
>
const
char
*
operator
()(
Args
...
args
)
{
typedef
const
char
*
(
*
cudnnFunc
)(
Args
...);
std
::
call_once
(
cudnn_dso_flag
,
GetCudnnDsoHandle
,
&
cudnn_dso_handle
);
void
*
p_name
=
dlsym
(
cudnn_dso_handle
,
"cudnnGetErrorString"
);
return
reinterpret_cast
<
cudnnFunc
>
(
p_name
)(
args
...);
}
}
cudnnGetErrorString
;
/* struct DynLoad__##__name */
#else
#define DYNAMIC_LOAD_CUDNN_WRAP(__name) \
struct DynLoad__##__name { \
template <typename... Args> \
cudnnStatus_t operator()(Args... args) {
\
return __name(args...); \
} \
#define DYNAMIC_LOAD_CUDNN_WRAP(__name)
\
struct DynLoad__##__name {
\
template <typename... Args>
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
return __name(args...);
\
}
\
} __name;
/* struct DynLoad__##__name */
struct
DynLoad__cudnnGetVersion
{
template
<
typename
...
Args
>
size_t
operator
()(
Args
...
args
)
{
return
cudnnGetVersion
(
args
...);
}
}
cudnnGetVersion
;
/* struct DynLoad__##__name */
struct
DynLoad__cudnnGetErrorString
{
template
<
typename
...
Args
>
const
char
*
operator
()(
Args
...
args
)
{
return
cudnnGetErrorString
(
args
...);
}
}
cudnnGetErrorString
;
/* struct DynLoad__##__name */
#endif
/**
...
...
@@ -133,7 +96,9 @@ struct DynLoad__cudnnGetErrorString {
__macro(cudnnPoolingForward) \
__macro(cudnnPoolingBackward) \
__macro(cudnnSoftmaxBackward) \
__macro(cudnnSoftmaxForward)
__macro(cudnnSoftmaxForward) \
__macro(cudnnGetVersion) \
__macro(cudnnGetErrorString)
CUDNN_DNN_ROUTINE_EACH
(
DYNAMIC_LOAD_CUDNN_WRAP
)
#define CUDNN_DNN_ROUTINE_EACH_R2(__macro) \
...
...
paddle/cuda/src/hl_cuda_device.cc
浏览文件 @
3424a4c0
...
...
@@ -85,44 +85,24 @@ void* cudart_dso_handle = nullptr;
#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
struct DynLoad__##__name { \
template <typename... Args> \
cudaError_t operator()(Args... args) {
\
typedef cudaError_t (*cudartFunc)(Args...);
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
using cudart_func = decltype(__name(args...))(*)(Args...);
\
std::call_once(cudart_dso_flag, GetCudartDsoHandle, \
&cudart_dso_handle); \
void* p_##__name = dlsym(cudart_dso_handle, #__name); \
return reinterpret_cast<cudart
Func>(p_##__name)(args...);
\
return reinterpret_cast<cudart
_func>(p_##__name)(args...);
\
} \
} __name;
/* struct DynLoad__##__name */
#else
#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
struct DynLoad__##__name { \
template <typename... Args> \
cudaError_t operator()(Args... args) {
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
return __name(args...); \
} \
} __name;
/* struct DynLoad__##__name */
#endif
#ifdef PADDLE_USE_DSO
struct
DynLoad__cudaGetErrorString
{
template
<
typename
...
Args
>
const
char
*
operator
()(
Args
...
args
)
{
typedef
const
char
*
(
*
cudaFunc
)(
Args
...);
std
::
call_once
(
cudart_dso_flag
,
GetCudartDsoHandle
,
&
cudart_dso_handle
);
void
*
p_func
=
dlsym
(
cudart_dso_handle
,
"cudaGetErrorString"
);
return
reinterpret_cast
<
cudaFunc
>
(
p_func
)(
args
...);
}
}
cudaGetErrorString
;
/* struct DynLoad__cudaGetErrorString */
#else
struct
DynLoad__cudaGetErrorString
{
template
<
typename
...
Args
>
const
char
*
operator
()(
Args
...
args
)
{
return
cudaGetErrorString
(
args
...);
}
}
cudaGetErrorString
;
/* struct DynLoad__cudaGetErrorString */
#endif
/* include all needed cuda functions in HPPL */
#define CUDA_ROUTINE_EACH(__macro) \
__macro(cudaMalloc) \
...
...
@@ -152,7 +132,8 @@ struct DynLoad__cudaGetErrorString {
__macro(cudaSetDeviceFlags) \
__macro(cudaGetLastError) \
__macro(cudaFuncSetCacheConfig) \
__macro(cudaRuntimeGetVersion)
__macro(cudaRuntimeGetVersion) \
__macro(cudaGetErrorString)
CUDA_ROUTINE_EACH
(
DYNAMIC_LOAD_CUDART_WRAP
)
...
...
paddle/cuda/src/hl_dso_loader.cc
浏览文件 @
3424a4c0
...
...
@@ -49,14 +49,14 @@ static inline std::string join(const std::string& part1, const std::string& part
static
inline
void
GetDsoHandleFromDefaultPath
(
std
::
string
&
dso_path
,
void
**
dso_handle
,
int
dynload_flags
)
{
LOG
(
INFO
)
<<
"Try to find cuda library: "
<<
dso_path
<<
"from default system path."
;
<<
"
from default system path."
;
// default search from LD_LIBRARY_PATH/DYLD_LIBRARY_PATH
*
dso_handle
=
dlopen
(
dso_path
.
c_str
(),
dynload_flags
);
// DYLD_LIBRARY_PATH is disabled after Mac OS 10.11 to
// bring System Integrity Projection (SIP), if dso_handle
// is null, search from default package path in Mac OS.
#if defined(__APPLE__)
or
defined(__OSX__)
#if defined(__APPLE__)
||
defined(__OSX__)
if
(
nullptr
==
*
dso_handle
)
{
dso_path
=
join
(
"/usr/local/cuda/lib/"
,
dso_path
);
*
dso_handle
=
dlopen
(
dso_path
.
c_str
(),
dynload_flags
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录