提交 0ebf739f 编写于 作者: Z zhangbo9674 提交者: GitHub

Revert "Fix_Linux_[-Wterminate]warning (#52186)"

This reverts commit 225f1af2.
上级 225f1af2
...@@ -44,13 +44,10 @@ class GPUContextAllocation : public Allocation { ...@@ -44,13 +44,10 @@ class GPUContextAllocation : public Allocation {
underlying_allocation_(std::move(allocation)) {} underlying_allocation_(std::move(allocation)) {}
~GPUContextAllocation() { ~GPUContextAllocation() {
try { PADDLE_ENFORCE_NOT_NULL(
PADDLE_ENFORCE_NOT_NULL( dev_ctx_,
dev_ctx_, platform::errors::PreconditionNotMet(
platform::errors::PreconditionNotMet( "Device context is not set for GPUContextAllocation"));
"Device context is not set for GPUContextAllocation"));
} catch (std::exception &e) {
}
auto *p_allocation = underlying_allocation_.release(); auto *p_allocation = underlying_allocation_.release();
VLOG(4) << "Adding callback to delete GPUContextAllocation at " VLOG(4) << "Adding callback to delete GPUContextAllocation at "
<< p_allocation; << p_allocation;
...@@ -89,17 +86,13 @@ class GPUContextAllocator : public Allocator { ...@@ -89,17 +86,13 @@ class GPUContextAllocator : public Allocator {
} }
~GPUContextAllocator() { ~GPUContextAllocator() {
try { if (event_) {
if (event_) { platform::CUDADeviceGuard guard(place_.device);
platform::CUDADeviceGuard guard(place_.device);
#ifdef PADDLE_WITH_HIP #ifdef PADDLE_WITH_HIP
PADDLE_ENFORCE_GPU_SUCCESS(hipEventDestroy(event_));
PADDLE_ENFORCE_GPU_SUCCESS(hipEventDestroy(event_));
#else #else
PADDLE_ENFORCE_GPU_SUCCESS(cudaEventDestroy(event_)); PADDLE_ENFORCE_GPU_SUCCESS(cudaEventDestroy(event_));
#endif #endif
}
} catch (std::exception &e) {
} }
} }
......
...@@ -216,26 +216,19 @@ void RefcountedMemoryMapAllocation::close() { ...@@ -216,26 +216,19 @@ void RefcountedMemoryMapAllocation::close() {
} }
MemoryMapWriterAllocation::~MemoryMapWriterAllocation() { MemoryMapWriterAllocation::~MemoryMapWriterAllocation() {
try { PADDLE_ENFORCE_NE(
PADDLE_ENFORCE_NE( munmap(this->ptr(), this->size()),
munmap(this->ptr(), this->size()), -1,
-1, platform::errors::Unavailable("could not unmap the shared memory file %s",
platform::errors::Unavailable( this->ipc_name()));
"could not unmap the shared memory file %s", this->ipc_name()));
} catch (std::exception &e) {
}
} }
MemoryMapReaderAllocation::~MemoryMapReaderAllocation() { MemoryMapReaderAllocation::~MemoryMapReaderAllocation() {
try { PADDLE_ENFORCE_NE(
PADDLE_ENFORCE_NE( munmap(this->ptr(), this->size()),
-1,
munmap(this->ptr(), this->size()), platform::errors::Unavailable("could not unmap the shared memory file %s",
-1, this->ipc_name()));
platform::errors::Unavailable(
"could not unmap the shared memory file %s", this->ipc_name()));
} catch (std::exception &e) {
}
/* Here we do not pay attention to the result of shm_unlink, /* Here we do not pay attention to the result of shm_unlink,
because the memory mapped file may have been cleared due to the because the memory mapped file may have been cleared due to the
MemoryMapFdSet::Clear() */ MemoryMapFdSet::Clear() */
......
...@@ -24,7 +24,6 @@ namespace allocation { ...@@ -24,7 +24,6 @@ namespace allocation {
TEST(MemoryMapAllocation, test_allocation_base) { TEST(MemoryMapAllocation, test_allocation_base) {
size_t data_size = 4UL * 1024; size_t data_size = 4UL * 1024;
// 1. allocate writer holader // 1. allocate writer holader
auto mmap_writer_holder = AllocateMemoryMapWriterAllocation(data_size); auto mmap_writer_holder = AllocateMemoryMapWriterAllocation(data_size);
std::string ipc_name = mmap_writer_holder->ipc_name(); std::string ipc_name = mmap_writer_holder->ipc_name();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册