From 09946fcad5be9290908d53aa060eae572498a709 Mon Sep 17 00:00:00 2001 From: caifubi Date: Tue, 11 Aug 2020 15:18:19 +0800 Subject: [PATCH] Support Profiling With Graph Only Have Hccl Op --- .../device/ascend/profiling/profiling_utils.cc | 3 ++- mindspore/ccsrc/runtime/device/kernel_adjust.cc | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_utils.cc b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_utils.cc index ed96f6ed2a..643e35ac0b 100644 --- a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_utils.cc +++ b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_utils.cc @@ -167,7 +167,8 @@ std::string ProfilingUtils::GetGraphLastTbeKernelName(const std::vectorfullname_with_scope(); break; } diff --git a/mindspore/ccsrc/runtime/device/kernel_adjust.cc b/mindspore/ccsrc/runtime/device/kernel_adjust.cc index 513fa68252..2aa44397c1 100644 --- a/mindspore/ccsrc/runtime/device/kernel_adjust.cc +++ b/mindspore/ccsrc/runtime/device/kernel_adjust.cc @@ -35,6 +35,9 @@ #include "runtime/base.h" #include "runtime/device/ascend/ascend_stream_assign.h" +namespace { +constexpr auto kProfilingGraphId = "PROFILING_GRAPH_ID"; +} // namespace namespace mindspore { namespace device { using device::ascend::ProfilingUtils; @@ -557,6 +560,15 @@ void KernelAdjust::Profiling(NotNull kernel_graph_ptr) { MS_LOG(INFO) << "No need to profiling"; return; } + auto graph_id_env = std::getenv(kProfilingGraphId); + if (graph_id_env != nullptr) { + auto graph_id = std::stoul(graph_id_env); + if (graph_id != kernel_graph_ptr->graph_id()) { + MS_LOG(WARNING) << "Get PROFILING_GRAPH_ID " << graph_id + << " Not Match Current Graph Id:" << kernel_graph_ptr->graph_id(); + return; + } + } ProfilingTraceInfo profiling_trace_info = ProfilingUtils::GetProfilingTraceFromEnv(kernel_graph_ptr); if (!profiling_trace_info.IsValid()) { MS_LOG(WARNING) << "[profiling] no profiling node found!";