fix profiling start up fail

This commit is contained in:
caifubi 2020-09-17 21:16:54 +08:00
parent 5a76bd717d
commit 39039974b2
3 changed files with 28 additions and 5 deletions

@ -1 +1 @@
Subproject commit 6dcf11d26eca81a328c7069235c7675c557fe0c0
Subproject commit 4f6ebe0f92da8c758b1b71a2bc7ff33f9344e18a

View File

@ -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<std::string> 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<uint32_t>(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;

View File

@ -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; }