Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8aef685b
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
8aef685b
编写于
4月 01, 2022
作者:
F
From00
提交者:
GitHub
4月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix compilation errors for gcc-54 (#41228)
* Fix compilation error for gcc-54 * Remove const for gpuStream_t
上级
5dae6da0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
32 addition
and
40 deletion
+32
-40
paddle/fluid/memory/allocation/allocator_facade.cc
paddle/fluid/memory/allocation/allocator_facade.cc
+11
-13
paddle/fluid/memory/allocation/allocator_facade.h
paddle/fluid/memory/allocation/allocator_facade.h
+5
-8
paddle/fluid/memory/allocation/stream_safe_cuda_allocator.cc
paddle/fluid/memory/allocation/stream_safe_cuda_allocator.cc
+5
-5
paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h
paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h
+5
-5
paddle/fluid/memory/malloc.cc
paddle/fluid/memory/malloc.cc
+3
-4
paddle/fluid/memory/malloc.h
paddle/fluid/memory/malloc.h
+3
-5
未找到文件。
paddle/fluid/memory/allocation/allocator_facade.cc
浏览文件 @
8aef685b
...
@@ -354,8 +354,7 @@ class AllocatorFacadePrivate {
...
@@ -354,8 +354,7 @@ class AllocatorFacadePrivate {
}
}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
bool
HasCUDAAllocator
(
const
platform
::
CUDAPlace
&
place
,
bool
HasCUDAAllocator
(
const
platform
::
CUDAPlace
&
place
,
gpuStream_t
stream
)
{
const
gpuStream_t
&
stream
)
{
auto
it
=
cuda_allocators_
.
find
(
place
);
auto
it
=
cuda_allocators_
.
find
(
place
);
if
(
it
==
cuda_allocators_
.
end
())
{
if
(
it
==
cuda_allocators_
.
end
())
{
return
false
;
return
false
;
...
@@ -366,7 +365,7 @@ class AllocatorFacadePrivate {
...
@@ -366,7 +365,7 @@ class AllocatorFacadePrivate {
}
}
const
std
::
shared_ptr
<
Allocator
>&
GetAllocator
(
const
std
::
shared_ptr
<
Allocator
>&
GetAllocator
(
const
platform
::
CUDAPlace
&
place
,
const
gpuStream_t
&
stream
,
const
platform
::
CUDAPlace
&
place
,
gpuStream_t
stream
,
bool
create_if_not_found
=
false
)
{
bool
create_if_not_found
=
false
)
{
if
(
LIKELY
(
!
IsCUDAGraphCapturing
()))
{
if
(
LIKELY
(
!
IsCUDAGraphCapturing
()))
{
if
(
stream
==
GetDefaultStream
(
place
))
{
if
(
stream
==
GetDefaultStream
(
place
))
{
...
@@ -407,14 +406,13 @@ class AllocatorFacadePrivate {
...
@@ -407,14 +406,13 @@ class AllocatorFacadePrivate {
return
iter
->
second
;
return
iter
->
second
;
}
}
const
gpuStream_t
&
GetDefaultStream
(
const
platform
::
CUDAPlace
&
place
)
const
{
gpuStream_t
GetDefaultStream
(
const
platform
::
CUDAPlace
&
place
)
const
{
const
std
::
shared_ptr
<
StreamSafeCUDAAllocator
>&
allocator
=
const
std
::
shared_ptr
<
StreamSafeCUDAAllocator
>&
allocator
=
GetDefaultStreamSafeCUDAAllocator
(
place
);
GetDefaultStreamSafeCUDAAllocator
(
place
);
return
allocator
->
GetDefaultStream
();
return
allocator
->
GetDefaultStream
();
}
}
void
SetDefaultStream
(
const
platform
::
CUDAPlace
&
place
,
void
SetDefaultStream
(
const
platform
::
CUDAPlace
&
place
,
gpuStream_t
stream
)
{
const
gpuStream_t
&
stream
)
{
const
std
::
shared_ptr
<
StreamSafeCUDAAllocator
>&
allocator
=
const
std
::
shared_ptr
<
StreamSafeCUDAAllocator
>&
allocator
=
GetDefaultStreamSafeCUDAAllocator
(
place
);
GetDefaultStreamSafeCUDAAllocator
(
place
);
allocator
->
SetDefaultStream
(
stream
);
allocator
->
SetDefaultStream
(
stream
);
...
@@ -424,7 +422,7 @@ class AllocatorFacadePrivate {
...
@@ -424,7 +422,7 @@ class AllocatorFacadePrivate {
}
}
void
RecordStream
(
std
::
shared_ptr
<
phi
::
Allocation
>
allocation
,
void
RecordStream
(
std
::
shared_ptr
<
phi
::
Allocation
>
allocation
,
const
gpuStream_t
&
stream
)
{
gpuStream_t
stream
)
{
std
::
shared_ptr
<
StreamSafeCUDAAllocation
>
stream_safe_cuda_allocation
=
std
::
shared_ptr
<
StreamSafeCUDAAllocation
>
stream_safe_cuda_allocation
=
std
::
dynamic_pointer_cast
<
StreamSafeCUDAAllocation
>
(
allocation
);
std
::
dynamic_pointer_cast
<
StreamSafeCUDAAllocation
>
(
allocation
);
if
(
stream_safe_cuda_allocation
!=
nullptr
)
{
if
(
stream_safe_cuda_allocation
!=
nullptr
)
{
...
@@ -434,7 +432,7 @@ class AllocatorFacadePrivate {
...
@@ -434,7 +432,7 @@ class AllocatorFacadePrivate {
}
}
}
}
const
gpuStream_t
GetStream
(
gpuStream_t
GetStream
(
const
std
::
shared_ptr
<
phi
::
Allocation
>&
allocation
)
const
{
const
std
::
shared_ptr
<
phi
::
Allocation
>&
allocation
)
const
{
const
std
::
shared_ptr
<
StreamSafeCUDAAllocation
>
const
std
::
shared_ptr
<
StreamSafeCUDAAllocation
>
stream_safe_cuda_allocation
=
stream_safe_cuda_allocation
=
...
@@ -1044,7 +1042,7 @@ bool AllocatorFacade::IsStreamSafeCUDAAllocatorUsed() {
...
@@ -1044,7 +1042,7 @@ bool AllocatorFacade::IsStreamSafeCUDAAllocatorUsed() {
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
uint64_t
AllocatorFacade
::
Release
(
const
platform
::
CUDAPlace
&
place
,
uint64_t
AllocatorFacade
::
Release
(
const
platform
::
CUDAPlace
&
place
,
const
gpuStream_t
&
stream
)
{
gpuStream_t
stream
)
{
AllocatorFacadePrivate
*
m
=
GetPrivate
();
AllocatorFacadePrivate
*
m
=
GetPrivate
();
if
(
!
m
->
IsStreamSafeCUDAAllocatorUsed
())
{
if
(
!
m
->
IsStreamSafeCUDAAllocatorUsed
())
{
VLOG
(
6
)
<<
"Warning: StreamSafeCUDAAllocator is not used!"
;
VLOG
(
6
)
<<
"Warning: StreamSafeCUDAAllocator is not used!"
;
...
@@ -1055,12 +1053,12 @@ uint64_t AllocatorFacade::Release(const platform::CUDAPlace& place,
...
@@ -1055,12 +1053,12 @@ uint64_t AllocatorFacade::Release(const platform::CUDAPlace& place,
}
}
void
AllocatorFacade
::
RecordStream
(
std
::
shared_ptr
<
phi
::
Allocation
>
allocation
,
void
AllocatorFacade
::
RecordStream
(
std
::
shared_ptr
<
phi
::
Allocation
>
allocation
,
const
gpuStream_t
&
stream
)
{
gpuStream_t
stream
)
{
GetPrivate
()
->
RecordStream
(
allocation
,
stream
);
GetPrivate
()
->
RecordStream
(
allocation
,
stream
);
}
}
const
std
::
shared_ptr
<
Allocator
>&
AllocatorFacade
::
GetAllocator
(
const
std
::
shared_ptr
<
Allocator
>&
AllocatorFacade
::
GetAllocator
(
const
platform
::
Place
&
place
,
const
gpuStream_t
&
stream
)
{
const
platform
::
Place
&
place
,
gpuStream_t
stream
)
{
AllocatorFacadePrivate
*
m
=
GetPrivate
();
AllocatorFacadePrivate
*
m
=
GetPrivate
();
if
(
!
m
->
IsStreamSafeCUDAAllocatorUsed
())
{
if
(
!
m
->
IsStreamSafeCUDAAllocatorUsed
())
{
...
@@ -1075,13 +1073,13 @@ const std::shared_ptr<Allocator>& AllocatorFacade::GetAllocator(
...
@@ -1075,13 +1073,13 @@ const std::shared_ptr<Allocator>& AllocatorFacade::GetAllocator(
return
m
->
GetAllocator
(
place
,
/* A non-zero num to choose allocator_ */
1
);
return
m
->
GetAllocator
(
place
,
/* A non-zero num to choose allocator_ */
1
);
}
}
const
gpuStream_t
AllocatorFacade
::
GetStream
(
gpuStream_t
AllocatorFacade
::
GetStream
(
const
std
::
shared_ptr
<
phi
::
Allocation
>&
allocation
)
const
{
const
std
::
shared_ptr
<
phi
::
Allocation
>&
allocation
)
const
{
return
GetPrivate
()
->
GetStream
(
allocation
);
return
GetPrivate
()
->
GetStream
(
allocation
);
}
}
void
AllocatorFacade
::
SetDefaultStream
(
const
platform
::
CUDAPlace
&
place
,
void
AllocatorFacade
::
SetDefaultStream
(
const
platform
::
CUDAPlace
&
place
,
const
gpuStream_t
&
stream
)
{
gpuStream_t
stream
)
{
if
(
m_
->
IsStreamSafeCUDAAllocatorUsed
())
{
if
(
m_
->
IsStreamSafeCUDAAllocatorUsed
())
{
m_
->
SetDefaultStream
(
place
,
stream
);
m_
->
SetDefaultStream
(
place
,
stream
);
}
}
...
...
paddle/fluid/memory/allocation/allocator_facade.h
浏览文件 @
8aef685b
...
@@ -80,15 +80,12 @@ class AllocatorFacade {
...
@@ -80,15 +80,12 @@ class AllocatorFacade {
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
// TODO(zhiqiu): change gpuStream_t to phi::Stream if needed.
// TODO(zhiqiu): change gpuStream_t to phi::Stream if needed.
uint64_t
Release
(
const
platform
::
CUDAPlace
&
place
,
const
gpuStream_t
&
stream
);
uint64_t
Release
(
const
platform
::
CUDAPlace
&
place
,
gpuStream_t
stream
);
void
RecordStream
(
std
::
shared_ptr
<
Allocation
>
allocation
,
void
RecordStream
(
std
::
shared_ptr
<
Allocation
>
allocation
,
gpuStream_t
stream
);
const
gpuStream_t
&
stream
);
const
std
::
shared_ptr
<
Allocator
>&
GetAllocator
(
const
platform
::
Place
&
place
,
const
std
::
shared_ptr
<
Allocator
>&
GetAllocator
(
const
platform
::
Place
&
place
,
const
gpuStream_t
&
stream
);
gpuStream_t
stream
);
const
gpuStream_t
GetStream
(
gpuStream_t
GetStream
(
const
std
::
shared_ptr
<
Allocation
>&
allocation
)
const
;
const
std
::
shared_ptr
<
Allocation
>&
allocation
)
const
;
void
SetDefaultStream
(
const
platform
::
CUDAPlace
&
place
,
gpuStream_t
stream
);
void
SetDefaultStream
(
const
platform
::
CUDAPlace
&
place
,
const
gpuStream_t
&
stream
);
#endif
#endif
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
...
...
paddle/fluid/memory/allocation/stream_safe_cuda_allocator.cc
浏览文件 @
8aef685b
...
@@ -33,7 +33,7 @@ StreamSafeCUDAAllocation::StreamSafeCUDAAllocation(
...
@@ -33,7 +33,7 @@ StreamSafeCUDAAllocation::StreamSafeCUDAAllocation(
owning_stream_
(
std
::
move
(
owning_stream
)),
owning_stream_
(
std
::
move
(
owning_stream
)),
allocator_
(
allocator
->
shared_from_this
())
{}
allocator_
(
allocator
->
shared_from_this
())
{}
void
StreamSafeCUDAAllocation
::
RecordStream
(
const
gpuStream_t
&
stream
)
{
void
StreamSafeCUDAAllocation
::
RecordStream
(
gpuStream_t
stream
)
{
VLOG
(
8
)
<<
"Try record stream "
<<
stream
<<
" for address "
<<
ptr
();
VLOG
(
8
)
<<
"Try record stream "
<<
stream
<<
" for address "
<<
ptr
();
if
(
stream
==
owning_stream_
)
{
if
(
stream
==
owning_stream_
)
{
return
;
return
;
...
@@ -90,7 +90,7 @@ bool StreamSafeCUDAAllocation::CanBeFreed() {
...
@@ -90,7 +90,7 @@ bool StreamSafeCUDAAllocation::CanBeFreed() {
return
true
;
return
true
;
}
}
const
gpuStream_t
&
StreamSafeCUDAAllocation
::
GetOwningStream
()
const
{
gpuStream_t
StreamSafeCUDAAllocation
::
GetOwningStream
()
const
{
return
owning_stream_
;
return
owning_stream_
;
}
}
...
@@ -102,7 +102,7 @@ void StreamSafeCUDAAllocation::RecordGraphCapturingStreams() {
...
@@ -102,7 +102,7 @@ void StreamSafeCUDAAllocation::RecordGraphCapturingStreams() {
}
}
void
StreamSafeCUDAAllocation
::
RecordStreamWithNoGraphCapturing
(
void
StreamSafeCUDAAllocation
::
RecordStreamWithNoGraphCapturing
(
const
gpuStream_t
&
stream
)
{
gpuStream_t
stream
)
{
gpuEvent_t
record_event
;
gpuEvent_t
record_event
;
auto
it
=
outstanding_event_map_
.
find
(
stream
);
auto
it
=
outstanding_event_map_
.
find
(
stream
);
if
(
it
==
outstanding_event_map_
.
end
())
{
if
(
it
==
outstanding_event_map_
.
end
())
{
...
@@ -154,11 +154,11 @@ StreamSafeCUDAAllocator::~StreamSafeCUDAAllocator() {
...
@@ -154,11 +154,11 @@ StreamSafeCUDAAllocator::~StreamSafeCUDAAllocator() {
bool
StreamSafeCUDAAllocator
::
IsAllocThreadSafe
()
const
{
return
true
;
}
bool
StreamSafeCUDAAllocator
::
IsAllocThreadSafe
()
const
{
return
true
;
}
const
gpuStream_t
&
StreamSafeCUDAAllocator
::
GetDefaultStream
()
const
{
gpuStream_t
StreamSafeCUDAAllocator
::
GetDefaultStream
()
const
{
return
default_stream_
;
return
default_stream_
;
}
}
void
StreamSafeCUDAAllocator
::
SetDefaultStream
(
const
gpuStream_t
&
stream
)
{
void
StreamSafeCUDAAllocator
::
SetDefaultStream
(
gpuStream_t
stream
)
{
default_stream_
=
stream
;
default_stream_
=
stream
;
}
}
...
...
paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h
浏览文件 @
8aef685b
...
@@ -39,13 +39,13 @@ class StreamSafeCUDAAllocation : public Allocation {
...
@@ -39,13 +39,13 @@ class StreamSafeCUDAAllocation : public Allocation {
gpuStream_t
owning_stream
,
gpuStream_t
owning_stream
,
StreamSafeCUDAAllocator
*
allocator
);
StreamSafeCUDAAllocator
*
allocator
);
void
RecordStream
(
const
gpuStream_t
&
stream
);
void
RecordStream
(
gpuStream_t
stream
);
bool
CanBeFreed
();
bool
CanBeFreed
();
const
gpuStream_t
&
GetOwningStream
()
const
;
gpuStream_t
GetOwningStream
()
const
;
private:
private:
void
RecordGraphCapturingStreams
();
void
RecordGraphCapturingStreams
();
void
RecordStreamWithNoGraphCapturing
(
const
gpuStream_t
&
stream
);
void
RecordStreamWithNoGraphCapturing
(
gpuStream_t
stream
);
DecoratedAllocationPtr
underlying_allocation_
;
DecoratedAllocationPtr
underlying_allocation_
;
std
::
set
<
gpuStream_t
>
graph_capturing_stream_set_
;
std
::
set
<
gpuStream_t
>
graph_capturing_stream_set_
;
std
::
map
<
gpuStream_t
,
gpuEvent_t
>
outstanding_event_map_
;
std
::
map
<
gpuStream_t
,
gpuEvent_t
>
outstanding_event_map_
;
...
@@ -66,8 +66,8 @@ class StreamSafeCUDAAllocator
...
@@ -66,8 +66,8 @@ class StreamSafeCUDAAllocator
~
StreamSafeCUDAAllocator
();
~
StreamSafeCUDAAllocator
();
bool
IsAllocThreadSafe
()
const
override
;
bool
IsAllocThreadSafe
()
const
override
;
const
gpuStream_t
&
GetDefaultStream
()
const
;
gpuStream_t
GetDefaultStream
()
const
;
void
SetDefaultStream
(
const
gpuStream_t
&
stream
);
void
SetDefaultStream
(
gpuStream_t
stream
);
protected:
protected:
phi
::
Allocation
*
AllocateImpl
(
size_t
size
)
override
;
phi
::
Allocation
*
AllocateImpl
(
size_t
size
)
override
;
...
...
paddle/fluid/memory/malloc.cc
浏览文件 @
8aef685b
...
@@ -57,17 +57,16 @@ void* GetBasePtr(const std::shared_ptr<Allocation>& allocation) {
...
@@ -57,17 +57,16 @@ void* GetBasePtr(const std::shared_ptr<Allocation>& allocation) {
}
}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
uint64_t
Release
(
const
platform
::
CUDAPlace
&
place
,
const
gpuStream_t
&
stream
)
{
uint64_t
Release
(
const
platform
::
CUDAPlace
&
place
,
gpuStream_t
stream
)
{
return
allocation
::
AllocatorFacade
::
Instance
().
Release
(
place
,
stream
);
return
allocation
::
AllocatorFacade
::
Instance
().
Release
(
place
,
stream
);
}
}
void
RecordStream
(
std
::
shared_ptr
<
Allocation
>
allocation
,
void
RecordStream
(
std
::
shared_ptr
<
Allocation
>
allocation
,
gpuStream_t
stream
)
{
const
gpuStream_t
&
stream
)
{
return
allocation
::
AllocatorFacade
::
Instance
().
RecordStream
(
allocation
,
return
allocation
::
AllocatorFacade
::
Instance
().
RecordStream
(
allocation
,
stream
);
stream
);
}
}
const
gpuStream_t
GetStream
(
const
std
::
shared_ptr
<
Allocation
>&
allocation
)
{
gpuStream_t
GetStream
(
const
std
::
shared_ptr
<
Allocation
>&
allocation
)
{
return
allocation
::
AllocatorFacade
::
Instance
().
GetStream
(
allocation
);
return
allocation
::
AllocatorFacade
::
Instance
().
GetStream
(
allocation
);
}
}
...
...
paddle/fluid/memory/malloc.h
浏览文件 @
8aef685b
...
@@ -50,13 +50,11 @@ extern bool InSameStream(const std::shared_ptr<Allocation>& allocation,
...
@@ -50,13 +50,11 @@ extern bool InSameStream(const std::shared_ptr<Allocation>& allocation,
extern
void
*
GetBasePtr
(
const
std
::
shared_ptr
<
Allocation
>&
allocation
);
extern
void
*
GetBasePtr
(
const
std
::
shared_ptr
<
Allocation
>&
allocation
);
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
extern
uint64_t
Release
(
const
platform
::
CUDAPlace
&
place
,
extern
uint64_t
Release
(
const
platform
::
CUDAPlace
&
place
,
gpuStream_t
stream
);
const
gpuStream_t
&
stream
);
void
RecordStream
(
std
::
shared_ptr
<
Allocation
>
allocation
,
void
RecordStream
(
std
::
shared_ptr
<
Allocation
>
allocation
,
gpuStream_t
stream
);
const
gpuStream_t
&
stream
);
const
gpuStream_t
GetStream
(
const
std
::
shared_ptr
<
Allocation
>&
allocation
);
gpuStream_t
GetStream
(
const
std
::
shared_ptr
<
Allocation
>&
allocation
);
#endif
#endif
}
// namespace memory
}
// namespace memory
}
// namespace paddle
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录