From fa6293d90535eb93c0ccb84b76f91316434e7784 Mon Sep 17 00:00:00 2001 From: caifubi Date: Mon, 12 Oct 2020 15:47:41 +0800 Subject: [PATCH] fix hccl dynamic kernel finalize bug --- .../device/ascend/executor/hccl_dynamic_kernel.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc b/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc index de6bd7b9854..9de582d38eb 100644 --- a/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc +++ b/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc @@ -138,6 +138,11 @@ bool HcclExecutorManager::Initialize() { if (initialized_) { return true; } + auto context = MsContext::GetInstance(); + MS_EXCEPTION_IF_NULL(context); + if (!context->get_param(MS_CTX_ENABLE_HCCL)) { + return true; + } initialized_ = true; MS_LOG(INFO) << "Start Initialize Hccl DynamicKernel"; handle_ = dlopen(kHcomGraphAdaptorPath, RTLD_NOW | RTLD_GLOBAL); @@ -165,9 +170,12 @@ bool HcclExecutorManager::Initialize() { } bool HcclExecutorManager::Finalize() { + if (!initialized_) { + return true; + } auto HcomExecutorFinalize = (HcclResult(*)())dlsym(handle_, "HcomExcutorFinalize"); if (HcomExecutorFinalize == nullptr) { - MS_LOG(ERROR) << "Faile to dlsym HcomExecutorFinalize"; + MS_LOG(ERROR) << "Fail to dlsym HcomExecutorFinalize"; return false; } HcclResult hccl_ret = HcomExecutorFinalize(); @@ -179,7 +187,7 @@ bool HcclExecutorManager::Finalize() { MS_LOG(ERROR) << "Failed to close hcom handle"; return false; } - MS_LOG(INFO) << "Hccl DynamicKernel Finalize failed"; + MS_LOG(INFO) << "Hccl DynamicKernel Finalize success"; return true; } } // namespace ascend