From 5e2d692cec30b08e8ed09be357090b849785823c Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Wed, 2 May 2012 07:17:08 +0200 Subject: [PATCH] Lock the DSP thread on its own core when using "Lock threads to cores" and "LLE on Thread". Greatly improves DSPLLE performance on Linux with >= 3 cores CPUs. --- Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp index a795b4966d..c3b6a2d674 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp @@ -24,6 +24,8 @@ #include "Thread.h" #include "ChunkFile.h" #include "IniFile.h" +#include "ConfigManager.h" +#include "CPUDetect.h" #include "DSPLLEGlobals.h" // Local #include "DSP/DSPInterpreter.h" @@ -84,6 +86,27 @@ void DSPLLE::dsp_thread(DSPLLE *dsp_lle) { Common::SetCurrentThreadName("DSP thread"); + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bLockThreads) + { + if (cpu_info.num_cores > 3) + { + // HACK (delroth): there is no way to know where hyperthreads are in + // the current Dolphin version. + bool windows = false; +#ifdef _WIN32 + windows = true; +#endif + + u8 core_id; + if (windows && cpu_info.num_cores > 4) // Probably HT + core_id = 5; // 3rd non HT core + else + core_id = 3; // 3rd core + + Common::SetCurrentThreadAffinity(1 << core_id); + } + } + while (dsp_lle->m_bIsRunning) { int cycles = (int)dsp_lle->m_cycle_count;