Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3424a4c0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
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;
...
@@ -41,65 +41,28 @@ void* cudnn_dso_handle = nullptr;
#ifdef PADDLE_USE_DSO
#ifdef PADDLE_USE_DSO
#define DYNAMIC_LOAD_CUDNN_WRAP(__name) \
#define DYNAMIC_LOAD_CUDNN_WRAP(__name)
\
struct DynLoad__##__name { \
struct DynLoad__##__name {
\
template <typename... Args> \
template <typename... Args>
\
cudnnStatus_t operator()(Args... args) {
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
typedef cudnnStatus_t (*cudnnFunc)(Args...);
\
using cudnn_func = decltype(__name(args...))(*)(Args...);
\
std::call_once(cudnn_dso_flag, GetCudnnDsoHandle, \
std::call_once(cudnn_dso_flag, GetCudnnDsoHandle,
\
&cudnn_dso_handle); \
&cudnn_dso_handle);
\
void* p_##__name = dlsym(cudnn_dso_handle, #__name); \
void* p_##__name = dlsym(cudnn_dso_handle, #__name);
\
return reinterpret_cast<cudnn
F
unc>(p_##__name)(args...); \
return reinterpret_cast<cudnn
_f
unc>(p_##__name)(args...); \
} \
}
\
} __name;
/* struct DynLoad__##__name */
} __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
#else
#define DYNAMIC_LOAD_CUDNN_WRAP(__name) \
#define DYNAMIC_LOAD_CUDNN_WRAP(__name)
\
struct DynLoad__##__name { \
struct DynLoad__##__name {
\
template <typename... Args> \
template <typename... Args>
\
cudnnStatus_t operator()(Args... args) {
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
return __name(args...); \
return __name(args...);
\
} \
}
\
} __name;
/* struct DynLoad__##__name */
} __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
#endif
/**
/**
...
@@ -133,7 +96,9 @@ struct DynLoad__cudnnGetErrorString {
...
@@ -133,7 +96,9 @@ struct DynLoad__cudnnGetErrorString {
__macro(cudnnPoolingForward) \
__macro(cudnnPoolingForward) \
__macro(cudnnPoolingBackward) \
__macro(cudnnPoolingBackward) \
__macro(cudnnSoftmaxBackward) \
__macro(cudnnSoftmaxBackward) \
__macro(cudnnSoftmaxForward)
__macro(cudnnSoftmaxForward) \
__macro(cudnnGetVersion) \
__macro(cudnnGetErrorString)
CUDNN_DNN_ROUTINE_EACH
(
DYNAMIC_LOAD_CUDNN_WRAP
)
CUDNN_DNN_ROUTINE_EACH
(
DYNAMIC_LOAD_CUDNN_WRAP
)
#define CUDNN_DNN_ROUTINE_EACH_R2(__macro) \
#define CUDNN_DNN_ROUTINE_EACH_R2(__macro) \
...
...
paddle/cuda/src/hl_cuda_device.cc
浏览文件 @
3424a4c0
...
@@ -85,44 +85,24 @@ void* cudart_dso_handle = nullptr;
...
@@ -85,44 +85,24 @@ void* cudart_dso_handle = nullptr;
#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
struct DynLoad__##__name { \
struct DynLoad__##__name { \
template <typename... Args> \
template <typename... Args> \
cudaError_t operator()(Args... args) {
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
typedef cudaError_t (*cudartFunc)(Args...);
\
using cudart_func = decltype(__name(args...))(*)(Args...);
\
std::call_once(cudart_dso_flag, GetCudartDsoHandle, \
std::call_once(cudart_dso_flag, GetCudartDsoHandle, \
&cudart_dso_handle); \
&cudart_dso_handle); \
void* p_##__name = dlsym(cudart_dso_handle, #__name); \
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 */
} __name;
/* struct DynLoad__##__name */
#else
#else
#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
struct DynLoad__##__name { \
struct DynLoad__##__name { \
template <typename... Args> \
template <typename... Args> \
cudaError_t operator()(Args... args) {
\
auto operator()(Args... args) -> decltype(__name(args...)) {
\
return __name(args...); \
return __name(args...); \
} \
} \
} __name;
/* struct DynLoad__##__name */
} __name;
/* struct DynLoad__##__name */
#endif
#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 */
/* include all needed cuda functions in HPPL */
#define CUDA_ROUTINE_EACH(__macro) \
#define CUDA_ROUTINE_EACH(__macro) \
__macro(cudaMalloc) \
__macro(cudaMalloc) \
...
@@ -152,7 +132,8 @@ struct DynLoad__cudaGetErrorString {
...
@@ -152,7 +132,8 @@ struct DynLoad__cudaGetErrorString {
__macro(cudaSetDeviceFlags) \
__macro(cudaSetDeviceFlags) \
__macro(cudaGetLastError) \
__macro(cudaGetLastError) \
__macro(cudaFuncSetCacheConfig) \
__macro(cudaFuncSetCacheConfig) \
__macro(cudaRuntimeGetVersion)
__macro(cudaRuntimeGetVersion) \
__macro(cudaGetErrorString)
CUDA_ROUTINE_EACH
(
DYNAMIC_LOAD_CUDART_WRAP
)
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
...
@@ -49,14 +49,14 @@ static inline std::string join(const std::string& part1, const std::string& part
static
inline
void
GetDsoHandleFromDefaultPath
(
static
inline
void
GetDsoHandleFromDefaultPath
(
std
::
string
&
dso_path
,
void
**
dso_handle
,
int
dynload_flags
)
{
std
::
string
&
dso_path
,
void
**
dso_handle
,
int
dynload_flags
)
{
LOG
(
INFO
)
<<
"Try to find cuda library: "
<<
dso_path
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
// default search from LD_LIBRARY_PATH/DYLD_LIBRARY_PATH
*
dso_handle
=
dlopen
(
dso_path
.
c_str
(),
dynload_flags
);
*
dso_handle
=
dlopen
(
dso_path
.
c_str
(),
dynload_flags
);
// DYLD_LIBRARY_PATH is disabled after Mac OS 10.11 to
// DYLD_LIBRARY_PATH is disabled after Mac OS 10.11 to
// bring System Integrity Projection (SIP), if dso_handle
// bring System Integrity Projection (SIP), if dso_handle
// is null, search from default package path in Mac OS.
// 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
)
{
if
(
nullptr
==
*
dso_handle
)
{
dso_path
=
join
(
"/usr/local/cuda/lib/"
,
dso_path
);
dso_path
=
join
(
"/usr/local/cuda/lib/"
,
dso_path
);
*
dso_handle
=
dlopen
(
dso_path
.
c_str
(),
dynload_flags
);
*
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录