Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
ba4f43fd
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看板
提交
ba4f43fd
编写于
1月 28, 2019
作者:
S
sneaxiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile error in distributed mode
test=develop
上级
5f89ce7f
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
45 addition
and
98 deletion
+45
-98
paddle/fluid/operators/distributed/proto_encoder_helper.h
paddle/fluid/operators/distributed/proto_encoder_helper.h
+1
-1
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+41
-96
paddle/fluid/platform/nccl_helper.h
paddle/fluid/platform/nccl_helper.h
+1
-1
paddle/fluid/string/printf.h
paddle/fluid/string/printf.h
+2
-0
未找到文件。
paddle/fluid/operators/distributed/proto_encoder_helper.h
浏览文件 @
ba4f43fd
...
@@ -85,7 +85,7 @@ class ProtoEncodeHelper {
...
@@ -85,7 +85,7 @@ class ProtoEncodeHelper {
#define REPLACE_ENFORCE_GLOG 1
#define REPLACE_ENFORCE_GLOG 1
// Make sure callers didn't do operations that went over max_size promised
// Make sure callers didn't do operations that went over max_size promised
if
(
paddle
::
platform
::
is_error
(
p_
<=
limit_
))
{
if
(
paddle
::
platform
::
is_error
(
p_
<=
limit_
))
{
paddle
::
platform
::
throw_on_error
(
p_
<=
limit_
);
paddle
::
platform
::
throw_on_error
(
p_
<=
limit_
,
""
);
}
}
#undef REPLACE_ENFORCE_GLOG
#undef REPLACE_ENFORCE_GLOG
}
}
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
ba4f43fd
...
@@ -71,9 +71,8 @@ struct EnforceNotMet : public std::exception {
...
@@ -71,9 +71,8 @@ struct EnforceNotMet : public std::exception {
}
}
}
}
template
<
typename
...
ARGS
>
EnforceNotMet
(
const
std
::
string
&
str
,
const
char
*
f
,
int
l
)
{
EnforceNotMet
(
const
char
*
f
,
int
l
,
ARGS
...
args
)
{
Init
(
str
,
f
,
l
);
Init
(
string
::
Sprintf
(
args
...),
f
,
l
);
}
}
const
char
*
what
()
const
noexcept
override
{
return
err_str_
.
c_str
();
}
const
char
*
what
()
const
noexcept
override
{
return
err_str_
.
c_str
();
}
...
@@ -142,28 +141,23 @@ struct EOFException : public std::exception {
...
@@ -142,28 +141,23 @@ struct EOFException : public std::exception {
inline
bool
is_error
(
bool
stat
)
{
return
!
stat
;
}
inline
bool
is_error
(
bool
stat
)
{
return
!
stat
;
}
template
<
typename
...
Args
>
inline
void
throw_on_error
(
bool
stat
,
const
std
::
string
&
msg
)
{
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
bool
stat
,
const
Args
&
...
args
)
{
#ifndef REPLACE_ENFORCE_GLOG
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
string
::
Sprintf
(
args
...)
);
throw
std
::
runtime_error
(
msg
);
#else
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
msg
;
#endif
#endif
}
}
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
inline
bool
is_error
(
cudaError_t
e
)
{
return
UNLIKELY
(
e
)
;
}
inline
bool
is_error
(
cudaError_t
e
)
{
return
e
!=
cudaSuccess
;
}
template
<
typename
...
Args
>
inline
void
throw_on_error
(
cudaError_t
e
,
const
std
::
string
&
msg
)
{
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
cudaError_t
e
,
const
Args
&
...
args
)
{
#ifndef REPLACE_ENFORCE_GLOG
#ifndef REPLACE_ENFORCE_GLOG
throw
thrust
::
system_error
(
e
,
thrust
::
cuda_category
(),
throw
thrust
::
system_error
(
e
,
thrust
::
cuda_category
(),
msg
);
string
::
Sprintf
(
args
...));
#else
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
msg
;
#endif
#endif
}
}
...
@@ -171,14 +165,12 @@ inline bool is_error(curandStatus_t stat) {
...
@@ -171,14 +165,12 @@ inline bool is_error(curandStatus_t stat) {
return
stat
!=
CURAND_STATUS_SUCCESS
;
return
stat
!=
CURAND_STATUS_SUCCESS
;
}
}
template
<
typename
...
Args
>
inline
void
throw_on_error
(
curandStatus_t
stat
,
const
std
::
string
&
msg
)
{
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
curandStatus_t
stat
,
const
Args
&
...
args
)
{
#ifndef REPLACE_ENFORCE_GLOG
#ifndef REPLACE_ENFORCE_GLOG
throw
thrust
::
system_error
(
cudaErrorLaunchFailure
,
thrust
::
cuda_category
(),
throw
thrust
::
system_error
(
cudaErrorLaunchFailure
,
thrust
::
cuda_category
(),
string
::
Sprintf
(
args
...)
);
msg
);
#else
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
msg
;
#endif
#endif
}
}
...
@@ -186,14 +178,11 @@ inline bool is_error(cudnnStatus_t stat) {
...
@@ -186,14 +178,11 @@ inline bool is_error(cudnnStatus_t stat) {
return
stat
!=
CUDNN_STATUS_SUCCESS
;
return
stat
!=
CUDNN_STATUS_SUCCESS
;
}
}
template
<
typename
...
Args
>
inline
void
throw_on_error
(
cudnnStatus_t
stat
,
const
std
::
string
&
msg
)
{
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
cudnnStatus_t
stat
,
const
Args
&
...
args
)
{
#ifndef REPLACE_ENFORCE_GLOG
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
platform
::
dynload
::
cudnnGetErrorString
(
stat
)
+
throw
std
::
runtime_error
(
platform
::
dynload
::
cudnnGetErrorString
(
stat
)
+
msg
);
string
::
Sprintf
(
args
...));
#else
#else
LOG
(
FATAL
)
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
platform
::
dynload
::
cudnnGetErrorString
(
stat
)
<<
msg
;
#endif
#endif
}
}
...
@@ -201,9 +190,7 @@ inline bool is_error(cublasStatus_t stat) {
...
@@ -201,9 +190,7 @@ inline bool is_error(cublasStatus_t stat) {
return
stat
!=
CUBLAS_STATUS_SUCCESS
;
return
stat
!=
CUBLAS_STATUS_SUCCESS
;
}
}
template
<
typename
...
Args
>
inline
void
throw_on_error
(
cublasStatus_t
stat
,
const
std
::
string
&
msg
)
{
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
cublasStatus_t
stat
,
const
Args
&
...
args
)
{
std
::
string
err
;
std
::
string
err
;
if
(
stat
==
CUBLAS_STATUS_NOT_INITIALIZED
)
{
if
(
stat
==
CUBLAS_STATUS_NOT_INITIALIZED
)
{
err
=
"CUBLAS: not initialized, "
;
err
=
"CUBLAS: not initialized, "
;
...
@@ -225,87 +212,45 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
...
@@ -225,87 +212,45 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
err
=
"CUBLAS: license error, "
;
err
=
"CUBLAS: license error, "
;
}
}
#ifndef REPLACE_ENFORCE_GLOG
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
err
+
string
::
Sprintf
(
args
...)
);
throw
std
::
runtime_error
(
err
+
msg
);
#else
#else
LOG
(
FATAL
)
<<
err
<<
string
::
Sprintf
(
args
...)
;
LOG
(
FATAL
)
<<
err
<<
msg
;
#endif
#endif
}
}
#if !defined(__APPLE__) && !defined(_WIN32)
#if !defined(__APPLE__) && !defined(_WIN32)
template
<
typename
...
Args
>
inline
bool
is_error
(
ncclResult_t
nccl_result
)
{
inline
typename
std
::
enable_if
<
sizeof
...(
Args
)
!=
0
,
void
>::
type
throw_on_error
(
return
nccl_result
!=
ncclSuccess
;
ncclResult_t
stat
,
const
Args
&
...
args
)
{
}
if
(
stat
==
ncclSuccess
)
{
return
;
inline
void
throw_on_error
(
ncclResult_t
stat
,
const
std
::
string
&
msg
)
{
}
else
{
#ifndef REPLACE_ENFORCE_GLOG
#ifndef REPLACE_ENFORCE_GLOG
throw
std
::
runtime_error
(
platform
::
dynload
::
ncclGetErrorString
(
stat
)
+
throw
std
::
runtime_error
(
platform
::
dynload
::
ncclGetErrorString
(
stat
)
+
msg
);
string
::
Sprintf
(
args
...));
#else
#else
LOG
(
FATAL
)
<<
platform
::
dynload
::
ncclGetErrorString
(
stat
)
LOG
(
FATAL
)
<<
platform
::
dynload
::
ncclGetErrorString
(
stat
)
<<
msg
;
<<
string
::
Sprintf
(
args
...);
#endif
#endif
}
}
}
#endif // __APPLE__ and windows
#endif // __APPLE__ and windows
#endif // PADDLE_WITH_CUDA
#endif // PADDLE_WITH_CUDA
template
<
typename
T
>
inline
void
throw_on_error
(
T
e
)
{
throw_on_error
(
e
,
""
);
}
#define PADDLE_THROW(...) \
#define PADDLE_THROW(...) \
throw ::paddle::platform::EnforceNotMet(__FILE__, __LINE__, __VA_ARGS__)
throw ::paddle::platform::EnforceNotMet( \
::paddle::string::Sprintf(__VA_ARGS__), __FILE__, __LINE__)
#define __PADDLE_THROW_ERROR_I(_, _9, _8, _7, _6, _5, _4, _3, _2, X_, ...) X_;
#define __THROW_ON_ERROR_ONE_ARG(COND, ARG) \
::paddle::platform::throw_on_error(COND, ::paddle::string::Sprintf(ARG));
#ifdef _WIN32
#define __PADDLE_THROW_ON_ERROR(COND, ...) \
__THROW_ON_ERROR_ONE_ARG(COND, __VA_ARGS__)
#else // _WIN32
#define __PADDLE_THROW_ON_ERROR(COND, ...) \
__PADDLE_THROW_ERROR_I( \
__VA_ARGS__, ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
__THROW_ON_ERROR_ONE_ARG(COND, __VA_ARGS__))
#endif // _WIN32
#define __PADDLE_UNARY_COMPARE(COND, ...) \
do { \
auto __cond = COND; \
if (UNLIKELY(::paddle::platform::is_error(__cond))) { \
__PADDLE_THROW_ON_ERROR(__cond, __VA_ARGS__); \
} \
} while (0)
#ifndef REPLACE_ENFORCE_GLOG
#define PADDLE_ENFORCE(COND, ...) \
#define __PADDLE_ENFORCE_I(COND, ...) \
do { \
do { \
auto __cond__ = (COND); \
if (UNLIKELY(::paddle::platform::is_error(__cond__))) { \
try { \
try { \
__PADDLE_UNARY_COMPARE(COND, __VA_ARGS__); \
::paddle::platform::throw_on_error( \
__cond__, ::paddle::string::Sprintf(__VA_ARGS__)); \
} catch (...) { \
} catch (...) { \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
__FILE__, __LINE__); \
__FILE__, __LINE__); \
} \
} \
} \
} while (0)
} while (0)
#else
#define __PADDLE_ENFORCE_I(COND, ...) __PADDLE_UNARY_COMPARE(COND, __VA_ARGS__);
#endif // REPLACE_ENFORCE_GLOG
#define __PADDLE_ENFORCE(__args) __PADDLE_ENFORCE_I __args
#define PADDLE_ENFORCE(...) __PADDLE_ENFORCE((__VA_ARGS__))
#define PADDLE_THROW_EOF() \
#define PADDLE_THROW_EOF() \
do { \
do { \
throw ::paddle::platform::EOFException("There is no next data.", __FILE__, \
throw ::paddle::platform::EOFException("There is no next data.", __FILE__, \
...
...
paddle/fluid/platform/nccl_helper.h
浏览文件 @
ba4f43fd
...
@@ -64,7 +64,7 @@ class NCCLGroupGuard {
...
@@ -64,7 +64,7 @@ class NCCLGroupGuard {
}
}
inline
~
NCCLGroupGuard
()
{
inline
~
NCCLGroupGuard
()
{
CHECK_EQ
(
dynload
::
ncclGroupEnd
(),
ncclSuccess
);
PADDLE_ENFORCE
(
dynload
::
ncclGroupEnd
()
);
NCCLMutex
().
unlock
();
NCCLMutex
().
unlock
();
}
}
};
};
...
...
paddle/fluid/string/printf.h
浏览文件 @
ba4f43fd
...
@@ -84,6 +84,8 @@ void Fprintf(std::ostream& out, const char* fmt, const Args&... args) {
...
@@ -84,6 +84,8 @@ void Fprintf(std::ostream& out, const char* fmt, const Args&... args) {
tinyformat
::
vformat
(
out
,
fmt
,
tinyformat
::
makeFormatList
(
args
...));
tinyformat
::
vformat
(
out
,
fmt
,
tinyformat
::
makeFormatList
(
args
...));
}
}
inline
std
::
string
Sprintf
()
{
return
""
;
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
std
::
string
Sprintf
(
const
Args
&
...
args
)
{
std
::
string
Sprintf
(
const
Args
&
...
args
)
{
std
::
ostringstream
oss
;
std
::
ostringstream
oss
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录