|
|
|
@ -111,6 +111,9 @@ const char *const kWorkSpaceSize = "workspace_size";
|
|
|
|
|
const char *const kTotalSize = "total_size";
|
|
|
|
|
const char *const kTaskCount = "task_count";
|
|
|
|
|
const char *const kTaskId = "task_id";
|
|
|
|
|
const char *const kIndexId = "index_id";
|
|
|
|
|
const char *const kTimeStamp = "time_stamp";
|
|
|
|
|
const char *const kTagId = "tag_id";
|
|
|
|
|
const char* const kRequestId = "request_id";
|
|
|
|
|
const char* const kThreadId = "thread_id";
|
|
|
|
|
const char* const kInputBeginTime = "input_begin_time";
|
|
|
|
@ -2305,6 +2308,61 @@ Status DavinciModel::SinkTimeProfile(const InputData ¤t_data) {
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Status DavinciModel::ProfileStepInfo(DavinciModel *model, uint16_t tag_id) {
|
|
|
|
|
if (ProfilingManager::Instance().ProfilingModelExecuteOn()) {
|
|
|
|
|
uint64_t index_id = model->iterator_count_ + 1;
|
|
|
|
|
uint64_t model_id = static_cast<uint64_t>(model->Id());
|
|
|
|
|
rtError_t rt_ret = RT_ERROR_NONE;
|
|
|
|
|
#ifndef ONLY_COMPILE_OPEN_SRC
|
|
|
|
|
rtStream_t stream = model->rt_model_stream_;
|
|
|
|
|
GELOGD("Profiling Step Info TraceTask execute async start, index_id = %lu, model_id = %lu, tag_id = %u",
|
|
|
|
|
index_id, model_id, tag_id);
|
|
|
|
|
rt_ret = rtProfilerTraceEx(index_id, model_id, tag_id, stream);
|
|
|
|
|
if (rt_ret != RT_ERROR_NONE) {
|
|
|
|
|
GELOGE(RT_FAILED, "[Call][rtProfilerTraceEx] failed, ret: 0x%X", rt_ret);
|
|
|
|
|
return RT_ERROR_TO_GE_STATUS(rt_ret);
|
|
|
|
|
}
|
|
|
|
|
GELOGD("Profiling Step Info TraceTask execute async success, index_id = %lu, model_id = %lu, tag_id = %u",
|
|
|
|
|
index_id, model_id, tag_id);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
mmTimespec timespec = mmGetTickCount();
|
|
|
|
|
// 1000 ^ 3 converts second to nanosecond
|
|
|
|
|
int64_t time = timespec.tv_sec * 1000 * 1000 * 1000 + timespec.tv_nsec;
|
|
|
|
|
uint32_t task_id = 0;
|
|
|
|
|
uint32_t stream_id = 0;
|
|
|
|
|
rt_ret = rtGetTaskIdAndStreamID(&task_id, &stream_id);
|
|
|
|
|
if (rt_ret != RT_ERROR_NONE) {
|
|
|
|
|
GELOGE(RT_FAILED, "[Get][RtsInfo] task_id and stream_id failed, ret: 0x%X.", rt_ret);
|
|
|
|
|
return RT_ERROR_TO_GE_STATUS(rt_ret);
|
|
|
|
|
}
|
|
|
|
|
GELOGD("Get profiling args, task_id[%u], stream_id[%u]", task_id, stream_id);
|
|
|
|
|
int32_t device_id = static_cast<int32_t>(model->GetDeviceId());
|
|
|
|
|
|
|
|
|
|
Json step_info;
|
|
|
|
|
step_info[kIndexId] = index_id;
|
|
|
|
|
step_info[kModeleId] = model_id;
|
|
|
|
|
step_info[kTimeStamp] = time;
|
|
|
|
|
step_info[kTagId] = tag_id;
|
|
|
|
|
step_info[kTaskId] = task_id;
|
|
|
|
|
step_info[kStreamId] = stream_id;
|
|
|
|
|
step_info[kThreadId] = mmGetTid();
|
|
|
|
|
|
|
|
|
|
std::string reported_data;
|
|
|
|
|
try {
|
|
|
|
|
reported_data = step_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore);
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
|
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what());
|
|
|
|
|
} catch (...) {
|
|
|
|
|
GELOGE(FAILED, "Failed to convert JSON to string.");
|
|
|
|
|
}
|
|
|
|
|
reported_data.append(",")
|
|
|
|
|
.append("\n");
|
|
|
|
|
ProfilingManager::Instance().ReportData(device_id, reported_data, "step_info");
|
|
|
|
|
}
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DavinciModel::SetProfileTime(ModelProcStage stage, int64_t endTime) {
|
|
|
|
|
int64_t time = endTime;
|
|
|
|
|
|
|
|
|
@ -2599,6 +2657,8 @@ void *DavinciModel::Run(DavinciModel *model) {
|
|
|
|
|
GELOGI("data_wrapper is null!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// tag_id 0 means step begin, 1 meas step end.
|
|
|
|
|
(void)DavinciModel::ProfileStepInfo(model, 0);
|
|
|
|
|
GELOGI("Getting the input data, model_id:%u", model_id);
|
|
|
|
|
GE_IF_BOOL_EXEC(!model->RunFlag(), break);
|
|
|
|
|
|
|
|
|
@ -2678,6 +2738,8 @@ void *DavinciModel::Run(DavinciModel *model) {
|
|
|
|
|
GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(),
|
|
|
|
|
model->SetProfileTime(MODEL_AFTER_PROC_END));
|
|
|
|
|
GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), (void)model->SinkTimeProfile(current_data));
|
|
|
|
|
// tag_id 0 means step begin, 1 meas step end.
|
|
|
|
|
(void)DavinciModel::ProfileStepInfo(model, 1);
|
|
|
|
|
|
|
|
|
|
model->iterator_count_++;
|
|
|
|
|
model->is_first_execute_ = false;
|
|
|
|
@ -3693,12 +3755,16 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa
|
|
|
|
|
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_PRE_PROC_END));
|
|
|
|
|
|
|
|
|
|
if (!task_list_.empty()) {
|
|
|
|
|
// tag_id 0 means step begin, 1 meas step end.
|
|
|
|
|
GE_CHK_STATUS_RET_NOLOG(ProfileStepInfo(this, 0));
|
|
|
|
|
GELOGD("rtModelExecute do");
|
|
|
|
|
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_INFER_START));
|
|
|
|
|
rtError_t rt_ret = rtModelExecute(rt_model_handle_, rt_model_stream_, 0);
|
|
|
|
|
GE_CHK_RT_EXEC(rt_ret, return RT_ERROR_TO_GE_STATUS(rt_ret));
|
|
|
|
|
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_INFER_END));
|
|
|
|
|
GELOGD("rtModelExecute end");
|
|
|
|
|
GE_CHK_STATUS_RET_NOLOG(ProfileStepInfo(this, 1));
|
|
|
|
|
iterator_count_++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!is_async_mode_) {
|
|
|
|
|