Skip to content

Commit

Permalink
Default TreadPool size to number of physical cores
Browse files Browse the repository at this point in the history
TODO: Some benchmarks
  • Loading branch information
malfet authored and pytorchmergebot committed May 23, 2024
1 parent bbe68a1 commit be2399a
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit be2399a

Please sign in to comment.