From 6e12fb164401265304111e4c0f2fafb935f67d23 Mon Sep 17 00:00:00 2001 From: caifubi Date: Tue, 16 Jun 2020 11:04:58 +0800 Subject: [PATCH] set prof_handle_ to nullptr after release --- mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc | 4 +++- mindspore/ccsrc/device/ascend/profiling/profiling_manager.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc b/mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc index 6cf3cad62f..adc6407af2 100644 --- a/mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc +++ b/mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc @@ -169,7 +169,7 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) { return true; } -bool ProfilingManager::StopProfiling() const { +bool ProfilingManager::StopProfiling() { MS_LOG(INFO) << "StopProfiling"; if (!IsProfiling()) { MS_LOG(INFO) << "No need profiling. please export PROFILING_MODE and in train mode."; @@ -184,8 +184,10 @@ bool ProfilingManager::StopProfiling() const { int result = ProfMgrStop(prof_handle_); if (result != 0) { MS_LOG(ERROR) << "ProfMgr stop return fail:" << result << "."; + prof_handle_ = nullptr; return false; } + prof_handle_ = nullptr; } return true; diff --git a/mindspore/ccsrc/device/ascend/profiling/profiling_manager.h b/mindspore/ccsrc/device/ascend/profiling/profiling_manager.h index f0c25d7f8a..c30c6898ea 100644 --- a/mindspore/ccsrc/device/ascend/profiling/profiling_manager.h +++ b/mindspore/ccsrc/device/ascend/profiling/profiling_manager.h @@ -39,7 +39,7 @@ class ProfilingManager { uint64_t GetJobId() const; bool ReportProfilingData(const map &op_taskId_map) const; bool StartupProfiling(uint32_t device_id); - bool StopProfiling() const; + bool StopProfiling(); inline bool IsProfiling() const { auto context = MsContext::GetInstance();