diff --git a/paddle/fluid/memory/allocation/cuda_device_context_allocator.h b/paddle/fluid/memory/allocation/cuda_device_context_allocator.h index a27ac3d6f482081ea2015aac375c93e0fedcfc28..f7e74e0421281300797411354cca49901b94c406 100644 --- a/paddle/fluid/memory/allocation/cuda_device_context_allocator.h +++ b/paddle/fluid/memory/allocation/cuda_device_context_allocator.h @@ -44,13 +44,10 @@ class GPUContextAllocation : public Allocation { underlying_allocation_(std::move(allocation)) {} ~GPUContextAllocation() { - try { - PADDLE_ENFORCE_NOT_NULL( - dev_ctx_, - platform::errors::PreconditionNotMet( - "Device context is not set for GPUContextAllocation")); - } catch (std::exception &e) { - } + PADDLE_ENFORCE_NOT_NULL( + dev_ctx_, + platform::errors::PreconditionNotMet( + "Device context is not set for GPUContextAllocation")); auto *p_allocation = underlying_allocation_.release(); VLOG(4) << "Adding callback to delete GPUContextAllocation at " << p_allocation; @@ -89,17 +86,13 @@ class GPUContextAllocator : public Allocator { } ~GPUContextAllocator() { - try { - if (event_) { - platform::CUDADeviceGuard guard(place_.device); + if (event_) { + platform::CUDADeviceGuard guard(place_.device); #ifdef PADDLE_WITH_HIP - - PADDLE_ENFORCE_GPU_SUCCESS(hipEventDestroy(event_)); + PADDLE_ENFORCE_GPU_SUCCESS(hipEventDestroy(event_)); #else - PADDLE_ENFORCE_GPU_SUCCESS(cudaEventDestroy(event_)); + PADDLE_ENFORCE_GPU_SUCCESS(cudaEventDestroy(event_)); #endif - } - } catch (std::exception &e) { } } diff --git a/paddle/fluid/memory/allocation/mmap_allocator.cc b/paddle/fluid/memory/allocation/mmap_allocator.cc index 1a6eaeaac21aef548acc3b9ada1149cf7d2fb7a1..c0747a12984f41cbfc2a2e5a540b7cf22f7580fb 100644 --- a/paddle/fluid/memory/allocation/mmap_allocator.cc +++ b/paddle/fluid/memory/allocation/mmap_allocator.cc @@ -216,26 +216,19 @@ void RefcountedMemoryMapAllocation::close() { } MemoryMapWriterAllocation::~MemoryMapWriterAllocation() { - try { - PADDLE_ENFORCE_NE( - munmap(this->ptr(), this->size()), - -1, - platform::errors::Unavailable( - "could not unmap the shared memory file %s", this->ipc_name())); - } catch (std::exception &e) { - } + PADDLE_ENFORCE_NE( + munmap(this->ptr(), this->size()), + -1, + platform::errors::Unavailable("could not unmap the shared memory file %s", + this->ipc_name())); } MemoryMapReaderAllocation::~MemoryMapReaderAllocation() { - try { - PADDLE_ENFORCE_NE( - - munmap(this->ptr(), this->size()), - -1, - platform::errors::Unavailable( - "could not unmap the shared memory file %s", this->ipc_name())); - } catch (std::exception &e) { - } + PADDLE_ENFORCE_NE( + munmap(this->ptr(), this->size()), + -1, + platform::errors::Unavailable("could not unmap the shared memory file %s", + this->ipc_name())); /* Here we do not pay attention to the result of shm_unlink, because the memory mapped file may have been cleared due to the MemoryMapFdSet::Clear() */ diff --git a/paddle/fluid/memory/allocation/mmap_allocator_test.cc b/paddle/fluid/memory/allocation/mmap_allocator_test.cc index a8c20e8d04d7b27660df03d4fa061dc5448775e1..bcb02e0479290c92ab064ae1a995758c1d079161 100644 --- a/paddle/fluid/memory/allocation/mmap_allocator_test.cc +++ b/paddle/fluid/memory/allocation/mmap_allocator_test.cc @@ -24,7 +24,6 @@ namespace allocation { TEST(MemoryMapAllocation, test_allocation_base) { size_t data_size = 4UL * 1024; - // 1. allocate writer holader auto mmap_writer_holder = AllocateMemoryMapWriterAllocation(data_size); std::string ipc_name = mmap_writer_holder->ipc_name();