areusch commented on a change in pull request #7983:
URL: https://github.com/apache/tvm/pull/7983#discussion_r663178912
##########
File path: src/runtime/thread_pool.cc
##########
@@ -258,32 +258,21 @@ class SpscTaskQueue {
class ThreadPool {
public:
ThreadPool() : num_workers_(tvm::runtime::threading::MaxConcurrency()) {
- 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()));
- }
const char* exclude_worker0 = getenv("TVM_EXCLUDE_WORKER0");
if (exclude_worker0 && atoi(exclude_worker0) == 0) {
exclude_worker0_ = false;
}
- threads_ = std::unique_ptr<tvm::runtime::threading::ThreadGroup>(
- new tvm::runtime::threading::ThreadGroup(
- num_workers_, [this](int worker_id) { this->RunWorker(worker_id);
},
- exclude_worker0_ /* include_main_thread */));
- num_workers_used_ = threads_->Configure(threading::ThreadGroup::kBig, 0,
exclude_worker0_);
+ Init();
}
+
~ThreadPool() {
for (std::unique_ptr<SpscTaskQueue>& q : queues_) {
q->SignalForKill();
}
threads_.reset();
}
- void Reset() {
- for (std::unique_ptr<SpscTaskQueue>& q : queues_) {
- q->SignalForKill();
- }
- queues_.clear();
- threads_.reset();
+
+ void Init() {
Review comment:
wait but this should be private, no?
--
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]