From a3e89eff0dcd10a6b30b770f786d5ebd50925140 Mon Sep 17 00:00:00 2001 From: Yangrl <2535184404@qq.com> Date: Thu, 23 Mar 2023 11:06:54 +0000 Subject: [PATCH 1/6] this is a test pr, test=develop --- test.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test.cc diff --git a/test.cc b/test.cc new file mode 100644 index 00000000000000..acb0c53d8267fe --- /dev/null +++ b/test.cc @@ -0,0 +1,17 @@ +/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +namespace kiki { +void getVal() {} +} // namespace kiki From 8ba97bad19a41a6eb63ed56dcd18b7fdb6bccbcc Mon Sep 17 00:00:00 2001 From: Yangrl <2535184404@qq.com> Date: Mon, 27 Mar 2023 07:28:39 +0000 Subject: [PATCH 2/6] solve the four [-Wterminate] warning, test=develop --- .../cuda_device_context_allocator.h | 22 ++++++++++------ .../fluid/memory/allocation/mmap_allocator.cc | 26 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/paddle/fluid/memory/allocation/cuda_device_context_allocator.h b/paddle/fluid/memory/allocation/cuda_device_context_allocator.h index f7e74e04212813..928a7d4e0e2ddd 100644 --- a/paddle/fluid/memory/allocation/cuda_device_context_allocator.h +++ b/paddle/fluid/memory/allocation/cuda_device_context_allocator.h @@ -44,10 +44,13 @@ class GPUContextAllocation : public Allocation { underlying_allocation_(std::move(allocation)) {} ~GPUContextAllocation() { - PADDLE_ENFORCE_NOT_NULL( - dev_ctx_, - platform::errors::PreconditionNotMet( - "Device context is not set for GPUContextAllocation")); + try { + PADDLE_ENFORCE_NOT_NULL( + dev_ctx_, + platform::errors::PreconditionNotMet( + "Device context is not set for GPUContextAllocation")); + } catch (std::exception &e) { + } auto *p_allocation = underlying_allocation_.release(); VLOG(4) << "Adding callback to delete GPUContextAllocation at " << p_allocation; @@ -86,13 +89,16 @@ class GPUContextAllocator : public Allocator { } ~GPUContextAllocator() { - if (event_) { - platform::CUDADeviceGuard guard(place_.device); + try { + 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 c0747a12984f41..f367fa729a2f26 100644 --- a/paddle/fluid/memory/allocation/mmap_allocator.cc +++ b/paddle/fluid/memory/allocation/mmap_allocator.cc @@ -216,19 +216,25 @@ void RefcountedMemoryMapAllocation::close() { } MemoryMapWriterAllocation::~MemoryMapWriterAllocation() { - PADDLE_ENFORCE_NE( - munmap(this->ptr(), this->size()), - -1, - platform::errors::Unavailable("could not unmap the shared memory file %s", - this->ipc_name())); + 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) { + } } MemoryMapReaderAllocation::~MemoryMapReaderAllocation() { - PADDLE_ENFORCE_NE( - munmap(this->ptr(), this->size()), - -1, - platform::errors::Unavailable("could not unmap the shared memory file %s", - this->ipc_name())); + 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) { + } /* 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() */ From 1f1f6267a0356c3db413af33da0372e38872e3e4 Mon Sep 17 00:00:00 2001 From: Yangrl <2535184404@qq.com> Date: Mon, 27 Mar 2023 07:52:01 +0000 Subject: [PATCH 3/6] solve the four [-Wterminate] warning, test=develop --- paddle/fluid/memory/allocation/cuda_device_context_allocator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/fluid/memory/allocation/cuda_device_context_allocator.h b/paddle/fluid/memory/allocation/cuda_device_context_allocator.h index 928a7d4e0e2ddd..a27ac3d6f48208 100644 --- a/paddle/fluid/memory/allocation/cuda_device_context_allocator.h +++ b/paddle/fluid/memory/allocation/cuda_device_context_allocator.h @@ -93,6 +93,7 @@ class GPUContextAllocator : public Allocator { if (event_) { platform::CUDADeviceGuard guard(place_.device); #ifdef PADDLE_WITH_HIP + PADDLE_ENFORCE_GPU_SUCCESS(hipEventDestroy(event_)); #else PADDLE_ENFORCE_GPU_SUCCESS(cudaEventDestroy(event_)); From f5f12dfa04ec32349ae5cf285b52a4c825b2c4f2 Mon Sep 17 00:00:00 2001 From: Yangrl <2535184404@qq.com> Date: Mon, 27 Mar 2023 08:17:13 +0000 Subject: [PATCH 4/6] handle the four [-Wterminate] warning, test=develop --- paddle/fluid/memory/allocation/mmap_allocator_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/fluid/memory/allocation/mmap_allocator_test.cc b/paddle/fluid/memory/allocation/mmap_allocator_test.cc index bcb02e0479290c..a8c20e8d04d7b2 100644 --- a/paddle/fluid/memory/allocation/mmap_allocator_test.cc +++ b/paddle/fluid/memory/allocation/mmap_allocator_test.cc @@ -24,6 +24,7 @@ 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(); From fe7815b62bb90e6f4705416a39d46b132e848451 Mon Sep 17 00:00:00 2001 From: Yangrl <2535184404@qq.com> Date: Mon, 27 Mar 2023 08:53:26 +0000 Subject: [PATCH 5/6] handle the four [-Wterminate] warning, test=develop --- paddle/fluid/memory/allocation/mmap_allocator.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/fluid/memory/allocation/mmap_allocator.cc b/paddle/fluid/memory/allocation/mmap_allocator.cc index f367fa729a2f26..1a6eaeaac21aef 100644 --- a/paddle/fluid/memory/allocation/mmap_allocator.cc +++ b/paddle/fluid/memory/allocation/mmap_allocator.cc @@ -229,6 +229,7 @@ MemoryMapWriterAllocation::~MemoryMapWriterAllocation() { MemoryMapReaderAllocation::~MemoryMapReaderAllocation() { try { PADDLE_ENFORCE_NE( + munmap(this->ptr(), this->size()), -1, platform::errors::Unavailable( From c6a8f4d8f17806f71ed0482e90293db8695eefd3 Mon Sep 17 00:00:00 2001 From: Yangrl <2535184404@qq.com> Date: Tue, 28 Mar 2023 02:23:05 +0000 Subject: [PATCH 6/6] solve the four [-Wterminate]warning, test=develop --- test.cc | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 test.cc diff --git a/test.cc b/test.cc deleted file mode 100644 index acb0c53d8267fe..00000000000000 --- a/test.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -namespace kiki { -void getVal() {} -} // namespace kiki