areusch commented on a change in pull request #7983:
URL: https://github.com/apache/tvm/pull/7983#discussion_r662484447



##########
File path: src/runtime/thread_pool.cc
##########
@@ -278,6 +278,22 @@ class ThreadPool {
     }
     threads_.reset();
   }
+  void Reset() {
+    for (std::unique_ptr<SpscTaskQueue>& q : queues_) {
+      q->SignalForKill();
+    }
+    queues_.clear();
+    threads_.reset();
+    for (int i = 0; i < num_workers_; ++i) {
+      // The SpscTaskQueue only hosts ONE item at a time
+      queues_.emplace_back(std::unique_ptr<SpscTaskQueue>(new 
SpscTaskQueue()));
+    }
+    threads_ = std::unique_ptr<tvm::runtime::threading::ThreadGroup>(

Review comment:
       would be great if this logic could be shared with ctor

##########
File path: src/runtime/profiling.cc
##########
@@ -100,16 +102,37 @@ 
TVM_REGISTER_GLOBAL("profiling.start_timer").set_body_typed(Timer::Start);
 
 namespace profiling {
 
-void Profiler::Start(const std::vector<Device>& devs) {
-  CHECK(global_timers_.empty()) << "You can only call Start once per 
Profiler.";
+Profiler::Profiler(std::vector<Device> devs, std::vector<MetricCollector> 
metric_collectors)
+    : devs_(devs), collectors_(metric_collectors) {
+  is_running_ = false;
+  std::vector<DeviceWrapper> wrapped_devs;
   for (auto dev : devs) {
-    global_timers_.emplace_back(dev, Timer::Start(dev));
+    wrapped_devs.push_back(DeviceWrapper(make_object<DeviceWrapperNode>(dev)));
+  }
+  for (auto& x : collectors_) {
+    x->Init(wrapped_devs);
+  }
+  // reset the thread pool so that PAPI eventset hooks are set in all threads.
+  threading::ResetThreadPool();

Review comment:
       is this side effect documented anywhere?

##########
File path: python/tvm/runtime/profiler_vm.py
##########
@@ -50,14 +50,17 @@ def get_stat(self, sort_by_time=True):  # pylint: 
disable=unused-argument
         warnings.warn("get_stat has been removed, use profile instead")
         return ""
 
-    def profile(self, *args, func_name="main", **kwargs):
+    def profile(self, *args, func_name="main", collectors=[], **kwargs):

Review comment:
       can you fix this one too?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to