From 502dce7b55a122830a91cf29012574789adade16 Mon Sep 17 00:00:00 2001 From: caifubi Date: Wed, 2 Dec 2020 19:54:02 +0800 Subject: [PATCH] PyNative Hccl Release --- .../kernel_compiler/hccl/hccl_context.cc | 2 ++ .../device/ascend/ascend_kernel_runtime.cc | 17 +---------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc b/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc index ed1f79e37b..58bceb4753 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc @@ -60,6 +60,8 @@ bool HcclContext::Finalize() { MS_LOG(ERROR) << "HcclComm destroy failed, ret:" << hccl_result; return false; } + MS_LOG(INFO) << "HcclComm destroy success"; + hccl_comm_ = nullptr; return true; } } // namespace kernel diff --git a/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc b/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc index e8bcead66c..11d1b24d52 100644 --- a/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc +++ b/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc @@ -292,6 +292,7 @@ void AscendKernelRuntime::ReleaseDeviceRes() { mem_manager_->FreeDeviceMemory(); } + (void)DestroySingleOpHccl(); (void)DestroyHccl(); (void)ResetDevice(); (void)ProfilingManager::GetInstance().StopProfiling(); @@ -802,11 +803,6 @@ bool AscendKernelRuntime::ResetDevice() { stream_ = nullptr; } - if (!DestroySingleOpHccl()) { - MS_LOG(ERROR) << "Destroy hccl failed"; - return false; - } - if (rt_context_ != nullptr) { auto ret = rtCtxDestroy(rt_context_); if (ret != RT_ERROR_NONE) { @@ -861,21 +857,10 @@ bool AscendKernelRuntime::HcclInit() { } bool AscendKernelRuntime::DestroySingleOpHccl() { - auto context_ptr = MsContext::GetInstance(); - MS_EXCEPTION_IF_NULL(context_ptr); - if (context_ptr->get_param(MS_CTX_EXECUTION_MODE) != kPynativeMode) { - return true; - } - if (!NeedDestroyHccl()) { - MS_LOG(INFO) << "Hccl is not enable, no need to close."; - return true; - } if (!kernel::HcclContext::GetInstance().Finalize()) { MS_LOG(ERROR) << "Hccl finalize failed"; return false; } - MS_LOG(INFO) << "Hccl destroy successful."; - context_ptr->set_param(MS_CTX_ENABLE_HCCL, false); return true; }