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 597fc583f1f..923179bfd19 100644 --- a/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc +++ b/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.cc @@ -88,14 +88,12 @@ void HcclDynamicKernel::StaticShapeExecute() { void HcclDynamicKernel::Execute() { MS_LOG(INFO) << "Start Execute"; - auto handle = HcclExecutorManager::GetInstance().handle(); auto EnqueueHcomOperation = - (HcclResult(*)(ge::HcomOpertion, std::function))dlsym(handle, "EnqueueHcomOpertion"); + (HcclResult(*)(ge::HcomOpertion, std::function))HcclExecutorManager::GetInstance() + .GetHcomOpertion(); if (EnqueueHcomOperation == nullptr) { MS_LOG(ERROR) << "Failed to get EnqueueHcomOperation function"; - if (dlclose(handle) != 0) { - MS_LOG(WARNING) << "Failed to close hcom handle"; - } + HcclExecutorManager::GetInstance().CloseHandle(); MS_LOG(EXCEPTION) << "Hccl dynamic kernel execute failed"; return; } @@ -186,6 +184,13 @@ bool HcclExecutorManager::Finalize() { MS_LOG(INFO) << "Hccl DynamicKernel Finalize success"; return true; } + +void *HcclExecutorManager::GetHcomOpertion() { return dlsym(handle_, "EnqueueHcomOpertion"); } +void HcclExecutorManager::CloseHandle() { + if (dlclose(handle_) != 0) { + MS_LOG(WARNING) << "Failed to close hcom handle"; + } +} } // namespace ascend } // namespace device } // namespace mindspore diff --git a/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.h b/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.h index b164bbd9861..cebbdb0472e 100644 --- a/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.h +++ b/mindspore/ccsrc/runtime/device/ascend/executor/hccl_dynamic_kernel.h @@ -66,7 +66,8 @@ class HcclExecutorManager { bool Initialize(); bool Finalize(); - void *handle() { return handle_; } + void *GetHcomOpertion(); + void CloseHandle(); private: HcclExecutorManager() = default;