[pthreadpool] Don't recreate threadpool if the counts are same (#90478)

Summary: Don't do anything if the incoming count and current threadpool size are same

Test Plan: CI

Reviewed By: salilsdesai

Differential Revision: D41628132

Pull Request resolved: https://github.com/pytorch/pytorch/pull/90478
Approved by: https://github.com/salilsdesai
This commit is contained in:
Digant Desai
2022-12-10 03:17:08 +00:00
committed by PyTorch MergeBot
parent 3b3ed25109
commit d3a3604581

View File

@ -30,6 +30,11 @@ size_t PThreadPool::get_thread_count() const {
}
void PThreadPool::set_thread_count(const size_t thread_count) {
// No need to do anything if the count is same
if (thread_count == get_thread_count()) {
return;
}
std::lock_guard<std::mutex> lock{mutex_};
// As it stands, pthreadpool is an entirely data parallel framework with no