You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ju...@apache.org on 2021/03/12 04:25:56 UTC
[tvm] branch main updated: [RUNTIME] Switch time evaluator to use
device specific timing. (#7631)
This is an automated email from the ASF dual-hosted git repository.
junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 9d72bd0 [RUNTIME] Switch time evaluator to use device specific timing. (#7631)
9d72bd0 is described below
commit 9d72bd051bdc02ab678d223a794ab6cb607866ba
Author: Tristan Konolige <tr...@gmail.com>
AuthorDate: Thu Mar 11 20:25:35 2021 -0800
[RUNTIME] Switch time evaluator to use device specific timing. (#7631)
---
src/runtime/rpc/rpc_module.cc | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/runtime/rpc/rpc_module.cc b/src/runtime/rpc/rpc_module.cc
index 4f721e1..3469141 100644
--- a/src/runtime/rpc/rpc_module.cc
+++ b/src/runtime/rpc/rpc_module.cc
@@ -23,6 +23,7 @@
*/
#include <tvm/runtime/container.h>
#include <tvm/runtime/device_api.h>
+#include <tvm/runtime/profiling.h>
#include <tvm/runtime/registry.h>
#include <cstring>
@@ -364,8 +365,6 @@ PackedFunc WrapTimeEvaluator(PackedFunc pf, TVMContext ctx, int number, int repe
if (f_preproc != nullptr) {
f_preproc.CallPacked(args, &temp);
}
- std::chrono::time_point<std::chrono::high_resolution_clock, std::chrono::nanoseconds> tbegin,
- tend;
double duration_ms = 0.0;
do {
@@ -374,20 +373,17 @@ PackedFunc WrapTimeEvaluator(PackedFunc pf, TVMContext ctx, int number, int repe
number * 1.618)); // 1.618 is chosen by random
}
- tbegin = std::chrono::high_resolution_clock::now();
+ Timer t = Timer::Start(ctx);
// start timing
for (int i = 0; i < number; ++i) {
pf.CallPacked(args, &temp);
}
- DeviceAPI::Get(ctx)->StreamSync(ctx, nullptr);
- tend = std::chrono::high_resolution_clock::now();
-
- duration_ms =
- std::chrono::duration_cast<std::chrono::duration<double>>(tend - tbegin).count() * 1000;
+ t->Stop();
+ int64_t t_nanos = t->SyncAndGetElapsedNanos();
+ duration_ms = t_nanos / 1e6;
} while (duration_ms < min_repeat_ms);
- double speed =
- std::chrono::duration_cast<std::chrono::duration<double>>(tend - tbegin).count() / number;
+ double speed = duration_ms / 1e3 / number;
os.write(reinterpret_cast<char*>(&speed), sizeof(speed));
}