From 39039974b25919e22dd560e1af3fe757c76e5d85 Mon Sep 17 00:00:00 2001 From: caifubi Date: Thu, 17 Sep 2020 21:16:54 +0800 Subject: [PATCH] fix profiling start up fail --- graphengine | 2 +- .../ascend/profiling/profiling_manager.cc | 27 +++++++++++++++++-- tests/ut/cpp/stub/runtime/runtime_stub.cc | 4 +-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/graphengine b/graphengine index 6dcf11d26e..4f6ebe0f92 160000 --- a/graphengine +++ b/graphengine @@ -1 +1 @@ -Subproject commit 6dcf11d26eca81a328c7069235c7675c557fe0c0 +Subproject commit 4f6ebe0f92da8c758b1b71a2bc7ff33f9344e18a diff --git a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc index b8e15c1886..efa0cd99f0 100644 --- a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc +++ b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc @@ -26,6 +26,11 @@ #include "utils/ms_utils.h" #include "utils/convert_utils.h" #include "runtime/base.h" +#include "toolchain/prof_acl_api.h" + +namespace { +constexpr uint32_t kProfilingDeviceNum = 1; +} namespace mindspore { namespace device { @@ -102,6 +107,12 @@ static std::vector Split(const std::string &str, const char delim) return elems; } +uint64_t GetProfilingModule() { + return PROF_MODEL_EXECUTE_MASK | PROF_RUNTIME_API_MASK | PROF_RUNTIME_TRACE_MASK | PROF_SCHEDULE_TIMELINE_MASK | + PROF_SCHEDULE_TRACE_MASK | PROF_TASK_TIME_MASK | PROF_SUBTASK_TIME_MASK | PROF_AICPU_TRACE_MASK | + PROF_AICORE_METRICS_MASK | PROF_AIVECTORCORE_METRICS_MASK | PROF_MODEL_LOAD_MASK; +} + bool ProfilingManager::StartupProfiling(uint32_t device_id) { auto is_profiling = IsProfiling(); if (!is_profiling) { @@ -151,13 +162,22 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) { return true; } +uint32_t GetCurrentDeviceId() { + auto context = MsContext::GetInstance(); + MS_EXCEPTION_IF_NULL(context); + return context->get_param(MS_CTX_DEVICE_ID); +} + bool ProfilingManager::ProfStartUp(const nlohmann::json &startCfg) { // convert json to string std::stringstream ss; ss << startCfg; std::string cfg = ss.str(); MS_LOG(INFO) << "profiling config " << cfg; - auto ret = rtProfilerStart(); + + auto module = GetProfilingModule(); + auto device_id = GetCurrentDeviceId(); + auto ret = rtProfilerStart(module, kProfilingDeviceNum, &device_id); if (ret != RT_ERROR_NONE) { MS_LOG(INFO) << "Call rtProfilerStart failed, ret:" << ret; return false; @@ -185,7 +205,10 @@ bool ProfilingManager::StopProfiling() { MS_LOG(INFO) << "report data end, ret = " << ret; } - auto rt_ret = rtProfilerStop(); + auto module = GetProfilingModule(); + uint32_t device_ids[kProfilingDeviceNum] = {GetCurrentDeviceId()}; + + auto rt_ret = rtProfilerStop(module, kProfilingDeviceNum, device_ids); if (rt_ret != RT_ERROR_NONE) { MS_LOG(ERROR) << "Call rtProfilerStop failed"; return false; diff --git a/tests/ut/cpp/stub/runtime/runtime_stub.cc b/tests/ut/cpp/stub/runtime/runtime_stub.cc index 8967c11ecf..f5ca261cdc 100644 --- a/tests/ut/cpp/stub/runtime/runtime_stub.cc +++ b/tests/ut/cpp/stub/runtime/runtime_stub.cc @@ -134,6 +134,6 @@ rtError_t rtGetFunctionByName(const char *stubName, void **stubFunc) { return RT rtError_t rtSetTaskGenCallback(rtTaskGenCallback callback) { return RT_ERROR_NONE; } -rtError_t rtProfilerStart(void) { return RT_ERROR_NONE; } +RTS_API rtError_t rtProfilerStart(uint64_t profConfig, int32_t numsDev, uint32_t* deviceList) { return RT_ERROR_NONE; } -rtError_t rtProfilerStop(void) { return RT_ERROR_NONE; } +RTS_API rtError_t rtProfilerStop(uint64_t profConfig, int32_t numsDev, uint32_t* deviceList) { return RT_ERROR_NONE; }