From 468e257a146dca74251ad7470e5515c624ffc614 Mon Sep 17 00:00:00 2001 From: shibeiji Date: Mon, 30 Mar 2020 17:55:28 +0800 Subject: [PATCH] add log for kernel runtime in order to trace performance --- mindspore/ccsrc/device/kernel_runtime.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mindspore/ccsrc/device/kernel_runtime.cc b/mindspore/ccsrc/device/kernel_runtime.cc index f320aa9cf6..99f5d491ac 100644 --- a/mindspore/ccsrc/device/kernel_runtime.cc +++ b/mindspore/ccsrc/device/kernel_runtime.cc @@ -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(end_time.tv_sec - start_time.tv_sec); + cost += static_cast(end_time.tv_usec - start_time.tv_usec); + MS_LOG(INFO) << "Call MS Run Success in " << cost << " us"; return ret; }