未验证 提交 8aef685b 编写于 作者: F From00 提交者: GitHub

Fix compilation errors for gcc-54 (#41228)

* Fix compilation error for gcc-54

* Remove const for gpuStream_t
上级 5dae6da0
......@@ -354,8 +354,7 @@ class AllocatorFacadePrivate {
}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
bool HasCUDAAllocator(const platform::CUDAPlace& place,
const gpuStream_t& stream) {
bool HasCUDAAllocator(const platform::CUDAPlace& place, gpuStream_t stream) {
auto it = cuda_allocators_.find(place);
if (it == cuda_allocators_.end()) {
return false;
......@@ -366,7 +365,7 @@ class AllocatorFacadePrivate {
}
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) {
if (LIKELY(!IsCUDAGraphCapturing())) {
if (stream == GetDefaultStream(place)) {
......@@ -407,14 +406,13 @@ class AllocatorFacadePrivate {
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 =
GetDefaultStreamSafeCUDAAllocator(place);
return allocator->GetDefaultStream();
}
void SetDefaultStream(const platform::CUDAPlace& place,
const gpuStream_t& stream) {
void SetDefaultStream(const platform::CUDAPlace& place, gpuStream_t stream) {
const std::shared_ptr<StreamSafeCUDAAllocator>& allocator =
GetDefaultStreamSafeCUDAAllocator(place);
allocator->SetDefaultStream(stream);
......@@ -424,7 +422,7 @@ class AllocatorFacadePrivate {
}
void RecordStream(std::shared_ptr<phi::Allocation> allocation,
const gpuStream_t& stream) {
gpuStream_t stream) {
std::shared_ptr<StreamSafeCUDAAllocation> stream_safe_cuda_allocation =
std::dynamic_pointer_cast<StreamSafeCUDAAllocation>(allocation);
if (stream_safe_cuda_allocation != nullptr) {
......@@ -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<StreamSafeCUDAAllocation>
stream_safe_cuda_allocation =
......@@ -1044,7 +1042,7 @@ bool AllocatorFacade::IsStreamSafeCUDAAllocatorUsed() {
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
uint64_t AllocatorFacade::Release(const platform::CUDAPlace& place,
const gpuStream_t& stream) {
gpuStream_t stream) {
AllocatorFacadePrivate* m = GetPrivate();
if (!m->IsStreamSafeCUDAAllocatorUsed()) {
VLOG(6) << "Warning: StreamSafeCUDAAllocator is not used!";
......@@ -1055,12 +1053,12 @@ uint64_t AllocatorFacade::Release(const platform::CUDAPlace& place,
}
void AllocatorFacade::RecordStream(std::shared_ptr<phi::Allocation> allocation,
const gpuStream_t& stream) {
gpuStream_t stream) {
GetPrivate()->RecordStream(allocation, stream);
}
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();
if (!m->IsStreamSafeCUDAAllocatorUsed()) {
......@@ -1075,13 +1073,13 @@ const std::shared_ptr<Allocator>& AllocatorFacade::GetAllocator(
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 {
return GetPrivate()->GetStream(allocation);
}
void AllocatorFacade::SetDefaultStream(const platform::CUDAPlace& place,
const gpuStream_t& stream) {
gpuStream_t stream) {
if (m_->IsStreamSafeCUDAAllocatorUsed()) {
m_->SetDefaultStream(place, stream);
}
......
......@@ -80,15 +80,12 @@ class AllocatorFacade {
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
// TODO(zhiqiu): change gpuStream_t to phi::Stream if needed.
uint64_t Release(const platform::CUDAPlace& place, const gpuStream_t& stream);
void RecordStream(std::shared_ptr<Allocation> allocation,
const gpuStream_t& stream);
uint64_t Release(const platform::CUDAPlace& place, gpuStream_t stream);
void RecordStream(std::shared_ptr<Allocation> allocation, gpuStream_t stream);
const std::shared_ptr<Allocator>& GetAllocator(const platform::Place& place,
const gpuStream_t& stream);
const gpuStream_t GetStream(
const std::shared_ptr<Allocation>& allocation) const;
void SetDefaultStream(const platform::CUDAPlace& place,
const gpuStream_t& stream);
gpuStream_t stream);
gpuStream_t GetStream(const std::shared_ptr<Allocation>& allocation) const;
void SetDefaultStream(const platform::CUDAPlace& place, gpuStream_t stream);
#endif
#ifdef PADDLE_WITH_CUDA
......
......@@ -33,7 +33,7 @@ StreamSafeCUDAAllocation::StreamSafeCUDAAllocation(
owning_stream_(std::move(owning_stream)),
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();
if (stream == owning_stream_) {
return;
......@@ -90,7 +90,7 @@ bool StreamSafeCUDAAllocation::CanBeFreed() {
return true;
}
const gpuStream_t& StreamSafeCUDAAllocation::GetOwningStream() const {
gpuStream_t StreamSafeCUDAAllocation::GetOwningStream() const {
return owning_stream_;
}
......@@ -102,7 +102,7 @@ void StreamSafeCUDAAllocation::RecordGraphCapturingStreams() {
}
void StreamSafeCUDAAllocation::RecordStreamWithNoGraphCapturing(
const gpuStream_t& stream) {
gpuStream_t stream) {
gpuEvent_t record_event;
auto it = outstanding_event_map_.find(stream);
if (it == outstanding_event_map_.end()) {
......@@ -154,11 +154,11 @@ StreamSafeCUDAAllocator::~StreamSafeCUDAAllocator() {
bool StreamSafeCUDAAllocator::IsAllocThreadSafe() const { return true; }
const gpuStream_t& StreamSafeCUDAAllocator::GetDefaultStream() const {
gpuStream_t StreamSafeCUDAAllocator::GetDefaultStream() const {
return default_stream_;
}
void StreamSafeCUDAAllocator::SetDefaultStream(const gpuStream_t& stream) {
void StreamSafeCUDAAllocator::SetDefaultStream(gpuStream_t stream) {
default_stream_ = stream;
}
......
......@@ -39,13 +39,13 @@ class StreamSafeCUDAAllocation : public Allocation {
gpuStream_t owning_stream,
StreamSafeCUDAAllocator *allocator);
void RecordStream(const gpuStream_t &stream);
void RecordStream(gpuStream_t stream);
bool CanBeFreed();
const gpuStream_t &GetOwningStream() const;
gpuStream_t GetOwningStream() const;
private:
void RecordGraphCapturingStreams();
void RecordStreamWithNoGraphCapturing(const gpuStream_t &stream);
void RecordStreamWithNoGraphCapturing(gpuStream_t stream);
DecoratedAllocationPtr underlying_allocation_;
std::set<gpuStream_t> graph_capturing_stream_set_;
std::map<gpuStream_t, gpuEvent_t> outstanding_event_map_;
......@@ -66,8 +66,8 @@ class StreamSafeCUDAAllocator
~StreamSafeCUDAAllocator();
bool IsAllocThreadSafe() const override;
const gpuStream_t &GetDefaultStream() const;
void SetDefaultStream(const gpuStream_t &stream);
gpuStream_t GetDefaultStream() const;
void SetDefaultStream(gpuStream_t stream);
protected:
phi::Allocation *AllocateImpl(size_t size) override;
......
......@@ -57,17 +57,16 @@ void* GetBasePtr(const std::shared_ptr<Allocation>& allocation) {
}
#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);
}
void RecordStream(std::shared_ptr<Allocation> allocation,
const gpuStream_t& stream) {
void RecordStream(std::shared_ptr<Allocation> allocation, gpuStream_t stream) {
return allocation::AllocatorFacade::Instance().RecordStream(allocation,
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);
}
......
......@@ -50,13 +50,11 @@ extern bool InSameStream(const std::shared_ptr<Allocation>& allocation,
extern void* GetBasePtr(const std::shared_ptr<Allocation>& allocation);
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
extern uint64_t Release(const platform::CUDAPlace& place,
const gpuStream_t& stream);
extern uint64_t Release(const platform::CUDAPlace& place, gpuStream_t stream);
void RecordStream(std::shared_ptr<Allocation> allocation,
const gpuStream_t& stream);
void RecordStream(std::shared_ptr<Allocation> allocation, gpuStream_t stream);
const gpuStream_t GetStream(const std::shared_ptr<Allocation>& allocation);
gpuStream_t GetStream(const std::shared_ptr<Allocation>& allocation);
#endif
} // namespace memory
} // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册