10000 Default TreadPool size to number of physical cores · pytorch/pytorch@230082a · GitHub
[go: up one dir, main page]

Skip to content

Commit 230082a

Browse files
authored
Default TreadPool size to number of physical cores
TODO: Some benchmarks
1 parent 538877d commit 230082a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

c10/core/thread_pool.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ size_t TaskThreadPoolBase::defaultNumThreads() {
1010
size_t num_threads = 0;
1111
#if !defined(__powerpc__) && !defined(__s390x__)
1212
if (cpuinfo_initialize()) {
13+
// In cpuinfo parlance cores are physical ones and processors are virtual
14+
// ThreadPool should be defaulted to number of physical cores
15+
size_t num_cores = cpuinfo_get_cores_count();
1316
num_threads = cpuinfo_get_processors_count();
17+
if (num_cores > 0 && num_cores < num_threads) {
18+
return num_cores;
19+
}
1420
if (num_threads > 0) {
1521
return num_threads;
1622
}

0 commit comments

Comments
 (0)
0