Make use of hyperthreading for worker threads. Still cap to 16 workers.

This commit is contained in:
Henrik Rydgård
2021-06-13 00:05:18 +02:00
parent 62eadd2dac
commit 1d59560409
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -97,15 +97,17 @@ static void WorkerThreadFunc(GlobalThreadContext *global, ThreadContext *thread)
}
}
void ThreadManager::Init(int numRealCores, int numLogicalCores) {
void ThreadManager::Init(int numRealCores, int numLogicalCoresPerCpu) {
if (!global_->threads_.empty()) {
Teardown();
}
numComputeThreads_ = std::min(numRealCores, MAX_CORES_TO_USE);
numComputeThreads_ = std::min(numRealCores * numLogicalCoresPerCpu, MAX_CORES_TO_USE);
int numThreads = numComputeThreads_ + EXTRA_THREADS;
numThreads_ = numThreads;
INFO_LOG(SYSTEM, "ThreadManager::Init(compute threads: %d, all: %d)", numComputeThreads_, numThreads_);
for (int i = 0; i < numThreads; i++) {
ThreadContext *thread = new ThreadContext();
thread->cancelled.store(false);