mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
[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:
committed by
PyTorch MergeBot
parent
3b3ed25109
commit
d3a3604581
@ -30,6 +30,11 @@ size_t PThreadPool::get_thread_count() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PThreadPool::set_thread_count(const size_t thread_count) {
|
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_};
|
std::lock_guard<std::mutex> lock{mutex_};
|
||||||
|
|
||||||
// As it stands, pthreadpool is an entirely data parallel framework with no
|
// As it stands, pthreadpool is an entirely data parallel framework with no
|
||||||
|
Reference in New Issue
Block a user