!27 add log for kernel runtime in order to trace performance

Merge pull request !27 from shibeiji/master
This commit is contained in:
mindspore-ci-bot 2020-03-31 11:13:27 +08:00 committed by Gitee
commit 84a61bd015
1 changed files with 7 additions and 0 deletions

View File

@ -50,12 +50,19 @@ bool KernelRuntime::Run(session::KernelGraph *graph) {
bool ret = false;
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
struct timeval start_time, end_time;
(void)gettimeofday(&start_time, nullptr);
bool is_task_sink = context_ptr->enable_task_sink();
if (is_task_sink) {
ret = RunTask(graph);
} else {
ret = LaunchKernel(graph);
}
(void)gettimeofday(&end_time, nullptr);
const uint64_t kUSecondInSecond = 1000000;
uint64_t cost = kUSecondInSecond * static_cast<uint64_t>(end_time.tv_sec - start_time.tv_sec);
cost += static_cast<uint64_t>(end_time.tv_usec - start_time.tv_usec);
MS_LOG(INFO) << "Call MS Run Success in " << cost << " us";
return ret;
}