Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default TreadPool size to number of physical cores #125963

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions c10/core/thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ size_t TaskThreadPoolBase::defaultNumThreads() {
size_t num_threads = 0;
#if !defined(__powerpc__) && !defined(__s390x__)
if (cpuinfo_initialize()) {
// In cpuinfo parlance cores are physical ones and processors are virtual
// ThreadPool should be defaulted to number of physical cores
size_t num_cores = cpuinfo_get_cores_count();
num_threads = cpuinfo_get_processors_count();
if (num_cores > 0 && num_cores < num_threads) {
return num_cores;
}
if (num_threads > 0) {
return num_threads;
}
Expand Down