!9410 Hccl resource release

From: @jojobugfree
Reviewed-by: @kisnwang,@jjfeing
Signed-off-by: @jjfeing
This commit is contained in:
mindspore-ci-bot 2020-12-03 16:45:30 +08:00 committed by Gitee
commit 92d8d3af47
2 changed files with 3 additions and 16 deletions

View File

@ -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

View File

@ -261,6 +261,7 @@ void AscendKernelRuntime::ReleaseDeviceRes() {
mem_manager_->FreeDeviceMemory();
}
(void)DestroySingleOpHccl();
(void)DestroyHccl();
(void)ResetDevice();
(void)ProfilingManager::GetInstance().StopProfiling();
@ -762,11 +763,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) {
@ -821,21 +817,10 @@ bool AscendKernelRuntime::HcclInit() {
}
bool AscendKernelRuntime::DestroySingleOpHccl() {
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
if (context_ptr->get_param<int>(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<bool>(MS_CTX_ENABLE_HCCL, false);
return true;
}