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 2023/01/24 21:06:37 UTC

[tvm] branch main updated: [RUNTIME] Fix determination of big/little cores domains (#13832)

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 6fdb1b7e38 [RUNTIME] Fix determination of big/little cores domains (#13832)
6fdb1b7e38 is described below

commit 6fdb1b7e385efd1e296b94dd7f9fc2e0782b675a
Author: Andrey Malyshev <el...@gmail.com>
AuthorDate: Tue Jan 24 23:06:30 2023 +0200

    [RUNTIME] Fix determination of big/little cores domains (#13832)
    
    In case of three or more domains we starts to treat non little
    cores as big ones and offload work to them as well by default. This
    fix current modern schemes like 1-3-4 scheme with 1 huge, 3 big cores and 4
    little cores and causes tvm to use huge and big cores for inference
---
 src/runtime/threading_backend.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/runtime/threading_backend.cc b/src/runtime/threading_backend.cc
index 9f7f2cd8d9..b6e12a25cc 100644
--- a/src/runtime/threading_backend.cc
+++ b/src/runtime/threading_backend.cc
@@ -306,7 +306,11 @@ class ThreadGroup::Impl {
       int64_t cur_freq = 0;
 #if defined(__linux__) || defined(__ANDROID__)
       std::ostringstream filepath;
-      filepath << "/sys/devices/system/cpu/cpu" << i << "/cpufreq/scaling_max_freq";
+      // according to https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt
+      // it's better to use cpuinfo_max_freq instead of scaling_max_freq for our
+      // purposes since scaling values can be changed dynamically according "policy limits"
+      // while we are looking for persistent definition of cores
+      filepath << "/sys/devices/system/cpu/cpu" << i << "/cpufreq/cpuinfo_max_freq";
       std::ifstream ifs(filepath.str());
       if (!ifs.fail()) {
         if (!(ifs >> cur_freq)) {
@@ -335,7 +339,8 @@ class ThreadGroup::Impl {
       }
     }
     if (big_count_ + little_count_ != static_cast<int>(sorted_order_.size())) {
-      LOG(WARNING) << "more than two frequencies detected!";
+      big_count_ = static_cast<int>(sorted_order_.size()) - little_count_;
+      LOG(WARNING) << "more than two frequencies detected! Forced big_count_ to " << big_count_;
     }
   }